npm / @casl/ability
@casl/ability
What changed in @casl/ability 5 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
27 breaking5 security15 new APIs and options4 performance3 behavior and defaults16 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@casl/ability 719 changes
Breaking changes 9
Manually setting __caslSubjectType__ now throws an error during authorization; use the subject() helper to assign subject types.
Ability replaces PureAbility and no longer has default options; use createMongoAbility and MongoAbility to get the previous Ability behavior.
An empty conditions object now matches all.
The exported getDefaultErrorMessage function was removed.
possibleRulesFor now returns readonly Rule[], so callers can no longer treat its result as a mutable array.
PureAbility was renamed to Ability.
rulesFor now returns readonly Rule[], so callers can no longer treat its result as a mutable array.
rulesToCondition replaces rulesToQuery.
rulesToQuery has been replaced by rulesToCondition.
Security 1
Prevents rulesToFields from setting properties on prototypes and non-objects.
New APIs and options 1
Adds support for custom subject type detection types.
Behavior and default changes 1
Conditions that semantically match everything are treated the same as rules without conditions.
Fixes and other changes 7
Built-in detectSubjectType no longer reads an object's own constructor property; it reads constructor only from the prototype chain.
TaggedSubject now infers the subject type without widening it.
Instance inference now supports classes with abstract, private, or protected constructors.
Adds bugs metadata to all packages, giving developers a package-level issue-tracker reference.
Adds defensive protection against undefined returned from the rule conditions matcher.
Prevents the rules index cache from being polluted with undefined actions.
rulesToAST now generates conditions that respect rule priority.
@casl/ability 611 changes
Breaking changes 2
Manually setting __caslSubjectType__ now throws during authorization; use the subject() helper to assign subject types.
Drops support for Angular versions below 13.
Security 3
A proto pollution fix was ported from 7.x.
CASL Ability is Vulnerable to Prototype Pollution
Ignores potentially insecure fields in rulesToFields, helping prevent insecure fields from being included.
New APIs and options 2
The Rule type is now exported for developers to use.
The RuleOptions type is now exported for developers to use.
Performance 2
Performance improves for edge cases.
A new array is created lazily during rule field filtering.
Fixes and other changes 2
Adds Angular 13 support.
Replaces object.hasOwnProperty calls with static Object.hasOwn calls and a polyfill.
@casl/ability 540 changes
Breaking changes 16
Calling update triggers an update event.
No longer compares objects; users relying on a value equaling a specific object need to change conditions or implement a custom equal function.
Removes the subjectName option; use detectSubjectType instead.
Rules with all as the subject are prioritized in the same way as other rules, so rule ordering works as expected.
Ability functionality is provided by the @casl/ability package after CASL was split into packages under the @casl scope.
MongoDB-related functions moved to the separate @casl/mongoose package.
Ability throws an error when a rule specifies field as an empty array.
Ability no longer warns when only inverted rules are used, leaving the decision to the developer.
Removes LegacyClaimRawRule and LegacySubjectRawRule; rule definitions can no longer use actions and must use the action property.
manage represents any action rather than a CRUD alias; replace it with crud to retain the previous behavior.
MongoQuery now accepts an object interface for custom operators instead of a generic type of AdditionalOperators.
Renames MongoQueryOperators and adds an optional Value generic parameter.
rulesToQuery moved to @casl/ability/extra and its signature changed to accept an ability, action, subject, and rule callback.
The rulesToQuery export was moved out of the main package into @casl/ability/extra.
Subject-specific rules take precedence over all rules.
Replaces siftjs as the query-matching implementation, changing MongoQuery types and buildMongoQueryMatcher parameters for users who implemented custom sift operators.
Security 1
The prototype pollution fix was ported to ability-5.x.
New APIs and options 12
The on method was added, and update triggers an update event.
AbilityBuilder can accept the subject's Type.
Rule stores an ast property when conditionsMatcher has an ast property.
Rules support field patterns, allowing fields to be specified using patterns.
Forbidden reasons were added.
Methods to pack and unpack rules were added.
Per-field rules are supported.
The permittedAttributesOf helper was added.
The $regex condition is supported.
action was added as an alias for the actions Rule field.
A rulesToFields method was added.
Subjects can be passed as comma-separated items.
Performance 2
Fields are checked only when fields were specified in rules.
The permittedFieldsOf helper function was optimized.
Behavior and default changes 2
The third parameter to Ability.can is validated.
AbilityBuilder.define accepts an async function.
Fixes and other changes 7
The on method was added to the TypeScript definitions.
The TypeScript definitions for Ability were updated.
Event listeners are copied before they are called.
Inverted rules with conditions are ignored when checking subject type.
A TypeScript definition for rulesToFields was added.
An additional check was added to rulesToFields.
Returns null when an ability has only inverted rules.