fix(data-inspector): block prototype-chain writes - #324
Merged
Conversation
Restrict Data Inspector's write engine to own-property traversal and mutation so a write path can no longer reach or replace a shared prototype: - navigate() now returns undefined for a plain-object key that isn't an own property, instead of following the prototype chain. - Plain-object set/add/rename destinations reject __proto__, prototype, and constructor. - add and rename create the destination as an own data property via Object.defineProperty, so an inherited setter can never fire. - set now requires Object.hasOwn before reading/assigning, closing the same hole for existing-but-inherited property names. Map key semantics are untouched — a Map may still use these strings as ordinary data keys.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
antfu
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements plan
005-block-data-inspector-prototype-writes.md. Data Inspector's write engine re-descended object paths through inherited properties and assigned caller-selected keys directly, so a write request could reach or replace a shared prototype. This closes that off while preserving Map key semantics.navigate()now returnsundefinedfor a plain-object key that isn't an own property, instead of following the prototype chain (Map.getbehavior is unchanged).set/add/renamedestinations reject__proto__,prototype, andconstructor.addandrenamecreate the destination as an own data property viaObject.defineProperty, so an inherited setter can never fire.setnow requiresObject.hasOwnbefore reading/assigning an existing property, closing the same hole for property names that exist only on the prototype chain.Scope
plugins/data-inspector/src/engine/normalize.tsplugins/data-inspector/src/engine/write.tsplugins/data-inspector/test/write.test.ts(new regression coverage: rejected prototype-sensitive keys on set/add/rename, inherited-property paths reportingPathNotFound, an inherited-setter fixture provingadd/renamenever invoke it, and a positive Map test)plans/README.md(marks plan 005 done)Verification
pnpm exec vitest run plugins/data-inspector/test/write.test.ts plugins/data-inspector/test/engine.test.ts— 53 passedpnpm --filter @devframes/plugin-data-inspector typecheck— exit 0pnpm --filter @devframes/plugin-data-inspector build/test— passpnpm lint— passpnpm knip/pnpm test/pnpm typecheck/pnpm buildhit pre-existing, unrelated environment issues in this sandbox (a permission-brokenplugins/git/assets-pkg/distartifact, and several packages whosedist/isn't built) — confirmed identical onHEAD~1viagit stash, so unaffected by this change. A full repo-widepnpm exec vitest runshows the same unrelated pre-existing failures (dist-artifact-dependentexports.test.ts/dev-serversuites for other plugins); the data-inspector suite is unaffected.Created with the help of an agent (opencode).