Skip to content

feat(security): record what untrusted issue text tried to do - #891

Merged
HugoXK merged 1 commit into
mainfrom
dev1/370-untrusted-input
Nov 16, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev1/370-untrusted-input

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-1
Bot: Fledge Platform Dev-1

What changed

#370's labelling slice (#857) fences issue title and body as data. Fencing alone does not say what the text tried to do, so this slice names it.

  • src/lib/firewall.ts: scanUntrusted() scans the exact string the fence carries — after control characters are stripped, so a hidden newline cannot split a pattern the agent still reads — against a finite, ordered rule table (ignore-previous-instructions, push-to-main, merge-pull-request, system-prompt, run-command, reveal-secret). It returns rule ids only; matched text is never returned.
  • /fledge plan and /fledge fix record the verdict on the job event job.untrusted_input and in the job.untrusted_input audit row as blocked=<ids|none>, beside the label, body hash and truncation flag.
  • The job page states the count and the ids (data-untrusted-input), in both locales. The body stays out of the event, the log and the page.
  • parseUntrustedMeta() refuses a record it did not write (hand-edited event, older row, smuggled text), so a bad row is not rendered as a claim.
  • Nothing is blocked by the firewall itself: it labels and records. Choosing whether a flagged run may continue, confirmation for high-risk actions and any bridge/ change remain the follower half of security: treat issue text, PR comments and repo files as untrusted input to the agent #370.

Fixes #370 (slice: the firewall and its record; the fence shipped as #857).

Ran:

  • npm run check at ac4cac2 — 2323/2323, exit 0
  • npx tsx --test test/firewall.test.ts at 410f16b2 with the delivered test file — 0 pass / 1 fail (ERR_MODULE_NOT_FOUND src/lib/firewall.js); 6/6 at the tip
  • npx tsx --test test/untrusted.test.ts test/firewall.test.ts at the tip — 11/11
  • node scripts/risk-gate.mjs --base 410f16b2 — risk-tier: T2; basis: src/app.ts
    Not run: no bridge change, no live FlyBot run, no Docker image, no database migration (none exists).

Risk and rollback

T2, src/. No schema change, no config key, no bridge contract change. Revert the squash to roll back; the audit event kind simply stops being written.

Docs

docs/security.md (the firewall paragraph replaces the "follower half" claim) and docs/architecture.md (issue-command section) in the tree. Changelog fragment changelog.d/370-untrusted-firewall.added.md.

maintainer_can_modify: true

@HugoXK
HugoXK enabled auto-merge (squash) November 16, 2026 03:59
@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

PASS requested at a3a4437ae250e7b71edd7aaf784414de3f2e896c

Written-by: Fledge Platform Lead

All checks at this tip are green except review-gate. Tree a178cd87, parent 410f16b2; T2 src/app.ts.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: PASS at a3a4437

Written-by: HugoXK-bot
Author: Fledge Platform Verdict

  • The record carries ids, never text: src/lib/untrusted.ts:104 writes only label/sha256/truncated/blocked, and the reader at :119/:124 refuses any row it did not write, so a hand-edited meta renders nothing at src/views/pages.ts:3201-3203.
  • The scan reads the same normalised string the fence carries, not the raw bytes: src/lib/firewall.ts:37-39 strips control characters first, so a hidden newline cannot split a pattern the agent still sees; the table is bounded and every pattern is non-global (:24-30), pinned by test/firewall.test.ts:44.
  • Both issue paths write one shape and the page event only when there is a job: src/app.ts:5906-5912 audits always and records job.untrusted_input only when commandJobId is non-null, which is exactly what the page's find needs at src/views/pages.ts:3200.
  • The behaviour is pinned by tests that fail without it: test/firewall.test.ts:11, :51, :71, and test/untrusted.test.ts:82.
  • Non-blocking: src/app.ts:5907 scans the untruncated payload while the fence caps at 4000 (src/lib/untrusted.ts:12), so a directive past the cap is recorded though the agent never reads it — over-labelling only; and run-command will fire on ordinary prose such as "run the script", which is acceptable because a hit records and never blocks.

Ran:

  • npm run check in a tree of a3a4437a — exit 0, 2323/2323 pass (lint vs baseline, typecheck, test, build); dependencies came from an npm ci install whose package-lock.json sha256 is identical to this head's lock
  • npx tsx --test test/firewall.test.ts test/untrusted.test.ts — 11/11 at the tip
  • red half: src/app.ts, src/lib/untrusted.ts, src/lib/firewall.ts, src/views/pages.ts restored to base 410f16b2 (blob hashes dd15e401, 29008c7e, 07951d61 match the PR's base side), same tests — the firewall suite fails to load (ERR_MODULE_NOT_FOUND) and test/untrusted.test.ts is 3/6 red
  • node scripts/risk-gate.mjs --base <base tree> --head <head tree> — risk-tier: T2; basis: src/app.ts, 9 files +217/−18, matching the PR
  • GITHUB_TOKEN=… node scripts/pr-lint.mjs --pr 891 — pr-lint: ok (#891, T2, 9 files)

Not run: no real GitHub issue was driven through the firewall (no issue posted, no live job consumed the fenced goal); the scan was exercised only against the test bodies and the fixed rule table.

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 16, 2026
@HugoXK
HugoXK merged commit e450dac into main Nov 16, 2026
33 of 34 checks passed
@HugoXK
HugoXK deleted the dev1/370-untrusted-input branch November 16, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: treat issue text, PR comments and repo files as untrusted input to the agent

2 participants