//nefariousplan

Validated Source, Not Destination

A handler ingests one artifact through a request carrying two attacker-populated string fields that share a design-model noun (the filename, the member path, the extension, the MIME type). Validation reads one field under the grammar appropriate to that field. The operation reads a different field under the grammar appropriate to that other field. Validating one filename does not validate the other.

A handler ingests one artifact through a request that carries two attacker-populated string fields naming properties of it. The two fields share a design-model noun: both are "the filename," both are "the extension," both are "the member's path," both are "where this upload goes." In the developer's mental model the two fields are two views of one artifact. On the wire the attacker populates each slot independently, and the two slots address different bytes.

The validation step reads one of the two fields. The extension allowlist, the MIME check, the path-traversal scrub, the getimagesizefromstring guard, the wp_basename call: each is correct for the field it reads. The operation then reads the other field. move_uploaded_file writes to the client-supplied destination basename rather than to the validated source filename. os.symlink points at the client-supplied linkname rather than at the validated member name. copy() reads the basename of a URL stored next to the server path the MIME check inspected.

Validating one filename does not validate the other. Two correct proofs about two different byte sequences do not compose into one proof about either.

Mechanism

The shape requires three parts.

The first part is a structured value carrying two attacker-populated string fields that both name some property of a single notional artifact. In Ninja Forms File Uploads (CVE-2026-0740), a multipart POST ships files-7=("doc.pdf", PHP_PAYLOAD, "application/pdf") for the artifact's source filename alongside doc_pdf=murrez.php for the destination basename the client wants the server to write under. In PraisonAI's _safe_extractall (CVE-2026-44340), a single tarfile.TarInfo carries member.name (the path the member writes to) and member.linkname (the path a SYMTYPE or LNKTYPE member redirects to). In CodeIgniter4's upload abstraction (CVE-2026-48062), the framework exposes the bytes-derived extension through finfo_file plus Mimes::guessExtensionFromType and the client-supplied extension through getClientName() and getClientExtension(), both reachable from the same UploadedFile object. In Bricksforge Pro Forms (CVE-2026-85097), each temporaryFileUploads[i].file ships file.file (the server path phase one wrote the staged artifact to) and file.url (the URL phase one declared the artifact is reachable at). In Magento's ImageContentInterface (CVE-2026-48356), one Model Context object carries base64_encoded_data, name, and type, with the validator and the file writer reaching for two different accessors on the same reference. Across every exhibit the two fields share a design-model noun (the filename, the member path, the extension, the MIME type) while addressing independent bytes.

The second part is validation that reads one of those fields correctly. Nothing in the validator is skipped, misnamed, or badly written. Ninja Forms runs an extension allowlist against the multipart part's filename attribute and clears it. PraisonAI inspects every form of member.name including absolute, ..-traversing, and resolved-escape forms. CodeIgniter4's ext_in rule, after a January 2021 refactor titled "Solidate mime type guessing," reads the bytes-derived extension through finfo_file on the correct theory that bytes are more trustworthy than client strings. Bricksforge's phase-one MIME check reads the server-side path at file.file. Magento's ImageContentValidator::isValid reads getType() against a four-item allowlist and reads the raw bytes against getimagesizefromstring. Each validator is correct for the field it reads.

The third part is a later operation that reads the other field, also correctly for its own field. Ninja Forms' move_uploaded_file writes the validated body to the client-supplied doc_pdf basename. PraisonAI's os.symlink(member.linkname, dest_dir / member.name) reads the first argument the validator never saw and the second argument the validator approved. CodeIgniter4's store() writes under getClientName(), the client-supplied name the ext_in refactor stopped reading. Bricksforge's copy() reads basename($attachment['guid']) for its destination name, where guid is file.url. Magento's ImageProcessor::getFileName reads getName() and returns it unchanged whenever pathinfo($name, PATHINFO_EXTENSION) is non-empty, which is the one condition the attacker always satisfies. The operation reads its own field with a grammar appropriate to that field. Two correctness proofs do not compose into one correctness proof, because the two fields are not the same bytes.

