Fix allowedAction comparison and root enforcement - #90
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
+ Coverage 90.66% 91.10% +0.44%
==========================================
Files 6 6
Lines 1897 1901 +4
==========================================
+ Hits 1720 1732 +12
+ Misses 177 169 -8
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
| ## 10.0.0 - 2026-09-dd | ||
|
|
||
| ### Changed | ||
| - **BREAKING**: Enforce a root capability's `allowedAction` when verifying a |
There was a problem hiding this comment.
I think this should be a patch. A delegated zcap that was invalid that this library didn't catch (even if properly signed by the delegator) is still invalid and this patch will now properly reject it. Those zcaps shouldn't have been accepted to begin with, so this is a fix.
27f9f38 to
9941f20
Compare
| const actions = getAllowedActions({capability: {allowedAction}}); | ||
|
|
||
| // parent's `allowedAction` must include every one from child's | ||
| return actions.every(a => parentActions.includes(a)); |
There was a problem hiding this comment.
Can we add a test that covers an explicitly provided, but empty array for allowedAction? Added tests here should at least include negative tests where the child uses an empty array but the parent used a string or a non-empty array. It seems like an empty array in the child could pass here when it shouldn't.
There was a problem hiding this comment.
Agreed, that the helper itself would return true there, but an empty array can't reach it: checkCapability rejects any allowedAction that isn't a string or non-empty array (utils.js#L578) and runs first on both paths - before hasValidAllowedAction in CapabilityDelegation.update (L145 vs L160), and on every zcap in the dereferenced chain (utils.js#L339, #L412) before _verifyCapabilityChain ever compares actions - which the three tests in 105adc4 now pin down at both layers.
Compares
allowedActionsets rather than JSON types so a delegation that narrows nothing succeeds whether each side spells its actions as a string or an array, and seedsparentAllowedActionfrom the root zcap so a root'sallowedActionis enforced by the verifier and not only when a delegation proof is generated.Fixes #89