Skip to content

test: pin draft prototype-inspection behavior restored by #1271#1

Closed
jonatankruszewski wants to merge 1 commit into
mainfrom
prototype-inspection-tests
Closed

test: pin draft prototype-inspection behavior restored by #1271#1
jonatankruszewski wants to merge 1 commit into
mainfrom
prototype-inspection-tests

Conversation

@jonatankruszewski

@jonatankruszewski jonatankruszewski commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Note

Self-review PR — diff preview before opening against immerjs:main.

Follow-up to immerjs#1271, as offered in immerjs#1269.

The revert restored draft behavior that ecosystem libraries depend on, but that behavior is currently untested — the produce-side tests from immerjs#1259 were removed along with the guard, and the remaining pollution tests all live at the applyPatches layer. This PR adds test-only coverage (no source changes) that pins the restored contract:

The tests assert observable behavior directly rather than wrapping attacks in try/catch, so a crash and a successful defense are distinguishable. Verified: they fail on 11.1.9–11.1.11 (constructor.prototype throws, constructor identity and in break, writes to an own key named prototype are dropped) and pass on main.

If a convincing case for hardening comes up later, these tests define what any future guard must preserve. The applyPatches-layer guards in patch.js are untouched.

Full suite: 3689 passed, 8 skipped (pre-existing).

Drafts must stay safe for ecosystem introspection idioms: lodash's
isPrototype (used by isEmpty/isEqual/isPlainObject) reads
value.constructor.prototype, and fast-deep-equal compares constructor
identity. The guard reverted in immerjs#1271 broke these (immerjs#1265, immerjs#1266, immerjs#1268)
while its tests still passed, because try/catch made a crash and a
successful block indistinguishable.

These tests assert observable behavior directly, so they fail on
11.1.9-11.1.11 (verified: constructor.prototype throws, constructor
identity and 'in' checks break, writes to own keys named prototype are
dropped) and pass on main. setPrototypeOf remains forbidden; the
applyPatches-layer pollution guards in patch.js are untouched.
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