The pattern survives code review because the two fields look like two views of one thing. A developer reading $file->getClientName() next to a MIME check sees "the file's name" in both places and reads them as redundant. The validator's author names the function after the semantic property (the file's extension, the member's path) and the operation's author names the variable after the same semantic property. The design-model view that the two fields describe one artifact lives in both authors' heads and in the framework's docstrings. The handler reads them as two values the request body carries, because on the wire they are.

The failure repeats across stacks because the two-field shape is what file-transport protocols have always carried. HTTP multipart ships a part's filename attribute plus whatever path handling the server layers on top. Tar's header ships name and linkname for link-type members, and has done so since the format was defined; Python's tarfile module has carried this exact failure since 2007 (CVE-2007-4559), and PEP 706 added the data filter in 2023 to make the stdlib refuse it by default in Python 3.14. REST JSON documents ship whatever shape the server happens to accept, and server shapes that round-trip phase-one metadata through client control ship their state fields as request fields. Cloud storage requests pair the uploaded object's declared name against the key parameter. Every protocol that ships both a declared property of the artifact and a destination handle for it is a surface where the validator can read one slot and the writer can read the other.

The pattern distinguishes itself from near classes at the frame of how many bytes the two readers see. Gate Narrower Than Sink pairs two parsers describing the same bytes through different grammars (two regexes disagreeing on whitespace, a Python startswith against a SQL parser, a brace counter against a CSS compiler); here the two readers describe different bytes, each with the grammar appropriate to its own field. Sanitized The Secrets, Not The Sink pairs one function applying a sanitizer to some arguments of one sink and not others, sorted by the author's perception of which fields are sensitive; here the validator and the operation are often in different functions, and the two fields are not two arguments to one call but two accessors on one artifact. Predicate Stringifies The Object pairs a wide serialization against a narrow typed accessor on one object; here both accessors are narrow, they just address different fields of the same object. The signature move is "two named fields, two readers, one artifact."

Exhibits

CVE-2026-44340: PraisonAI's _safe_extractall Validates member.name. The Bypass Is in member.linkname.. PraisonAI's _safe_extractall is this pattern in stdlib form. tarfile.TarInfo is a structured record with two filename-shaped fields: name, the path the member writes to inside the archive's notional root, and linkname, the path a SYMTYPE or LNKTYPE member redirects to. The validator inspected every form of member.name (absolute, ..-traversing, resolved escape) and never inspected member.linkname. At extraction, os.symlink(member.linkname, dest_dir / member.name) reads the second argument the validator approved and the first argument the validator never saw, and the file the next archive member writes follows the symlink the validator never checked into wherever the linkname said. The pattern's two-identifier shape recurs here in its longest-standing form: Python's tarfile module has carried this exact failure since 2007 (CVE-2007-4559), PEP 706 added the data filter in 2023 to make the stdlib refuse it by default in Python 3.14, and PraisonAI's hand-rolled _safe_ variant is the majority-shape rewrite that read the same one identifier every variant reads and missed the same one identifier every variant misses.

CVE-2026-0740: Ninja Forms Shipped the Patch on February 10. The Bug Shipped Until March 19.. Ninja Forms File Uploads validated the source filename's extension on nf_fu_upload requests and accepted any value as the destination basename via a separate POST parameter the form's client-side code populated. The PoC sends files-7=("doc.pdf", PHP_PAYLOAD, "application/pdf") as the source (passes the extension allowlist) and doc_pdf=murrez.php as the destination basename (no check, no allowlist, no normalization in vulnerable releases). move_uploaded_file writes the source body to the destination path. The pattern's signature is two filenames in one request, with validation running on whichever one the developer designed the upload around, and the operation using whichever one the attacker actually supplied. The shape recurs in browser-based upload widgets, CMS file managers, and cloud storage gateways, anywhere a request carries both a source artifact and a destination handle and the validation effort is concentrated on the artifact rather than the handle.

Boundaries

Not every gate-sink disagreement is this pattern. Gate Narrower Than Sink pairs two parsers written to describe the same bytes through different grammars: two regexes with different whitespace rules, a Python startswith against a Trino SQL parser, a brace counter against a CSS compiler. The parsers may see identical bytes and simply recognize different sets. Here the two parsers describe different bytes, each under the grammar appropriate to its own field. If the mismatch is grammar against grammar on one byte sequence, the broader class applies. If the mismatch is field against field on one structured artifact, this one does.

Not every multi-field sanitization gap is this pattern. Sanitized The Secrets, Not The Sink covers one function assembling a call into one interpreter from several attacker-controlled fields, applying the escape or auth helper to some of those fields and omitting it on others on the same line. The helper is correct for the destination; the author sorted by perceived field sensitivity. Here the validator and the operation are often in different functions or phases of the request lifecycle, and the two fields are not two arguments to one call but two accessors on one artifact. The validator did not forget to run a helper on an adjacent field; it ran the correct check against a different field than the sink uses.

Not every structural-accessor bug is this pattern. Predicate Stringifies The Object covers a security predicate that reaches for an object's implicit serialization (__toString, getRequestURI, ctx.request.url) when the predicate's name implies it should read a specific typed accessor. The wide accessor concatenates fields the predicate did not intend to inspect. Here both the validator and the operation reach for narrow typed accessors; the bug is that they address different fields, each with its own correct grammar. If the gate reads a wide serialization and the fix is to swap to a narrow accessor on the same object, the stringification pattern applies. If the gate and the sink both read narrow accessors but of different fields, this one does.

Not every missing validation is this pattern. A handler that runs no check at all on the field the sink reads, and runs no related check on an adjacent field either, is a cruder failure than the within-artifact asymmetry. The pattern's signature is that the validator DOES cover a field of the artifact, correctly for that field. The developer's testimony that the artifact is dangerous is on the page; the error is that the covered field and the operated field are not the same slot of the request body. If no validation exists anywhere in the handler, read the simpler missing-check framing; this pattern names the case where a correct check exists one accessor away from the one the sink reads.

Defender playbook

Inventory every string field each upload, extraction, or file-write handler reads from the request. For each field that could be read as a filename, extension, MIME type, URL, path, key, or stream name, identify (a) which validation step examines it and (b) which operation uses it as input. The pattern's signature is a validation step that reads one such field and an operation that uses another from the same artifact. The directories you should grep hardest are the ones where the framework's own API exposes two accessors with semantically similar names on the same object: getClientName() next to finfo_file, member.name next to member.linkname, file.file next to file.url, getName() next to getType(). When two accessors describe the same conceptual property of one request value, the handler must pick one and derive the other from it. Any split where validation reads accessor A and operation reads accessor B is a candidate exhibit.

Co-locate validation and operation around a single derivation. The patch shape that closes the class derives the sink's input from the validator's output rather than reading an independent field. For file uploads, generate the destination basename server-side from the validator-approved bytes or from a random UUID, and extract the extension from the MIME string the validator cleared rather than from a client-supplied name. For archive extractors, derive the write path from the member's canonical name after the traversal check, and refuse to take the link target as authoritative; Python's tarfile.data_filter, introduced by PEP 706 and default in 3.14, is the stdlib's reference answer. For REST file handlers that round-trip phase-one metadata through client control, treat every field the client can repopulate as untrusted on re-entry, and rematerialize server state from a server-owned store keyed by an opaque handle. The validator should write the authoritative name; the operation should read it.

Build regression tests that vary the two fields independently. For file uploads, send a valid-shape body with a malicious destination basename, a malicious source filename with a benign destination, and each permutation of extensions crossed between the two slots. For archive extractors, construct tar members where name passes the traversal check but linkname does not, and the symmetric case. For REST JSON file handlers, swap the extension in each filename-shaped sibling while holding the MIME field fixed, then the inverse. For MIME-driven image writers, cross every allowed MIME value against every disallowed filename extension. Each failing test names which field the handler actually operated on. Each passing test after the fix is one more case where the validator's reader and the sink's reader agree on which bytes are authoritative. The test matrix size is the product of (number of filename-shaped fields) and (number of forbidden values); if that product is small, the invariant is small enough to enforce.

