Skip to content

fix(aichecks): hold AI runs with real secrets to a runtime host allowlist - #631

Merged
fclairamb merged 8 commits into
mainfrom
security/scan-specs-2026-10-22
Oct 22, 2026
Merged

fclairamb merged 8 commits into
mainfrom
security/scan-specs-2026-10-22

Conversation

@fclairamb

@fclairamb fclairamb commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Fixes the open finding of the daily security scan of 2026-10-22 (P1, medium).

What changes

  • AI repair and generation runs that hold a check's real secrets are now held to a runtime host allowlist (egress.HostAllowlist), checked by name before any DNS lookup. Repair allows the hosts of the previous script, generation the hosts declared in the prompt, contract and env.
  • Every network API of checkjs goes through it: http (redirects included), websocket, tcp.connect, udp.open, rdp, vnc. browser.open() and solidping.* sub-checks are refused while it is active.
  • A refused host makes the run fail with HostNotAllowedError, even if the script reported up. The refused host is scrubbed of secret values and fed back to the model.
  • The static ScriptHosts scan stays as an early refusal only.
  • repair: auto: a candidate whose hosts cannot be read from its text, when the previous version's could, is proposed instead of applied.
  • Docs: ai-authored-checks.md.

Behavior changes

  • An AI repair of a browser-based check that uses secrets can no longer pass its test run.
  • aichecks.Runner.Run takes a new allowed []string argument.
  • Scheduled runs are unchanged: the allowlist only applies to AI-loop runs.

Residual risk (follow-up)

With repair: auto, a candidate that keeps env.BASE_URL visible but sends secrets to a runtime-built host only under a condition the verification run does not meet (a date, Math.random()) is still applied, and its scheduled runs carry no allowlist. This is the design the spec recommended. Closing it needs its own spec.

Checks

  • make build-backend lint-back test: green.
  • make test-postgres: green except a 10 min timeout in db/postgres on a loaded machine (load above 11), untouched by this PR; that package passed alone in 478 s.

Decided by autopilot

No open question to answer.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.53125% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.61%. Comparing base (ecbbad7) to head (03c4e8c).

Files with missing lines Patch % Lines
server/internal/aichecks/runner.go 91.66% 2 Missing ⚠️
server/internal/egress/allowlist.go 95.65% 2 Missing ⚠️
server/internal/checkers/checkjs/rdp.go 50.00% 1 Missing ⚠️
server/internal/checkers/checkjs/vnc.go 50.00% 1 Missing ⚠️
server/internal/checkers/checkjs/websocket.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #631      +/-   ##
==========================================
- Coverage   83.66%   83.61%   -0.05%     
==========================================
  Files        1267     1268       +1     
  Lines      129598   129703     +105     
==========================================
+ Hits       108431   108455      +24     
- Misses      21158    21239      +81     
  Partials        9        9              
Files with missing lines Coverage Δ
server/internal/aichecks/guards.go 88.80% <100.00%> (+1.88%) ⬆️
server/internal/aichecks/repair.go 87.39% <100.00%> (+0.22%) ⬆️
server/internal/aichecks/service.go 87.60% <100.00%> (+0.10%) ⬆️
server/internal/aichecks/tools.go 85.80% <100.00%> (+0.35%) ⬆️
server/internal/checkers/checkjs/browser.go 88.52% <100.00%> (+0.12%) ⬆️
server/internal/checkers/checkjs/checker.go 91.34% <100.00%> (+0.04%) ⬆️
server/internal/checkers/checkjs/socket.go 88.54% <100.00%> (+0.08%) ⬆️
server/internal/mcp/tools_jsauthoring.go 90.54% <100.00%> (ø)
server/internal/checkers/checkjs/rdp.go 83.50% <50.00%> (-0.35%) ⬇️
server/internal/checkers/checkjs/vnc.go 84.17% <50.00%> (-0.44%) ⬇️
... and 3 more

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fclairamb and others added 5 commits October 22, 2026 14:42
…list

The repair and generation loops decided whether a candidate script may run
with the check's real secrets by scanning its text (ScriptHosts). A URL built
at runtime (concatenation, a host read from a response, Object.values(env))
was invisible to it, so a prompt injection in page content could send the
secrets to any host.

Runner.Run now puts an egress.HostAllowlist on the context of every run that
holds a real secret value: the previous script's hosts for a repair, the
hosts the user named for a generation. The checkjs runtime checks it on the
host name, before resolution, for http (redirects included), websocket,
tcp/udp, rdp and vnc. browser.open() and solidping.* sub-checks dial outside
its reach and are refused while it is active. A refused run is an error
(host not allowed while secrets are loaded), so the candidate is refused and
the refusal lands in the attempt event. The verification run uses it too.

