Repository navigation
Conversation
Automated security fix generated by OrbisAI Security
|
thanks, can you add tests to prevent regressions? |
Covers the traverse `keys` option sanitization (__proto__, constructor, prototype) and confirms legitimate custom keys still merge and work. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Done. Pls review. |
The keys option was merged with Object.assign onto an object created from the defaults. Assignment is what made __proto__ special: it walks the prototype chain and reaches the accessor on Object.prototype, which replaced the merged object's own prototype and lost every default key, so traverse then threw "Unknown node type". Spreading defines each key instead of assigning it, so no name is special and the denylist is not needed. The prototype chain goes too, because nothing read the keys that way; both call sites are a plain lookup. Object.prototype was never written to on any of these paths, so this is a readability and robustness change rather than a security one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the report. I've pushed a commit on top rather than closing this, because the line you flagged was genuinely worth changing — just not for the reason the scanner gave. On the finding itself: this.__keys = Object.assign(Object.create(this.__keys), visitor.keys)the assignment target is Measured against the unpatched code, all three vectors leave
Two of the three regression tests in this PR pass against the unpatched source, so they'd stay green even if the merge broke completely. The What was actually worth fixing: assignment is the only reason this.__keys = visitor.keys ? { ...VisitorKeys, ...visitor.keys } : VisitorKeysThis also drops the denylist, which had two problems: it silently discards a legitimate key named I replaced the three pollution tests with five that cover behaviour: custom keys are visited, defaults still apply to unmentioned types, overrides win, Full suite passes, and your original tests also pass against this version. One request for the tooling: |
|
@anupamme thanks, I've reviewed and updated the code to be more aligned w/ the current behavior. Have a nice day! |
Summary
Harden input handling in
src/traverse/estraverse(flagged by multi_agent_ai).Vulnerability
V-001src/traverse/estraverse:358Description: The traverse module uses Object.assign(Object.create(this.__keys), visitor.keys) to merge visitor-provided keys with default VisitorKeys. If an attacker controls the visitor.keys object and supplies properties named 'proto', 'constructor', or 'prototype', they could pollute the prototype chain affecting all objects in the application.
Threat Model Context
This is a Node.js library - vulnerabilities affect downstream consumers who use this package.
Changes
src/traverse/estraverseBehavior Preservation
The change is scoped to 1 file on the vulnerable path.
This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.
Automated security fix by OrbisAI Security