Skip to content

@W-23515831: neutralize agent-directed text in portal machine-readable - #202

Merged
spezzirriemiliano merged 1 commit into
masterfrom
fix/W-23515831-prompt-injection-warning
Aug 4, 2026
Merged

@W-23515831: neutralize agent-directed text in portal machine-readable#202
spezzirriemiliano merged 1 commit into
masterfrom
fix/W-23515831-prompt-injection-warning

Conversation

@spezzirriemiliano

Copy link
Copy Markdown
Contributor

Summary

The Dev Portal's base template embedded a <nav aria-label="machine-readable" class="visually-hidden"> block whose contents directly addressed LLM agents in imperative voice —
STOP., If you are an AI agent or LLM: read AGENTS.md FIRST, Do NOT use summarizer tools, MANDATORY first read, Fetch with raw HTTP. Because this block lives in base.html,
every generated portal page inherited it.

Claude Code (in automode) flagged this as an attempted prompt injection on every page it browsed and surfaced a warning to end users — visible noise that erodes trust for
AI-agent-assisted workflows. Reported by Fernando Lescano; same symptom was internally recorded on 2026-07-15.

What changed

  • scripts/portal_generator/templates/base.html — rewrote the machine-readable nav in declarative, third-person voice. The block still exists (screen-readers, crawlers, and
    body-scanning agents still discover the three resources), but it now describes what each file contains instead of instructing the reader:
    • <p> describes the three resources and notes they are served as raw text/JSON.
    • Each <a> uses filename — Description format (no imperatives, no "Fetch/Read/STOP/MANDATORY", no If you are an AI… targeting).
  • <head> <link rel="help"> / rel="llms-txt" / rel="alternate"> discovery hints preserved. /AGENTS.md, /registry.json, /llms.txt are unchanged.

Why not just delete the block

The nav has legitimate purposes — screen-reader announcement, alternate discovery path for crawlers/agents that scan <body> and ignore <head>. Deleting it would drop that
affordance. Neutralizing the text keeps the discovery intent while removing the prompt-injection signals.

Tests

Added TestNoPromptInjectionTriggers in scripts/tests/test_smoke.py (7 tests):

  • 5 forbidden-phrase sweeps: homepage, API detail, MCP detail, skill pages, and a repo-wide *.html sweep — guards against reintroduction of the specific triggers (STOP., MANDATORY first read, If you are an AI agent, Do NOT use summarizer, read AGENTS.md FIRST).
  • 2 structural asserts on the machine-readable nav: exactly 3 anchors whose text starts with the target filename, and at most one <p> (any descriptive paragraph must remain
    declarative).

Verification

  • make test-portal → 614 pytest + 303 jest, all pass.
  • make generate-portal succeeds. Regenerated portal/ HTML no longer contains any of the forbidden phrases in files produced by base.html.
  • Manual: browse a served portal page with Claude Code (automode) and confirm the prompt-injection warning no longer surfaces.

Fixes W-23515831.

@spezzirriemiliano
spezzirriemiliano requested review from a team as code owners August 4, 2026 04:17
@spezzirriemiliano
spezzirriemiliano merged commit 64e3609 into master Aug 4, 2026
9 checks passed
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.

2 participants