fix(security): escape API-controlled values in sophia_dashboard innerHTML (RIP-306) - #16832
Merged
Scottcjn merged 1 commit intoSep 5, 2026
Conversation
…HTML (RIP-306)
scripts/sophia_dashboard.py (Admin Dashboard for SophiaCore Attestation Inspector):
- Add esc() helper that escapes the five HTML-significant characters.
- Replace the per-row inline-onclick-with-JSON.stringify pattern with a single
delegated click listener on #review-table that reads data-record-idx and
looks up the record from currentFilteredRecords.
- Escape every API-controlled value going into tbody.innerHTML.
- Escape API-controlled values in detail-verdict and detail-history blocks.
- detail-title now uses textContent (inherently safe).
- Coerce confidences through Number() before arithmetic.
- Add EMOJI[...]-lookup fallback (|| empty-string).
tests/test_sophia_dashboard_xss.py:
- 9 source-pattern regression tests that fail if the unsafe patterns come back.
Refs: RIP-306 admin dashboard XSS; same defensive posture as Scottcjn#16790, Scottcjn#16809-Scottcjn#16821.
Scottcjn
approved these changes
Sep 5, 2026
Scottcjn
left a comment
Owner
There was a problem hiding this comment.
Escapes API-controlled values in sophia_dashboard innerHTML (RIP-306 surface).
Contributor
|
Sophia auto-tier: skipped — this PR touches consensus / money / CI code. It needs a maintainer |
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.
Summary
scripts/sophia_dashboard.py(Admin Dashboard for SophiaCore Attestation Inspector) renders 4 API-controlledinnerHTMLblocks. Three were missing escape, and one had the same unsafe inline-onclick+JSON.stringifypattern as #16790 (reviewer asked for that fix to be reused here).Fix
esc()helper that escapes& < > " 'and coerces nullish to''.onclick='showDetail(${JSON.stringify(r).replace(/'/g,"'")})'with a single delegated click listener on#review-tablethat readsdata-record-idxand looks up the record fromcurrentFilteredRecords. The'replace was a no-op (the browser HTML-decodes it back to'before evaluating the JS string), and any value containing'or</script>could break out.tbody.innerHTML,detail-verdict, anddetail-history.detail-titlenow usestextContent(inherently safe).Number()before arithmetic so a non-numeric payload returnsNaNrather thanNaN-as-string.EMOJI[...]-lookup fallback (|| '') so a malicious verdict value does not produceundefinedin the chip.Tests
tests/test_sophia_dashboard_xss.py— 9 source-pattern regression tests, all pass:Related
Notes