fix: harden composables against prototype pollution, CSS injection, and unbounded allocation#271
Open
johnleider wants to merge 4 commits into
Open
fix: harden composables against prototype pollution, CSS injection, and unbounded allocation#271johnleider wants to merge 4 commits into
johnleider wants to merge 4 commits into
Conversation
createPermissions built a nested plain object keyed by caller-supplied role/action/subject names with no guard, so a __proto__ key in a permissions config (e.g. one sourced from a backend) could pollute Object.prototype. Skip keys in the shared UNSAFE_KEYS blocklist at all three levels; export UNSAFE_KEYS from #v0/utilities so it is reused rather than duplicated.
range(toValue(size)) allocated an unbounded array, so a large or non-finite size could exhaust memory. Clamp the count to a finite upper bound before allocating, mirroring the guard in createPagination.
Extend ThemeAdapter UNSAFE_CSS to also reject < and >, closing a </style> breakout on the SSR/unhead innerHTML path. Theme color values never legitimately contain angle brackets.
Codify the four sink-to-guard patterns (UNSAFE_KEYS, CSS sanitizer, CSS.escape, bounded range) so new code reaches for the existing guard instead of reinventing it.
|
commit: |
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.
Security hardening pass over the v0 composables — three independent fixes plus a rule documenting the convention.
createPermissionsbuilt a nested plain object keyed by caller-suppliedrole/action/subjectnames with no guard, so a__proto__key in a permissions config (e.g. one fetched from a backend) could polluteObject.prototype. It now skips keys in the sharedUNSAFE_KEYSblocklist at all three levels;UNSAFE_KEYSis exported from#v0/utilitiesso it is reused rather than duplicated.range(toValue(size))allocated an unbounded array, so a large or non-finitesizecould exhaust memory. The count is now clamped to a finite upper bound before allocating, mirroring the existing guard increatePagination.ThemeAdapter'sUNSAFE_CSSpattern now also rejects<and>, closing a</style>breakout on the SSR/unheadinnerHTMLpath. Theme color values never legitimately contain angle brackets.Also adds a
## Security primitivessection to.claude/rules/implementation.mdmapping each sink shape to its existing guard, so new code reaches for the primitive instead of reinventing it.For context:
mergeDeepwas already guarded, and registry/selection/nested/tokens keyed state isMap-based and pollution-immune by construction.packages/0typecheck, lint, and the affected test suites are green.