repair: auto no longer applies a candidate whose text shows no host while the
previous version's did: scheduled runs carry no allowlist, so it is proposed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Also lint fixes for the allowlist change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ets to scripts whose hosts are only checked by regex

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts to scripts whose hosts are only checked by regex

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fclairamb fclairamb changed the title chore(specs): security scan findings fix(aichecks): hold AI runs with real secrets to a runtime host allowlist Oct 22, 2026
@fclairamb
fclairamb enabled auto-merge (squash) October 22, 2026 16:42
@fclairamb
fclairamb merged commit c09fdd1 into main Oct 22, 2026
33 checks passed
@fclairamb
fclairamb deleted the security/scan-specs-2026-10-22 branch October 22, 2026 17:30
fclairamb added a commit that referenced this pull request Oct 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.41.0](v0.40.1...v0.41.0)
(2026-10-22)


### Features

* **email:** calmer emails that say why a check is down
([#623](#623))
([8dd68d3](8dd68d3))
* run crawl and discovery as worker tasks from private locations
([#633](#633))
([062fd99](062fd99))


### Bug Fixes

* **aichecks:** hold AI runs with real secrets to a runtime host
allowlist ([#631](#631))
([c09fdd1](c09fdd1))
* **checkdns:** stub the resolver in TestDNSChecker_Execute
([#630](#630))
([cca1d88](cca1d88))
* **dash0:** drag-to-zoom on the Timing chart
([#617](#617))
([931816c](931816c))
* **deps:** update github.com/dop251/goja digest to 07c4b9d
([#637](#637))
([0170643](0170643))
* **deps:** update github.com/dop251/goja digest to 64adc8b
([#626](#626))
([1efd502](1efd502))
* **deps:** update github.com/dop251/goja digest to 7b1a022
([#619](#619))
([d3adde9](d3adde9))
* **deps:** update go dependencies (non-major)
([#622](#622))
([adb622c](adb622c))
* **deps:** update go dependencies (non-major)
([#627](#627))
([dee2fd0](dee2fd0))
* **deps:** update go dependencies (non-major)
([#635](#635))
([da717a5](da717a5))
* **deps:** update module github.com/a2aproject/a2a-go/v2 to v2.7.0
([#625](#625))
([bb8c7ae](bb8c7ae))
* **deps:** update module github.com/anthropics/anthropic-sdk-go to v2
([#628](#628))
([90f70c2](90f70c2))
* **deps:** update module github.com/fergusstrange/embedded-postgres to
v2 ([#614](#614))
([913ece9](913ece9))
* **email:** usage-cap email links to the platform upgrade page, not
billing ([#632](#632))
([abf3a68](abf3a68))
* **status-pages:** close a grouped check's entry when it recovers
([#615](#615))
([d4d9b21](d4d9b21))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
fclairamb added a commit that referenced this pull request Oct 23, 2026
…646)

Fixes finding Q1 of the 2026-10-23 security scan (medium): the AI repair
and generation loops could relay an encoded secret through the model to
`fetch_page` or to a run without secrets. Scrubbing only removes exact
matches, so this got past the runtime host allowlist from the P1 fix
(#631).

Spec:
`specs/done/2026/10/2026-10-23-02-ai-loop-secret-relay-through-model.md`.

## What changed

- Once a loop has made a run with real secret values, it is held to the
check's own hosts: `fetch_page` only reaches those hosts,
`browser_snapshot` is refused, and a blank-secrets `run_script` gets the
same allowlist (repair and generation).
- A refused host that was built at runtime is no longer named in the
error the model sees.
- Exact-match scrubbing stays as defence in depth. Comments, the P1 done
spec and `web/docs/docs/features/ai-authored-checks.md` now say so.
- Regression tests for the repair and generation paths and the refused
host, with positive controls (a loop without a real-secrets run can
still fetch any host; a repair on the previous host still runs with the
real secret).
- `origin/main` merged in.

Behaviour change: after a real-secrets run, repair and generation lose
`browser_snapshot` and any `fetch_page` outside the check's hosts for
the rest of that loop.

Batch gate: `make build-backend lint-back test` green.

## Decided by autopilot

No open questions in the spec: the recommended proposal (1, plus 3 and
4) was implemented.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant