Skip to content

Resolve Proxy-backed JS file variable addresses#396

Merged
GrahamCampbell merged 1 commit into
3.xfrom
proxy-file-variables-3x
Jun 12, 2026
Merged

Resolve Proxy-backed JS file variable addresses#396
GrahamCampbell merged 1 commit into
3.xfrom
proxy-file-variables-3x

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

Since the prototype pollution hardening in #165, the file variable source has gated every address segment on Object.prototype.hasOwnProperty, which does not consult a Proxy's has or get traps. Variables that read virtual properties from Proxy-backed objects returned by JS files, such as ${file(./vars.js):cfg.settings} where cfg is a Proxy, therefore began resolving to null. This change restores those lookups by deferring to the proxy's own traps: when a value is a Proxy and does not claim the segment as an own property, the segment is now resolved through ordinary property access, which invokes the get trap. Proxies can only originate from JS files, which are already executed as trusted code, so consulting their traps introduces no new attack surface, and the own-property check itself already invokes the proxy's getOwnPropertyDescriptor trap today. The behaviour for every non-Proxy value is unchanged, including the guarantees that inherited properties are not traversable and that own __proto__ data properties parsed from JSON files still resolve. To keep the hardening posture uniform, the __proto__, prototype and constructor keys remain blocked on proxies unless they are claimed as own properties. The variables guide now documents these semantics.

Fixes #384.

@GrahamCampbell
GrahamCampbell merged commit 04bad35 into 3.x Jun 12, 2026
8 checks passed
@GrahamCampbell
GrahamCampbell deleted the proxy-file-variables-3x branch June 12, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant