Repository navigation
Conversation
…range Before @casl/ability 7.1.1, a plain object's own __caslSubjectType__ property chose its subject type, so JSON from outside the app could pose as any type. The browser guide and the package README now recommend 7.1.1 or later, and say how to stay safe on 6.7/7.0. The peer range stays ^6.7.0 || ^7.0.0. Refs #8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CU4qH6uMNWadmwVG9pypJk
…docs
@casl/ability 7.1.3 closes a second way for parsed JSON to name its own
subject type: an own `constructor` property ({"constructor":{"name":
"Invoice"}} was checked as an Invoice on 7.1.2). The browser guide, the
package README and the changelog now recommend 7.1.3 rather than 7.1.1.
The compatibility test and the browser package's dev dependency move from
7.0.1 to 7.1.3. From 7.1.1, subject() tags objects for the copy of
@casl/ability that ran it, and the symlinked casl-net resolved its own dev
copy, so every check threw "Untrusted subject type". The test now installs
casl-net as a copy (install-links), sharing one @casl/ability as an app
does. 24,000 decisions still match.
Refs #8, #10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CU4qH6uMNWadmwVG9pypJk
This branch has not been deployed
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.
Closes #8. Closes #10.
What and why
Upstream
@casl/abilityclosed two ways for a plain object parsed from JSON to name its own subject type:ability.can('read', JSON.parse(x))withcan('read', 'Invoice'){"__caslSubjectType__":"Invoice"}{"constructor":{"name":"Invoice"}}subject('WorkItem', parsed)blocks both on every version.As decided in #8, the peer range stays
^6.7.0 || ^7.0.0. Instead:docs/browser.mdandpackages/casl-net/README.mdrecommend 7.1.3 or later whenever the checked objects come from outside the app's code. They explain both forged-type paths and tell apps on 6.7/7.0 to always pass parsed objects throughsubject(). A second paragraph says to keep one copy of@casl/ability(see below).tests/casl-compat/.npmrcsetsinstall-links=true. From 7.1.1,subject()tags an object for the copy of@casl/abilitythat ran it. The symlinkedcasl-netresolvedpackages/casl-net's own dev copy, while the test'ssubject()came from the test's copy, so on 7.1.3 every check threw "Untrusted subject type". Installingcasl-netas a copy makes it share the test's@casl/ability, as it would in an app (npm lsshows it as deduped). CI's steps are unchanged.## Unreleasedsection with Documentation and Tests entries. Move or drop it if you prefer to write entries at release time.The .NET library isn't affected.
Ability.DetectSubjectTypenever reads a type name from an object's data, andSubjectInstanceis only created throughSubject.Of.Checks
Run locally in the same order as
ci.yml:dotnet build -c Release: 0 errors.dotnet test -c Release --no-build: 288 passed (net10.0).packages/casl-net:npm cisucceeded.tests/casl-compat:npm ci && npm testreports "24000 decisions matched across 150 rule sets". Before the.npmrcchange, the same command on 7.1.3 failed with "Untrusted subject type value "WorkItem"".Generated by Claude Code