Skip to main content
Vulnerability Database/CVE-2025-31138

CVE-2025-31138: tarteaucitron.js Clickjacking Vulnerability

CVE-2025-31138 is a clickjacking flaw in tarteaucitron.js that allows attackers with high privileges to overlay malicious UI elements and trick users. This article covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-31138 Overview

CVE-2025-31138 affects tarteaucitron.js, a cookie consent banner library used by websites to meet privacy compliance requirements. Versions prior to 1.20.1 fail to validate user-controlled inputs for element dimensions. An attacker with high privileges, such as source code access or CMS plugin control, can inject values like 100%;height:100%;position:fixed; into width and height attributes. The resulting elements can cover the entire viewport and facilitate clickjacking attacks [CWE-1021]. The maintainer addressed the issue in version 1.20.1.

Critical Impact

An authenticated attacker can overlay malicious UI elements across the full viewport, tricking users into clicking hidden components and disrupting site accessibility.

Affected Products

  • Amauri tarteaucitron.js versions prior to 1.20.1
  • Node.js deployments consuming the tarteaucitronjs package
  • Websites embedding vulnerable tarteaucitron.js builds for cookie consent

Discovery Timeline

  • 2025-04-07 - CVE-2025-31138 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-31138

Vulnerability Analysis

The vulnerability resides in how tarteaucitron.js constructs embedded media and iframe elements for consented services. The library accepts width and height values from site operators and inserts them directly into inline style attributes without sanitization. An attacker can break out of the dimension context by appending additional CSS declarations such as position:fixed, top:0, and z-index values. The injected element then covers legitimate page content and intercepts user clicks. Because the injection occurs through a trusted consent banner script, the overlay inherits the hosting site's origin and bypasses visual security cues users would otherwise notice.

Root Cause

The root cause is improper neutralization of input used in a UI layer, classified as [CWE-1021] Improper Restriction of Rendered UI Layers or Frames. Width and height parameters are concatenated into style strings without type checking or value filtering, allowing CSS property injection via semicolons.

Attack Vector

Exploitation requires high privileges, meaning the attacker must already control a vector that supplies dimension values to tarteaucitron. This includes direct access to the website source code, a compromised content management system account with widget configuration rights, or a malicious CMS plugin that calls the library. No user interaction is required beyond the victim visiting the page. The attack scope is changed because the overlay affects content and interactions outside the vulnerable component itself.

No verified proof-of-concept code is available. See the GitHub Security Advisory GHSA-7524-3396-fqv3 for maintainer details.

Detection Methods for CVE-2025-31138

Indicators of Compromise

  • DOM elements rendered by tarteaucitron.js containing inline styles with position:fixed, full-viewport dimensions, or unexpected z-index values
  • Unexpected overlay iframes or div containers injected by the consent banner across page content
  • Modifications to CMS widget configuration fields that store width or height values containing semicolons or CSS keywords

Detection Strategies

  • Inspect tarteaucitron service configuration for width or height values that contain characters other than digits, decimals, or units like px and %
  • Scan deployed JavaScript bundles for tarteaucitron.js versions earlier than 1.20.1 using software composition analysis
  • Review CMS audit logs for changes to consent banner service parameters performed by high-privilege accounts

Monitoring Recommendations

  • Enable Content Security Policy reporting to capture unexpected inline style sources on pages using tarteaucitron
  • Monitor CMS administrative actions that modify third-party widget or consent banner settings
  • Track outbound requests from site templates to confirm cookie banner assets match the expected hash of version 1.20.1 or later

How to Mitigate CVE-2025-31138

Immediate Actions Required

  • Upgrade tarteaucitron.js to version 1.20.1 or later across all production and staging environments
  • Audit existing service configurations and remove any width or height values containing CSS metacharacters such as ;, :, or }
  • Restrict CMS permissions so only trusted administrators can modify consent banner service definitions

Patch Information

The fix is available in tarteaucitron.js version 1.20.1. The maintainer added validation of dimension parameters in commit 25fcf828aaa55306ddc09cfbac9a6f8f126e2d07. Review the GitHub Security Advisory GHSA-7524-3396-fqv3 for complete remediation guidance.

Workarounds

  • Apply a Content Security Policy that disallows inline styles or restricts them with a strict nonce to limit CSS injection impact
  • Add frame-ancestors and clickjacking defenses through X-Frame-Options: DENY and frame-ancestors 'self' directives
  • Validate consent banner service inputs server-side before they reach the client, rejecting any dimension value that is not a plain numeric unit
bash
# Configuration example: upgrade tarteaucitron.js via npm
npm install tarteaucitronjs@^1.20.1
npm audit --production

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.