Oct 1, 2026·6 min read·22 visits
An API contract collision in Fastify's validation runner allows attackers to bypass JSON Schema validation by embedding nested, unvalidated payloads inside a root-level 'value' key, which is then promoted to the root request body.
An API contract mismatch in the Fastify web framework allows remote attackers to bypass schema validation when asynchronous schema validators are used. When a route uses async validation, the validator resolves with the raw request body. If the body contains a root-level key named 'value', the validation runner interprets this as a synchronous wrapper envelope, extracting and promoting the unvalidated nested content to the root level of request.body.
The Fastify web framework relies on an internal validation runner to parse and validate incoming client requests. This component compiles route-specific schemas to sanitize input before the payload reaches downstream application controllers. Under default conditions, this architecture prevents malicious or malformed data from causing type confusion, parameter injection, or logic flaws within handlers.
To accommodate a wide ecosystem of custom schema compilers, Fastify supports both synchronous and asynchronous validation interfaces. Synchronous compilers, such as Joi, return structured validation results inside an envelope object. In contrast, asynchronous compilers, such as Ajv when compiled with the $async: true directive, resolve directly with the successfully validated dataset rather than an envelope.
This architectural difference creates a critical attack surface within the request runner. When processing successful asynchronous resolutions, the framework's internal runner fails to isolate the raw validated payload from legacy synchronous envelope-parsing rules. Consequently, attackers can transmit structured payloads that deliberately collide with internal validation properties, resulting in complete validation bypass.
The core of the vulnerability lies in the legacy unwrapping function named answer() in Fastify's validation execution path. This function is designed to handle custom synchronous validators that return a metadata wrapper structured as { value, error }. If answer() detects an error key on its argument, it signals a validation failure, whereas if it detects a value key, it extracts the nested value to replace the current request.body object.
When a route uses an asynchronous validation compiler, the validator returns a Promise that resolves directly with the raw validated payload upon success. The validation runner handles this resolved payload by passing it straight into the legacy answer() wrapper function. This creates an unhandled type collision because the user-controlled, successfully validated request payload is now evaluated as if it were a synchronous compiler envelope.
If an attacker structures an input payload to contain a root-level property named value, the asynchronous schema validator verifies that the outer object meets the schema criteria and passes the object to the resolver. The runner then processes this validated object through answer(). Because the object contains a root-level value property, answer() extracts its nested contents and assigns them directly to request.body, bypassing all structural checks on the nested fields.
The flaw is located in lib/validation.js where asynchronous validation promises are resolved and returned to the request lifecycle. The vulnerable path executes answer(res) on the resolved data, assuming it represents a validation wrapper.
Below is the code comparison between the vulnerable implementation and the patch:
// === VULNERABLE CODE ===
if (ret && typeof ret.then === 'function') {
return ret
.then((res) => { return answer(res) }) // Vulnerable wrapper processing
.catch(err => { return err })
}
// === PATCHED CODE ===
if (ret && typeof ret.then === 'function') {
// An async validator resolves with the validated data itself,
// not a { value, error } result envelope. Its properties must
// not be unwrapped. Treat the async result as pass/fail only.
return ret
.then((res) => { return res === false ? validatorFunction.errors : false })
.catch(err => { return err })
}In the patched version, the call to answer() is eliminated from the promise resolution chain. The runner now evaluates the resolved promise solely as a indicator of validation success or failure. If res is strictly false, validation is treated as failed and errors are returned. Otherwise, it returns false to indicate that no validation errors occurred, completely bypassing the legacy unwrapping logic.
To exploit this vulnerability, an attacker must identify a route that utilizes an asynchronous JSON Schema compiler, such as Ajv with asynchronous schemas. The endpoint must also permit additional properties on the input schema, or specifically permit a root-level parameter named value.
The exploit payload is structured with a root-level value property containing arbitrary, unvalidated keys. When submitted, the validator verifies only the top-level keys. Upon validation success, Fastify extracts the contents of value and promotes them to the root of request.body. This mechanism completely evades schema enforcement, allowing the injection of forbidden configuration properties, administrative roles, or restricted identifiers.
The impact of this vulnerability is classified as high severity with a CVSS v3.1 score of 8.1. By systematically bypassing JSON schema validation, remote attackers can achieve parameter injection, unauthorized modification of application state, and type confusion in backend databases or business logic.
In typical production applications, schema validation serves as the primary barrier against privilege escalation. For example, if a profile update route forbids the role parameter via schema constraints, an attacker can bypass this restriction by passing { "username": "user", "value": { "role": "admin" } }. This allows the attacker to gain administrative capabilities, modify access controls, or corrupt data integrity.
Furthermore, because the newly substituted request body never undergoes validation, database insertion operations may receive unexpected data structures. This can trigger unexpected application crashes, unhandled database exceptions, or secondary SQL injection and NoSQL injection vulnerabilities in downstream logic.
The primary remediation for this vulnerability is to upgrade Fastify to version 5.12.2 or later, which completely decouples the asynchronous execution path from the legacy synchronous unwrapping logic.
If immediate upgrading is not feasible, developers should enforce additionalProperties: false on all routes employing asynchronous validation. This configuration forces the schema validator to reject any payloads containing the unexpected root-level value property before the validation runner processes the result.
Alternatively, a global preValidation hook can be integrated to detect and drop payloads containing root-level value or error keys on affected routes. This ensures that potentially malicious collision payloads are discarded at the beginning of the request lifecycle.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
fastify fastify | < 5.12.2 | 5.12.2 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-20 |
| Attack Vector | Network |
| CVSS Score | 8.1 (High) |
| Exploit Status | poc |
| KEV Status | Not Listed |
| Impact | Validation Bypass / Parameter Injection |
The product does not validate or incorrectly validates input that can affect the control flow or data flow of a program.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.
CVE-2026-128077 (GHSA-r99w-jh2x-3mg9) is an authorization bypass and interpretation conflict vulnerability affecting Nuxt and its underlying @nuxt/nitro-server package in versions 4.6.0 through 4.6.3. When an incoming HTTP request path begins with a double forward slash (e.g., //x/admin), the WHATWG URL parser within the Nuxt server-side page renderer interprets the initial segment as a network host/authority and resolves the remaining path (/admin) against the application's page router. Because Nitro server middleware, route-scoped serverHandlers, and Nitro routeRules evaluate the unparsed request path (//x/admin), path-based access controls, redirects, and security header policies configured for /admin fail to match and are bypassed.
Prior to version 2.10.2, the sqlite3-ruby gem explicitly cast 64-bit Ruby string lengths (long) to 32-bit signed integers (int) when invoking the underlying SQLite C API. On 64-bit platforms, providing a string of 4 GiB (2^32 bytes) or larger causes integer truncation, instructing SQLite to process only a prefix of the string. This flaw affects SQL query preparation, bound parameter values, and return values from custom Ruby-defined SQL functions and aggregates, allowing trailing SQL clauses such as WHERE restrictions to be silently dropped under specific conditions.
CVE-2026-128068 (GHSA-cpgf-5mjf-73p7) is a Regular Expression Denial of Service (ReDoS) vulnerability in the rails-html-sanitizer Ruby gem affecting versions 1.0.3 through 1.7.1. The flaw resides in the Rails::HTML::PermitScrubber#scrub_attribute method, which uses the multiline regular expression /^\s*[^#\s].*/m to enforce local-only URI fragment references on SVG elements. On Ruby runtimes prior to version 3.2 (CRuby <= 3.1 and JRuby), evaluating an attribute value composed of repeated newline and whitespace characters without a hash character triggers quadratic backtracking O(n^2). Applications are only vulnerable if their sanitization allowlist is explicitly configured to permit SVG reference elements such as <use> alongside href or xlink:href attributes.