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

CVE-2025-31475: Tarteaucitronjs Prototype Pollution Vulnerability

CVE-2025-31475 is a prototype pollution flaw in tarteaucitronjs that enables attackers with high privileges to manipulate JavaScript object prototypes. This article covers technical details, affected versions, and mitigation steps.

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-31475 Overview

CVE-2025-31475 is a prototype pollution vulnerability in tarteaucitron.js, an accessible cookie consent banner used on web applications. The flaw resides in the AddOrUpdate function, which applies custom text configurations without validating dangerous object keys. An attacker with high-privilege access to the site's source code or a Content Management System (CMS) plugin can inject properties such as __proto__ or constructor to pollute JavaScript object prototypes. Successful exploitation can corrupt application data, trigger crashes, or introduce follow-on vulnerabilities depending on how the host application consumes modified prototypes. The vulnerability affects tarteaucitron.js versions prior to 1.20.1 and is tracked under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes.

Critical Impact

Prototype pollution in tarteaucitron.js can modify core JavaScript object behavior across a site, enabling data corruption, denial of service, or chained code execution.

Affected Products

  • tarteaucitron.js versions prior to 1.20.1
  • Node.js deployments of amauri:tarteaucitronjs
  • Web applications and CMS plugins embedding vulnerable builds of the library

Discovery Timeline

  • 2025-04-07 - CVE-2025-31475 published to the National Vulnerability Database (NVD)
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-31475

Vulnerability Analysis

The vulnerability exists in the tarteaucitron.AddOrUpdate utility, which recursively merges a custom object into a source object to apply user-defined banner texts. The pre-patch implementation iterates every enumerable key in custom using a for...in loop and copies values into source without filtering reserved prototype keys. When an attacker-controlled configuration includes a key such as __proto__, assignment walks up the prototype chain of Object.prototype, globally modifying inherited properties for every object in the running JavaScript context. Downstream consumers that rely on in checks, default property lookups, or truthy evaluations against inherited values can behave unpredictably, crash, or execute attacker-influenced logic paths.

Root Cause

The root cause is missing key validation and absent hasOwnProperty enforcement inside the recursive merge. The function trusts that incoming keys are safe data properties, which is false when any part of the configuration pipeline accepts attacker-influenced input through a CMS plugin, theme setting, or source code injection path.

Attack Vector

Exploitation requires high privileges (PR:H) because the attacker must be able to supply or modify the custom configuration object passed to AddOrUpdate. This typically means write access to the site's source, a CMS plugin interface, or a build pipeline that forwards untrusted values into tarteaucitron's initialization. Once the polluted prototype takes effect, the scope changes (S:C) and impact extends to any JavaScript component in the page beyond the consent banner itself.

javascript
// Security patch in tarteaucitron.js - rejects prototype-polluting keys
// Source: https://github.com/AmauriC/tarteaucitron.js/commit/74c354c413ee3f82dff97a15a0a43942887c2b5b
for (var key in custom) {
    if (key === "__proto__" || key === "constructor") continue;
    if (custom.hasOwnProperty(key)) {
        if (custom[key] instanceof Object) {
            source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
        } else {
            source[key] = custom[key];
        }
    }
}
return source;

The fix explicitly skips the __proto__ and constructor keys and gates the recursive assignment behind a hasOwnProperty check, preventing merges that traverse into inherited prototype attributes.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2025-31475

Indicators of Compromise

  • Presence of tarteaucitron.js files with versions below 1.20.1 served from the web root or bundled into application assets.
  • Custom text configuration payloads containing the literal strings __proto__, constructor, or prototype as object keys.
  • Unexplained client-side JavaScript errors referencing undefined-but-truthy inherited properties on standard objects.

Detection Strategies

  • Scan web asset directories and CDN bundles for tarteaucitron.min.js and verify the version string against 1.20.1 or later.
  • Audit CMS plugin configurations, theme settings, and build pipelines that feed values into tarteaucitron.user or AddOrUpdate for suspicious keys.
  • Enable client-side error monitoring to surface prototype-pollution symptoms such as unexpected property values on empty objects.

Monitoring Recommendations

  • Log and alert on changes to front-end JavaScript bundles and CMS plugin files that reference tarteaucitron.
  • Review CMS administrator and developer account activity for configuration edits that introduce raw JavaScript object payloads.
  • Track outbound requests from pages running the consent banner for signs of chained exploitation leveraging polluted prototypes.

How to Mitigate CVE-2025-31475

Immediate Actions Required

  • Upgrade tarteaucitron.js to version 1.20.1 or later across all production, staging, and development environments.
  • Inventory CMS plugins and third-party integrations that bundle tarteaucitron.js and request updated releases from their maintainers.
  • Restrict administrative and developer privileges that permit modification of client-side scripts and consent banner configuration.

Patch Information

The fix is published in tarteaucitron.js version 1.20.1. See the GitHub commit 74c354c and the GitHub Security Advisory GHSA-4hwx-xcc5-2hfc for full details.

Workarounds

  • If immediate upgrade is not possible, sanitize all custom configuration objects to strip __proto__, constructor, and prototype keys before passing them to tarteaucitron.AddOrUpdate.
  • Apply a Content Security Policy (CSP) that restricts inline scripts and limits the sources permitted to load JavaScript bundles.
  • Enforce code review on any CMS plugin or theme change that modifies tarteaucitron initialization.
bash
# Upgrade tarteaucitron.js to the patched release
npm install tarteaucitron.js@1.20.1

# Verify the installed version
npm ls tarteaucitron.js

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.