fix(dynamic-field): escape media field value (stored XSS) - #1029
Open
mmcintosh wants to merge 1 commit into
Open
fix(dynamic-field): escape media field value (stored XSS)#1029mmcintosh wants to merge 1 commit into
mmcintosh wants to merge 1 commit into
Conversation
Companion to #1027 (number/date/datetime value): the media value/url is attacker-controlled content data (stored raw by the write path) and rendered back into the content-edit form. - New local escapeJsAttr helper (\xHH) — for a single-quoted JS string inside an HTML attribute, where escapeHtml is reversible (the browser HTML-decodes the attribute before the inline onclick parses). - media case: media value/url escaped in its HTML-attr sinks (video/img src, hidden value, data-url) via escapeHtml; the url in removeMediaFromMultiple(...) via escapeJsAttr. Not in scope (schema-admin defense-in-depth): the field_options attrs + id/name-from-field_name sinks; the root fix there is slug-validating field_name on write.
lane711
approved these changes
Jul 24, 2026
lane711
left a comment
Collaborator
There was a problem hiding this comment.
Fix is correct. escapeJsAttr logic sound — \x27/\x22 avoids the HTML-decode-before-parse pitfall. One pre-existing gap scoped out correctly (tracked separately): fieldId unescaped in onclick — root fix is slug-validating field_name on write.
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.
Description
Follow-up to #1027 (number/date/datetime
value): themediafield's value/url renders unescaped. The media value/url is attacker-controlled content data (stored raw by the write path) and rendered back into the content-edit form, so a content author can persist"><script>…in a media field and have it execute in an admin's edit form.Fixes #1028
Changes
escapeJsAttrhelper (\xHH) — for a single-quoted JS string inside an HTML attribute, whereescapeHtmlis reversible (the browser HTML-decodes the attribute before the inline onclick parses).src, hiddenvalue,data-url) viaescapeHtml; the url inremoveMediaFromMultiple(...)viaescapeJsAttr.Not in scope (schema-admin defense-in-depth): the
field_optionsattrs +id/name-from-field_namesinks; the root fix there is slug-validatingfield_nameon write.Testing
tsc --noEmitclean. Verified in the downstream fork (Infowall) with break-it tests (media HTML sinks + onclick each go red when the escape is removed).Unit / E2E
Checklist