fix: apply ownPropertyOnly uniformly in readJSProperty

Proto keys block inherited access only; ownPropertyOnly is checked once before return for all keys. Own __proto__/constructor/prototype properties are readable—sanitize untrusted scope input.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-07-23 22:59:37 +08:00
co-authored by Cursor
parent d32da49925
commit 85321c6d64
5 changed files with 24 additions and 14 deletions
+3 -2
View File
@@ -52,8 +52,9 @@ The `memoryLimit` option was removed in v11; enforce memory limits at the host o
With [`ownPropertyOnly`][ownPropertyOnly] `true` (default), plain scope objects only expose **own** properties (no inherited / `Object.prototype` keys).
- **`true`:** proto keys (`__proto__`, `constructor`, `prototype`) blocked entirely.
- **`false`:** own properties with those names allowed; inherited proto-key access still blocked.
- **Proto keys** (`__proto__`, `constructor`, `prototype`): inherited access is always blocked.
- **`true`:** other inherited properties are also hidden.
- **`false`:** other inherited properties are allowed; own properties named `__proto__`, `constructor`, or `prototype` remain readable. Sanitize untrusted scope data (e.g. with [bourne](https://www.npmjs.com/package/bourne)) if those key names may appear.
Not restricted: [`Drop`][drop] values, iteration via `Symbol.iterator`, `.size`/`.first`/`.last`, filters, and custom tags.