Watch refactors that change which representation a security check reads. The CodeIgniter4 exhibit is instructive: the January 2021 "Solidate mime type guessing" refactor moved the ext_in rule from reading getClientExtension() to reading the finfo-derived MIME-to-extension map. The change was correct in isolation (bytes are more trustworthy than client strings) and broke the invariant the validator and the writer previously shared: both read the client name. The resulting rule passed shell.php whose body began with GIF87a for five years. When a refactor swaps which field a security check reads, confirm every downstream consumer reads the same field, or rewrite the consumers to derive their input from the validator's output. The refactor that pushes a check toward more trustworthy bytes without pulling the sink with it is the shape most likely to ship this class.

Kinship

Gate Narrower Than Sink. Broader sibling at the gate-reads-less-than-sink-acts-on frame. Gate Narrower Than Sink pairs two parsers written to describe the same bytes through grammars that do not agree: two regexes with different whitespace classes, a Python startswith against a Trino SQL parser, a brace counter against a CSS compiler. Validated Source, Not Destination is the specific case where the two parsers describe different bytes, each with the grammar appropriate to its own field, on one structured artifact. When the exhibit's two matchers see identical bytes and differ only on the grammar they apply, the broader class is a better fit; when they see different fields of the same request value and differ on which accessor the handler chose, this one is.

Sanitized The Secrets, Not The Sink. Cousin at the "author protected the wrong thing" frame. Sanitized The Secrets, Not The Sink names the within-function asymmetry: one function assembles a call into one interpreter from several attacker-controlled fields, applies the right escape helper to some of them, and omits it on others on the same line because the author sorted by perceived field sensitivity. Validated Source, Not Destination names the across-accessor asymmetry: the validator and the operation are often in different functions or phases, and the two fields are not two arguments to one call but two accessors on one artifact. The two patterns can co-occur (Gravity Forms's set_uploaded_files basenames two filename fields and esc_url_raws a third filesystem-bound field; the three-filename shape is a Sanitized The Secrets exhibit because the three paths all flow to the same unlink, where the Ninja Forms case has the source filename going to validation and the destination basename going to the writer through different call paths). Read the number of accessors on one artifact against the number of arguments to one sink to pick between them.

Predicate Stringifies The Object. Cousin at the structural-accessor frame. Both patterns live on structured objects with typed field accessors. Predicate Stringifies the Object names the case where one reader reaches for the object's wide serialization (__toString, getRequestURI, ctx.request.url) when the predicate's name implies it should read a specific typed accessor; the bypass writes the gate's allow-string into any of the other fields the serialization concatenates. Validated Source, Not Destination names the case where both readers reach for narrow typed accessors; the bypass is that the validator's accessor and the sink's accessor address different fields of the same artifact. Both patterns describe a reader trusting a label (the function's name in Predicate Stringifies, the field's conceptual noun in this pattern) that the framework's typed accessors did not enforce. The fix-shape also differs: the stringification pattern swaps a wide accessor for a narrow one, this pattern aligns two narrow accessors.

Internal Only By Convention. Cousin at the design-contract frame. Internal Only By Convention names a field the framework documents as internal-IPC-only and the runtime reads from every inbound request anyway. Validated Source, Not Destination names a pair of fields the framework documents as two views of one artifact and the handler reads as two independently attacker-controlled slots on the wire. Both patterns describe a documentation contract the runtime does not enforce. In Internal Only By Convention the contract is "this field only arrives from trusted callers"; in Validated Source, Not Destination the contract is "these two fields describe the same thing, so validating one is validating both." The design model lives in the author's head and in the framework's docstrings. The handler sees whatever the request body carries.

The design model saw one artifact. The handler saw two filenames. The attacker chose which bytes went in each.