This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(permissions): evaluateCondition reads a condition's field in three cases, not two - #8669
Merged
Merged
Conversation
`evaluateCondition` refused three field names by list and read every other
name with `hasOwnProperty`. That read collapses *inherited* into *absent*,
and on a negative operator absent ADMITS — so every prototype member outside
the list passed every record through the rule that existed to hide it.
Measured against `{ id: 1, tenant: 'acme' }`, `{ field: 'toString',
operator: 'neq' }` returned `true`, as did `valueOf`, `hasOwnProperty` and
`isPrototypeOf`, on both `neq` and `not_in`. The same read also widened for
records whose value is inherited: on `Object.create({ tenant: 'acme' })`,
`{ field: 'tenant', operator: 'neq', value: 'acme' }` returned `true`.
A longer list does not close this; the defect is the shape of the guard.
`readField` now answers in three cases — a listed name is refused, an own
member is read as before, and a non-own name is refused if it resolves on
the prototype chain and read as `undefined` if it resolves nowhere, so
ordinary "this record has no `status`" conditions keep the verdicts they
have always had.
Ported from `readField` in `@object-ui/core`'s `DataScopeManager`, which
adopted this shape at objectui#7751 with this evaluator as its reference —
and which recorded the gap as two `KNOWN GAP` conformance assertions that
this change flips.
Differential matrix over 3696 cases, replaying each through the previous
read and this one: 234 verdicts narrowed, zero widened, zero change across
the 924 genuinely-absent-field cases.
Ref: objectui#8044
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
os-justin
marked this pull request as ready for review
September 8, 2026 21:05
os-justin
enabled auto-merge
September 8, 2026 21:05
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #8044
A port of the shape objectui#7751 landed in
readField(packages/core/src/data-scope/DataScopeManager.ts) back to the evaluator that was #7751's reference — and which, it turned out, carried the defect it was being used as the standard for. Not a redesign: the reference shape was read first and followed.Root cause, one sentence
hasOwnPropertycollapses inherited into absent, and on a negative operator absent ADMITS.The pre-fix guard (verified by content on
4eb665bcf, the base of this branch —:129and:133, exactly where triage measured them) refused three field names by list and read every other name withhasOwnProperty. ⛔ Not fixed by lengthening the list: a list enumerates spellings, andObject.prototypehas more of them than any list will hold.The fix — three cases, and the third is the whole thing
readFieldinpackages/permissions/src/evaluator.tsnow answers:__proto__,constructor,prototype) → refused, the rule denies;toString;field in Object(record)) the read is refused; if it resolves nowhere the field is genuinely absent andundefinedis returned, so ordinary "this record has nostatus" rules keep the verdicts they have always had.The second half of case 3 is load-bearing. Refusing every non-own read would deny records this evaluator should admit — a worse defect on a permission boundary than the fail-open being closed. It is measured below, and it is what the ablation in leg C fails on.
⭐ The quantitative bar — both counts
Differential matrix, 3696 cases (14 field names × 4 record shapes × 11 operators × 6 values), each case replayed through the previous release's read and this one:
Measured twice, and the two agree:
git show 4eb665bcf:packages/permissions/src/evaluator.ts, imported alongside the shipped one in a throwaway test):total=3696 mismatches=0 narrowed=234 widened=0 absentTotal=924 absentChanged=0;evaluator.prototype-guard-8044.test.ts, which the run above confirms agrees with the real pre-fix module on every one of the 3696 cases (mismatches=0).The matrix is committed, so the counts stay asserted rather than recorded in a PR comment.
widened === 0most of all. So the case space is asserted by exact size first, and that guard is itself proven: emptyingFIELDS(leg D) turns 4 tests red, includingexpected [] to have a length of 14 but got +0— while⭐ widened ZEROstayed green over the empty list, which is precisely the hazard.Every narrowed verdict, characterised
A committed assertion walks all cases whose verdict moved and requires each one to be a read that is not own and does resolve on the chain. Nothing outside the prototype-name / inherited-value families moved.
Caricature — both directions, neither reads as success
Each leg: mutate → prove it landed on disk (marker count +
git hash-object≠ HEAD blob) → run → restore → provegit diff HEADempty and the hash back to the HEAD blob. Classified from vitest's JSON reporter, not the text one. No void legs.Leg C is the discriminating one: it leaves every "
toStringno longer admits" pin green. A patch strictly worse than the bug would have passed a pin set built only around the attack path.Sibling read-site sweep —
packages/permissionsevaluateConditionwas the only read site of this shape.grep -rn "hasOwnProperty" packages/permissions/→ 1 hit,evaluator.ts:133(the subject).grep -rn "record\[|row\[" packages/permissions/src→ 1 hit, the same line. Lit control on the identical command shape againstpackages/core/srcfired (optionRules.ts:86,listConditional.ts:447,DataScopeManager.ts:313, …), so the zero-elsewhere reading is a measurement and not a broken command.grep -rn "\[(condition\.field|filter\.field|field|key|name|f)\]" packages/permissions/src→ 2 hits: the subject, andMePermissionsProvider.tsx:309, which indexes a server-supplied permission map by an object/field key — a different subject (not a record, and its miss path falls through to the authentication-gated object-level default), so it is not part of this defect and is not touched here.⛔ No widening into a third package: the only source change outside
packages/permissionsis a doc comment inDataScopeManager.tsthat asserted, in the present tense, that the sibling still admits — now false.The
KNOWN GAPpins that this flipspackages/core/src/data-scope/__tests__/DataScopeManager.hardening.test.tsrecorded this card as assertions expecting the sibling to admit, so that fixing it would turn red and lead the implementer to where the standard is written:Done as instructed — the two blocks now assert that both evaluators refuse a prototype member name and an inherited value, and they have joined the conformance table. Neither evaluator was loosened to match the other. Operator spelling (
neq/not_inhere,ne/ninthere) is untouched and remains objectui#7750's question.Verification
pnpm exec vitest run packages/permissions/ packages/core/— 141 files, 2911 tests, 0 failed (JSON reporter).pnpm --filter @object-ui/permissions... --filter @object-ui/core... build→ exit 0, dist completeness verified — run before type-check, so the type-check below is a result and not a precondition report.pnpm --filter @object-ui/permissions --filter @object-ui/core type-check(tsc --noEmitandtsc -p tsconfig.test.json) →Done, no diagnostics.tsc -p packages/permissions/tsconfig.test.json --listFilesconfirms the new pin file is in the checked set — it is not silently excluded.pnpm exec eslinton the four touched files → 0 errors (8 pre-existingno-explicit-anywarnings onDataScopeManagerlines this PR does not add).Note for the release editor
.changeset/core-datascope-field-and-comparison-guards-7751.md(still unreleased) says the sibling "still returnstruefor{ field: 'toString', operator: 'neq' }". If both changesets ship in one release, that sentence is superseded by this one. Left untouched here rather than rewritten — it is another card's release note, and #7751's reasoning for going further than the sibling is still the correct history.Exploitation evidence
None found, and the search is named rather than asserted. A repo-wide sweep for a condition literal whose
fieldis a prototype member name — overpackages,apps,examples,contentande2e, in.ts/.tsx/.json/.md/.mdx— returns only the prose in the two files this PR touches that describes the defect; no fixture, example app, metadata file or docs page configures one. The lit control on the identical command shape (field: 'status') fired. Nothing was found indicating a deployment relies on a prototype-named condition either. The escalation clause (p1 → p0 on evidence of exploitation or of such a deployment) was therefore not triggered — reported here rather than absorbed silently.🤖 Generated with Claude Code
https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
Generated by Claude Code