May 5, 2026·6 min read·24 visits
A vulnerability in Axios allows XSRF tokens to leak to cross-origin servers. This occurs when loose boolean evaluation in the configuration logic is bypassed via an external Prototype Pollution gadget.
Axios, a widely used JavaScript HTTP client, contains a vulnerability where loose truthiness checks on the `withXSRFToken` configuration property permit Cross-Site Request Forgery (XSRF) token leakage. This occurs when an application is vulnerable to Prototype Pollution, allowing attackers to short-circuit same-origin validation checks and extract anti-CSRF tokens to cross-origin servers.
Axios serves as a foundational HTTP client in modern web and Node.js ecosystems, responsible for managing requests, responses, and security headers. A core security feature provided by Axios is automatic Cross-Site Request Forgery (CSRF/XSRF) token management, which extracts tokens from cookies and attaches them to outgoing request headers. This feature is intended to operate under strict same-origin policies to prevent token leakage.
CVE-2026-42042 exposes a flaw in how Axios validates the target origin before attaching these sensitive tokens. The vulnerability resides in the configuration resolution logic, specifically within the evaluation of the withXSRFToken property. A design flaw utilizing loose truthiness semantics enables an environment-level manipulation to bypass security constraints.
When combined with a separate Prototype Pollution vulnerability within the hosting application, attackers can manipulate the global object prototype chain. This manipulation injects a truthy, non-boolean value into the Axios configuration resolution process. The resulting logical short-circuit overrides the same-origin validation, causing Axios to append the XSRF token to requests destined for attacker-controlled infrastructure.
The root cause of this vulnerability stems from unsafe type coercion within JavaScript's logical operators. The configuration resolution logic within lib/helpers/resolveConfig.js relies on a conditional statement to determine if an XSRF token should be appended to the current request. This condition evaluates the withXSRFToken property using a standard logical OR (||) operator.
The specific vulnerable construct is if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))). In JavaScript, the || operator short-circuits if the left-hand operand evaluates to any truthy value. Because the code does not enforce strict boolean typing, values such as the integer 1, strings, or objects evaluate as true.
When the left-hand side evaluates to true, the right-hand side of the expression is ignored entirely. Consequently, the critical isURLSameOrigin(newConfig.url) function is never executed. The logic implicitly trusts the truthy value and proceeds to attach the XSRF token to the request headers, completely disregarding the destination URL.
Analyzing the configuration resolution logic reveals exactly how the validation failure manifests. The application attempts to support both explicit configuration and automatic same-origin detection. This dual-purpose design introduces the logic gap when combined with polluted prototypes.
// Vulnerable code in lib/helpers/resolveConfig.js
// Evaluates to true for any truthy value (e.g., 1, "true", {})
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
// Token extraction and header attachment logic
}In the presence of prototype pollution, withXSRFToken is inherited from Object.prototype. If Object.prototype.withXSRFToken = 1, the first condition passes, and origin validation is skipped. The patched versions (1.15.1 and 0.31.1) correct this logic by enforcing strict equality checks and utilizing nullish semantics. This ensures only an explicitly defined boolean true bypasses the same-origin verification.
// Fixed code logic
// Requires strict boolean true to force cross-origin token transmission
const requiresToken = withXSRFToken === true ||
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
if (requiresToken) {
// Token extraction and header attachment logic
}By requiring withXSRFToken === true, injected prototype properties like 1 or "true" fail the strict equality check. The fallback logic then properly executes isURLSameOrigin because the inherited property does not equal null or undefined.
Exploitation of CVE-2026-42042 requires the presence of an independent Prototype Pollution vulnerability within the application or its dependency tree. The attacker must first leverage this separate flaw to pollute the global Object.prototype. The objective is to establish the specific gadget required by the Axios logic flaw.
The attacker injects a payload that sets a non-boolean truthy value onto the prototype chain. A typical payload achieves Object.prototype.withXSRFToken = 1. Once established, any standard JavaScript object created without an explicit withXSRFToken property inherits this value during property lookup.
The victim application then initializes an Axios request to a cross-origin resource controlled by the attacker. During request configuration, Axios reads newConfig.withXSRFToken. Since the configuration object lacks this key, the JavaScript engine traverses the prototype chain and returns the polluted value 1.
The Axios logic interprets the inherited 1 as truthy, bypasses the isURLSameOrigin check, and appends the X-XSRF-TOKEN to the outgoing request headers. The attacker monitors the receiving server logs and captures the leaked credential.
The direct security impact of this vulnerability is the compromise of anti-CSRF tokens. These tokens are generated by backend services to cryptographically bind state-changing requests to the authenticated user's session. When these tokens are leaked to an external party, the primary defense against Cross-Site Request Forgery is neutralized.
With the extracted XSRF token, an attacker constructs malicious cross-origin requests that the backend service authenticates and authorizes. This enables the attacker to perform state-changing actions on behalf of the victim, such as modifying account details, initiating unauthorized transactions, or elevating privileges within the context of the vulnerable application.
The vulnerability scores a CVSS of 5.4, reflecting a Medium severity. The score accounts for the network attack vector and low complexity, but is constrained by the requirement for user interaction and the specific precondition of an existing Prototype Pollution flaw. The EPSS score remains low at 0.00035, indicating limited active exploitation in the wild.
The definitive remediation for CVE-2026-42042 is updating the Axios library to a patched release. Development teams must upgrade their dependencies to version 1.15.1 or version 0.31.1, depending on the major version branch currently in use. This update replaces the vulnerable loose truthiness checks with strict boolean evaluation.
In environments where immediate patching is not feasible, defensive programming practices mitigate the underlying prototype pollution vector. Implementing Object.freeze(Object.prototype) prevents unauthorized modification of the global prototype chain, neutralizing the gadget required for this Axios vulnerability.
Applications parsing untrusted user input should transition to using Map objects or Object.create(null) for dictionary storage. These structures do not inherit from Object.prototype, rendering them immune to prototype pollution injection techniques. Security teams verify dependency trees using software composition analysis tools to identify indirect inclusions of vulnerable Axios versions.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
axios axios | >= 1.0.0, < 1.15.1 | 1.15.1 |
axios axios | < 0.31.1 | 0.31.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-697 |
| Attack Vector | Network |
| CVSS v3.1 | 5.4 |
| EPSS Score | 0.00035 |
| Impact | XSRF Token Leakage |
| Exploit Status | poc |
The software evaluates a condition using an incorrect or unsafe comparison mechanism, relying on loose truthiness rather than strict boolean equality.
The @jhb.software/payload-cloudinary-plugin exposes an endpoint that performs unvalidated cryptographic signing of Cloudinary API parameters, allowing authenticated users with minimal privileges to forge valid signatures for arbitrary actions. This flaw allows attackers to overwrite remote storage assets, execute unauthorized file uploads, alter asset visibility parameters, trigger SSRF webhooks, and perform directory traversal within Cloudinary repositories.
A Server-Side Request Forgery (SSRF) and Bearer Token Exfiltration vulnerability exists in the @merill/lokka (Lokka) Model Context Protocol (MCP) server prior to version 2.1.2. The server constructed Azure Resource Manager request URLs by concatenating user-controlled path parameters directly into destination request strings. By injecting authority-redefinition characters, an attacker can manipulate URL parsing to execute a host-escape attack, forcing the server to send high-privilege Azure Resource Manager (ARM) Bearer tokens to an external attacker-controlled host. This allows complete administrative access to the associated Azure subscriptions.
A directory traversal and symlink following vulnerability exists in Pydantic Settings when using the NestedSecretsSettingsSource with nested subdirectory lookups enabled. An attacker capable of writing to the secrets directory can bypass size limitations, read arbitrary host files, or cause a denial-of-service condition via cyclic symlinks.
A Server-Side Request Forgery (SSRF) vulnerability exists in SurrealDB's Identity & Access Management (IAM) module prior to version 3.1.5. When configuring JSON Web Key Set (JWKS) URLs for token verification, the remote fetcher follows HTTP redirects by default without validating redirect targets against configured network capabilities. This allows high-privileged users to bypass network access limits and perform blind port scanning of internal network resources.
A local file disclosure vulnerability exists in SurrealDB's full-text search capabilities, allowing authenticated users with database EDITOR or OWNER roles to read arbitrary files from the host system filesystem. This occurs by abusing the mapper() filter inside a DEFINE ANALYZER statement to point to system files.
SurrealDB versions 3.0.0 through 3.1.4 contain an information exposure vulnerability (CWE-203) where the query planner optimizes sorted queries using indexes on fields with field-level SELECT restrictions. Because the query planner performs index-based sorting before enforcing permission-based redaction, unauthorized users can observe the physical order of returned rows to deduce the relative values of protected fields.