fix(csp): support MemberExpression assignments in evaluator#4807
Merged
calebporzio merged 2 commits intoalpinejs:mainfrom Apr 10, 2026
Merged
fix(csp): support MemberExpression assignments in evaluator#4807calebporzio merged 2 commits intoalpinejs:mainfrom
calebporzio merged 2 commits intoalpinejs:mainfrom
Conversation
Replace the blanket "Property assignments are prohibited" throw with targeted logic that resolves the object and property, blocks DOM node writes (instanceof Node), and performs the assignment. The UpdateExpression MemberExpression path was missing both guards; align it with AssignmentExpression to correctly guard against DOM node writes and prototype pollution. Fixes alpinejs#4722 Ref: alpinejs#4671 (sections 3.1.6, 3.2.5)
7af94c0 to
21e0a67
Compare
- Add setAttribute, setAttributeNS, setAttributeNode, setAttributeNodeNS
to the dangerous keywords blocklist to prevent XSS via event handler
attribute injection (e.g. $el.setAttribute('onclick', 'evil'))
- Widen instanceof Node check to also cover CSSStyleDeclaration,
DOMStringMap, DOMTokenList, and NamedNodeMap to prevent property
assignments on DOM-adjacent objects (e.g. $el.style.cssText, $el.dataset)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Replace the blanket "Property assignments are prohibited" throw with targeted logic that resolves the object and property, blocks DOM node writes (instanceof Node), and performs the assignment. The UpdateExpression MemberExpression path was missing both guards; align it with AssignmentExpression to correctly guard against DOM node writes and prototype pollution.
Fixes #4722
Ref: #4671 (sections 3.1.6, 3.2.5)