fix: escape YAML data in threat model detail overlay to prevent XSS - #140
Merged
Conversation
The showThreatDetail() function in all four threat model pages (en, ja, ko, zh-cn) concatenates YAML-sourced threat data directly into innerHTML without sanitization. Because the trust page invites community contributions to the threat model via pull requests, a malicious PR modifying threats.yaml could inject arbitrary HTML/JS that executes when a visitor clicks any threat card. Add an escapeHtml() helper that encodes &, <, >, ", and ' and wrap all data fields (risk, atlas, description, attackVector, affected, mitigations, residualRisk, recommendations) and i18n label values before innerHTML insertion. Existing textContent assignments (detailId, detailTitle) are already safe and left unchanged. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
@SebTardif is attempting to deploy a commit to the Jamie's projects Team on Vercel. A member of the Team first needs to authorize it. |
Replace innerHTML badge construction with createElement/setAttribute to address VADE security review feedback. escapeHtml() is insufficient for href attributes because the browser decodes HTML entities during innerHTML parsing, allowing attribute boundary breakout. Using setAttribute bypasses HTML parsing entirely. All four locale files updated (en, ja, ko, zh-cn). Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
This was referenced May 17, 2026
SebTardif
added a commit
to SebTardif/openclaw.ai
that referenced
this pull request
May 24, 2026
… XSS
URL fields from JSON data files (testimonials.json, testimonials-extra.json,
community-builds.json, press.json) are rendered directly in <a href={...}>
attributes. Astro auto-escapes HTML entities but does not block dangerous
protocols like javascript:, data:, or vbscript:.
If a crafted URL like javascript:alert(document.cookie) were merged via a
community PR, it would render as a clickable XSS link on the homepage,
shoutouts, showcase, and press pages.
This adds a sanitizeUrl() utility that validates URL protocols at build time,
allowing only http:, https:, and mailto:. Dangerous protocols are replaced
with #. All existing URLs are https:// so there is no behavioral change.
Follows up on openclaw#140 and openclaw#142 which fixed related XSS vectors.
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
This was referenced Jul 10, 2026
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.
What
Escape all YAML-sourced data fields before
innerHTMLinsertion in the threat model detail overlay across all four locale pages (en, ja, ko, zh-cn).Closes #139
Why
showThreatDetail()concatenates threat data fromthreats.yamldirectly intoinnerHTMLwithout sanitization. Since the trust page invites community contributions to the threat model via PRs, a malicious modification tothreats.yamlcould inject arbitrary HTML/JS that executes when any visitor clicks a threat card.How
Add an
escapeHtml()helper (encodes&,<,>,",') in each page's<script>block and wrap all data fields:risk,atlas,description,attackVector,affected,mitigations,residualRisk,recommendationsdetailLabels.*values (defense in depth)Existing
textContentassignments (detailId,detailTitle) are already safe and left unchanged.Verification
npx astro buildpasses (21 pages built)escapeHtmlpresent in all 4 built output filesinnerHTMLcalls