Repository navigation
fix(admin): XSS in adagents builder + retire legacy creator (#4468) - #4614
Merged
Merged
Conversation
…4468) Any admin validating a hostile domain via the adagents.json builder could execute attacker-controlled JS: the validation result renderer interpolated `card_data.name`, `validation.errors[*]`, `validation.warnings[*]`, `agent_url`, `domain`, and the raw-data JSON dump straight into innerHTML. Both reflection clusters now route through escapeHtml(), including the raw-data <pre> block (previously break-outable with `</pre><script>`). The legacy quick-add creator path (startCreating / updateUIForCreateOrUpdate) was orphaned when the v3 builder landed — its entry-point DOM IDs no longer exist — but it remained in the source emitting v2-shape agent rows and interpolating attacker-controlled URLs / authorized_for / property_ids into value= attributes without escaping. Removed. resetCreator() updated to drop references to the removed IDs. Regression test loads the static page in jsdom, calls the reflection helpers with hostile payloads (`<script>`, `<img onerror>`, `</pre>` break-out), and asserts no executable nodes are parsed into the DOM and no global side-effect fires. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
2 tasks
The earlier hardening covered displayValidationResults / displayAgentCardsResults
(orphan paths), but showValidationSummary is what startManaging() and the
Get Started button actually call. It interpolated err.message / warn.message
straight into innerHTML, and adagents-manager.ts echoes attacker-controlled
signal IDs, agent fields, tag names, and property IDs from the fetched
adagents.json into those messages — so an attacker who hosts
.well-known/adagents.json could inject script into the admin origin via a
single Get Started click.
Wrap message interpolations in escapeHtml(), gate errors/warnings shape to
{ message: string }, and add four regression tests covering both the direct
exploit and the real adagents-manager echo paths.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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
displayValidationResults()anddisplayAgentCardsResults()inserver/public/adagents-builder.htmlinterpolated attacker-controlled fields from a fetchedadagents.jsonand its A2A agent cards straight intoinnerHTML. Any admin who validated a hostile domain executed attacker-controlled JS. All reflections now route throughescapeHtml(), including the raw-data<pre>block (which previously let an attacker break out with</pre><script>).startCreating()andupdateUIForCreateOrUpdate()were orphaned when the v3 builder landed — their entry-point DOM IDs (creator-domain-input,creator-domain-step,start-creating-btn, etc.) are gone from the HTML — but the v2-shape-emitting handlers stayed in the source and interpolated attacker-controlledagent.url/authorized_for/property_idsintovalue=attributes without escaping. Removed.resetCreator()updated to drop references to the removed IDs.tests/community/adagents-builder-xss.test.tsloads the static page in jsdom, drives the two reflection helpers with hostile payloads (<script>,<img onerror>,</pre>break-out, hostiledomain), and asserts no executable nodes are parsed into the DOM and no global side-effect fires.Scope guards
Per the audit, only the two cited reflection clusters (~1884-1975, ~5256-5292) and the legacy form path are touched in this PR. The file has 61
innerHTMLusages total; a systematic migration totextContent/ DOM-API construction is out of scope here and should be a follow-up issue. The liveshowValidationSummary()helper at ~4890 also reflects attacker-controllederrors[*].message/warnings[*].messageintoinnerHTMLwithout escaping — same defect class, also worth folding into the follow-up.Closes adcp#4468.
Test plan
npx vitest run tests/community/— 34 passed (2 files), including the 6 new XSS regression casestest:unit+ lint passes +typecheck) green/adagents-builder.html, enter a domain that returns a hostileadagents.json, confirm script payloads render as literal text🤖 Generated with Claude Code