Skip to content

fix(admin): XSS in adagents builder + retire legacy creator (#4468) - #4614

Merged
bokelley merged 2 commits into
mainfrom
fix-adagents-builder-xss-4468
May 17, 2026
Merged

bokelley merged 2 commits into
mainfrom
fix-adagents-builder-xss-4468

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • XSS fix. displayValidationResults() and displayAgentCardsResults() in server/public/adagents-builder.html interpolated attacker-controlled fields from a fetched adagents.json and its A2A agent cards straight into innerHTML. Any admin who validated a hostile domain executed attacker-controlled JS. All reflections now route through escapeHtml(), including the raw-data <pre> block (which previously let an attacker break out with </pre><script>).
  • Legacy creator retired. startCreating() and updateUIForCreateOrUpdate() 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-controlled agent.url / authorized_for / property_ids into value= attributes without escaping. Removed. resetCreator() updated to drop references to the removed IDs.
  • Regression test. New tests/community/adagents-builder-xss.test.ts loads the static page in jsdom, drives the two reflection helpers with hostile payloads (<script>, <img onerror>, </pre> break-out, hostile domain), 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 innerHTML usages total; a systematic migration to textContent / DOM-API construction is out of scope here and should be a follow-up issue. The live showValidationSummary() helper at ~4890 also reflects attacker-controlled errors[*].message / warnings[*].message into innerHTML without 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 cases
  • Precommit (test:unit + lint passes + typecheck) green
  • Manual smoke: open /adagents-builder.html, enter a domain that returns a hostile adagents.json, confirm script payloads render as literal text

🤖 Generated with Claude Code

…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]>
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]>
@bokelley
bokelley merged commit c4b9ea8 into main May 17, 2026
13 checks passed
@bokelley
bokelley deleted the fix-adagents-builder-xss-4468 branch May 17, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant