//nefariousplan

CVE-2026-46510: form-data-objectizer Checked Map Membership With `in`. The `in` Operator Walks The Prototype Chain.

vendor

patterns

cve

proof of concept

form-data-objectizer is an npm package that converts a FormData instance into a plain JavaScript object. It supports Rails-style bracket notation: a field named user[name] becomes {user: {name: "..."}}. The parser walks the path one segment at a time. Before it descends into the first segment, it asks whether the result object already has that segment. In version 1.0.0, line 45 of index.cjs asks the question with the JavaScript in operator.

The in operator walks the prototype chain. "__proto__" in {} returns true on a fresh plain object with no prior writes. Every form field whose first segment is __proto__ is a write into Object.prototype. That is CVE-2026-46510.

The check was a lookup, and the lookup walked the chain

The vulnerable function is treatInitial(key, value, result) in index.cjs. It runs once per FormData entry. The first segment of the form key drives a three-way branch:

treatInitial(key, value, result) {
  const firstMatch = key.match(/^(.+?)(\[([\s\S]+$))/)

  if (firstMatch) {
    const inputName = firstMatch[1]
    const rest = firstMatch[2]

    let newResult

    if (inputName in result) {
      newResult = result[inputName]
    } else if (rest == "[]") {
      newResult = []
      result[inputName] = newResult
    } else {
      newResult = {}
      result[inputName] = newResult
    }

    this.treatSecond(value, rest, newResult)
  } else {
    result[key] = value
  }
}

For a field named user[name], inputName is "user" and rest is "[name]". The branch picks: is user already on result? If not, create a new {} for it, recurse into it, assign result["user"]["name"] = value. Standard nested-form handling.

The if (inputName in result) branch is the deduplication path. Two form fields named user[name] and user[email] should produce {user: {name: "...", email: "..."}}, not two separate user objects. The first field creates result["user"] = {} and recurses into it. The second field finds "user" already on result, reuses the existing {}, and recurses into the same target. The in operator is the gate that decides which of those two branches runs.

The JavaScript in operator does not check own properties. It walks the prototype chain. Every plain object in V8 inherits from Object.prototype, which carries twelve own properties:

constructor          isPrototypeOf       toLocaleString
hasOwnProperty       propertyIsEnumerable toString
valueOf              __proto__           __defineGetter__
__defineSetter__     __lookupGetter__    __lookupSetter__

in returns true for each of them, against any plain object, on the first call after construction.

For inputName = "__proto__":

  • "__proto__" in result returns true because Object.prototype declares __proto__ as an accessor.
  • newResult = result["__proto__"]. On a plain object, that accessor returns the object's actual prototype, which is Object.prototype itself.
  • this.treatSecond(value, "[polluted]", Object.prototype) runs against the global prototype.

The check that was supposed to detect duplicate top-level keys handed the recursion a reference to Object.prototype.

The recursion wrote it

treatSecond pulls the next segment from rest and decides whether to assign or descend:

treatSecond(value, rest, result) {
  const secondMatch = rest.match(/^\[(.*?)\]([\s\S]*)$/)
  const key = secondMatch[1]
  const newRest = secondMatch[2]

  let newResult

  if (rest == "[]") {
    result.push(value)
  } else if (newRest == "") {
    result[key] = value
  } else {
    if (typeof result == "object" && key in result) {
      newResult = result[key]
    } else if (newRest == "[]") {
      newResult = []
      result[key] = newResult
    } else {
      newResult = {}
      result[key] = newResult
    }

    this.treatSecond(value, newRest, newResult)
  }
}

With result = Object.prototype, key = "polluted", newRest = "":

result[key] = value
// equivalent to
Object.prototype.polluted = value

The library performs the write the form field named. Running the unpatched library on the package's own test harness:

const F = require("./index.cjs");
const fd = { entries: () => [["__proto__[polluted]", "pwned"]] };
F.toObject(fd);
console.log({}.polluted, [].polluted);
// pwned pwned

Every plain object in the process inherits polluted from Object.prototype for the rest of the process's lifetime. Every array, too: arrays inherit from Array.prototype, which inherits from Object.prototype. Every Map, Set, Date, and Error instance. The pollution is process-wide and survives until the process exits.

One HTTP form field. The library never wrote __proto__; the language wrote it for them.

The diff picks both readings of the bug

The patch for CVE-2026-46510 landed in commit 7c54b99 on 9 May 2026, merged from a fork by reporter Mohamed Bassia. Two changes, one commit, both targeting the same bug:

-      if (inputName in result) {
+      if (hasOwn(result, inputName)) {
         newResult = result[inputName]
+      assertSafeKeySegment(inputName)
+
       let newResult

Either change alone closes the path.

Swap in for Object.prototype.hasOwnProperty.call, and hasOwn(result, "__proto__") returns false on a fresh object, because __proto__ is inherited, not own. The branch falls through to result[inputName] = {}, which on a plain object assigns through the __proto__ setter and replaces the object's actual prototype with a fresh empty object. The recursion writes into the empty object, not into Object.prototype. Pollution closed.

Add the explicit blocklist, and the function throws on __proto__, constructor, and prototype before the lookup runs. Pollution closed.

The maintainer chose both. The two changes encode two different theses about what the original code got wrong. The blocklist treats __proto__/constructor/prototype as a closed enumeration of dangerous names. The hasOwnProperty swap treats in as the wrong operator. The first reads CVE-2026-46510 as "these three names are special." The second reads it as "this membership check was the wrong tool." They are not the same patch. Shipping both is shipping both readings.

The commit message says "Fix prototype pollution in form keys." The diff fixes that, and one other thing the commit message does not mention.

This is Object Literal As Map

The result container is {}. The keys are attacker-controlled. The membership check uses in. That shape has a name on this blog: Object Literal As Map. The canonical exhibit is multiparty (CVE-2026-8161), where a 2013 line of code initialized var fields = {} and read fields[name] with name coming from a multipart form field. Each of the twelve Object.prototype keys returned a non-undefined inherited value, the || short-circuit picked the inherited value over the new-array fallback, .push() ran on a non-array (the toString function), and the process exited.

Multiparty's read leaked the prototype chain into a crash. form-data-objectizer's read leaks the prototype chain into a write. The mechanisms diverge after the lookup. The root cause is identical: a JavaScript map built on {} whose membership is queried against attacker input without hasOwnProperty. Both libraries fixed the leak with the same swap. Both libraries' result containers are still {} in their patched releases. Object.create(null) and Map continue to exist, and they continue to be the constructions that would make this bug class structurally impossible. The npm ecosystem continues to reach for {}.

The downstream half of this attack is Prototype Pollution Trust Bypass. CVE-2026-34621 is what happens when a privilege gate reads properties off objects whose prototypes an attacker has poisoned. form-data-objectizer is what produces the poison. Any Node.js application that calls FormDataObjectizer.toObject(req.body) and runs a trust check anywhere downstream that reads someObject.admin or someObject.role against an object built from JSON or query parameters is one HTTP form POST from inheriting an attacker-chosen role. The form-data-objectizer half installs the value on Object.prototype; the Acrobat-style gate reads it as own-property-or-inherited and waves the call through.

The other test the CVE forced

The patch's spec file adds five new test cases. Four assert that the three dangerous segments throw. The fifth asserts something different:

it("parses inherited non-reserved names as own properties", () => {
  const formData = formDataWithEntries([["toString[value]", "yes"]])

  const object = FormDataObjectizer.toObject(formData)

  expect(object).toEqual({
    toString: {
      value: "yes"
    }
  })
})

This is not a security test. It is a correctness test. It asserts that a form field named toString[value] produces {toString: {value: "yes"}}.

Before the patch, the field did not produce that output. Running version 1.0.0 against the same input:

const F = require("./index.cjs");
const fd = { entries: () => [["toString[value]", "yes"]] };
console.log(F.toObject(fd));
// {}

The output is the empty object. "toString" in {} returns true because Object.prototype.toString is inherited. result["toString"] returns the toString function. treatSecond("yes", "[value]", function toString() {...}) assigns .value = "yes" to the function object and returns. The result object never receives a toString key. The form field is silently dropped on the floor.

The same is true for valueOf[x], hasOwnProperty[x], constructor[x], isPrototypeOf[x], and the seven other inherited names. Every one of them was a silently broken top-level form field name in version 1.0.0. index.cjs shipped its first commit on 15 February 2021. Every form between then and 9 May 2026 that carried a top-level field named after an Object.prototype property was parsed into the wrong object, with no error, no warning, and no test catching it. A consumer's models field passing through unaffected, their toString field vanishing without trace.

The maintainer wrote the test for that on 9 May 2026 because the prototype pollution disclosure forced the patch, and the patch's in → hasOwnProperty swap closed both the CVE and the correctness bug, and the new test verifies that the swap closed the correctness bug. The CVE produced the test for a five-year-old data-loss bug that had nothing to do with security.

What name in result meant

The author wrote if (inputName in result) to mean "is this field already part of the result so far?" That is not what JavaScript means by inputName in result. JavaScript means "does this name resolve to a non-undefined value through the prototype chain starting at result?" The two sentences read the same in English. They produce different programs.

The two sentences also pin different mitigations. The first mitigation, the one the author thought they were writing, is Object.prototype.hasOwnProperty.call(result, inputName) and was added to the diff. The second mitigation, the one the JavaScript language actually wanted, is to stop using {} as a map for attacker-controlled keys and reach for Object.create(null) or Map. The first mitigation closes the demonstrated chain. The second closes the bug class.

Every npm package that uses {} as a string-keyed map against caller-supplied keys is one careless in away from CVE-2026-46510. The patch swaps the operator. The container stays {}. The next consumer who reaches for in to mean "has this key been set on this map" inherits the same five-year shipping path.

PoC: advisories/GHSA-m2hg-wjq3-28wq

The line shipped on 15 February 2021 and was rewritten on 9 May 2026. Nothing about the in operator's semantics changed in between.