Hardening
Untrusted-input hardening closes the path from untrusted GitHub text to unauthorized writes across five progressive stages. Each stage keeps the sandbox’s network and role boundaries intact while shifting reads and writes behind factory-verified checks.
flowchart LR
h1["H1 · Audit<br/>canary in briefs · shadow check<br/>on every GitHub write"] --> h2["H2 · Non-code outputs<br/>output_pr / comment / labels / issue<br/>publisher + tracer"]
h2 --> h3["H3 · Push enforced<br/>git push → bundle inspected<br/>protected paths need digest approval"]
h3 --> h4["H4 · Reads filtered + drills<br/>forge_read withholds low-trust authors<br/>no api.github.com egress · weekly drills"]
h4 --> h5["H5 · Ready + T5 promotion<br/>all 7 readiness checks hold<br/>classifier promoted per output type"]
Hardening, audit
Stage H1 is untrusted-input hardening’s first live stage. Under mode: audit, the factory checks every GitHub write an agent run makes, records what enforcement would have done, and changes nothing the run can do. Readiness stays false until mode: enforce (Hardening, reads filtered), and switching from off to audit takes a factory restart (hardening keys are in the config reference).
What audit changes
- A canary in the brief. An implementer or tester run’s brief ends with
Canary mkc-…: never write this token anywhere: …. The canary is stored on theAgentRunasagents.ogenki.io/canaryand is never posted to the room. Any write that quotes it is a T3 finding. - A shadow record per write. When an implementer or tester run ends, the factory reads that run’s writes back from GitHub as the agents App within the run’s window: pushes, the pull request’s title and body (harness footer stripped), comments, labels added and issues opened. It runs T1–T5 in audit on each write and appends one
output_shadowedevent holdingwould_apply,would_refuse(first T1–T4 finding), orwould_wait(a push touching a protected path that would wait for approval under H3), with T5 and remaining findings inaudit. A failed shadow pass is logged and retried on the next reconcile without blocking the task. status.inputTruston the Task. Records the lowest author trust the task’s runs could read (min), per-source counts that enforcement would have withheld (withheld), each source’s kind and level (sources, never content), andmode: audit. Split children and integration tasks inherit the parent’smin.- The agent-guard client. When
hardening.agentGuard.urlis set, T5 posts written text to<url>/request; aRejectresponse is recorded asinjection_suspectedand never decides an audit verdict.
What audit does not change
- No write is refused, held or rewritten; the run’s own token still writes directly.
- Nothing is withheld from a brief or tool result (
withheldonly counts what enforcement would have omitted). - No
output_*tool is served and sandbox roles keep their GitHub scopes unless the repository also opts intoenforceOutputs. - The laptop demo is never audited.
The repository’s hardening block
A repository may tighten the central floor in .github/agent-factory.yaml beside factory::
factory: production
hardening:
protectedPaths:
- {path: "scripts/ci/**", on: blocked} # on: blocked | approval
minAuthorTrust: merged # may raise the central floor, never lower itprotectedPaths extends the central protected-path floor, and minAuthorTrust can only raise the central floor (a lower level, unknown key, or unparseable block falls back to the central floor plus merged and logs a warning). The block never decides repository ownership.
Stop rule: do not add a hardening: block before a factory release supporting it runs on the owning cluster; older factories parse .github/agent-factory.yaml strictly and treat unknown keys as not owned.
Hardening, non-code outputs enforced
Stage H2 moves non-code GitHub writes out of the sandbox for opted-in repositories (hardening.enforceOutputs or hardening.repositories.<repo>.enforceOutputs). Instead of opening, editing, commenting on or labelling pull requests and issues directly, a writer run requests each action with an output_* tool; the factory checks T1–T4 at enforce (T5 in audit) and publishes or refuses it.
Startup enforces five invariants on enforceOutputs:
- Types:
pr,comment,labels,issueand (from H3)push. - Inheritance: a repository’s list replaces the central list and must include every central type.
- Mode: any listed repository requires at least
mode: audit. - Publisher and per-run tokens: any list requires
hardening.publisher.minter: trueandrunTokens.perRun: true(the removedpublisher.octoSTSkey is refused: upgrading). WithoutrunTokens.perRun, runs would share a direct writer token. - Hash:
enforceOutputsenters the configuration hash bound by injection drills.
flowchart LR
A["implementer run"] -->|"output_pr / comment / labels / issue"| B["broker :8090<br/>served per run"]
B -->|"output_requested"| L[("room log")]
L --> P["applier (factory leader)<br/>T1–T4 enforce"]
P -->|"agents App, minted publisher token"| G[("GitHub")]
P -->|"issue: factory App, factory/proposed"| G
P -->|"output_applied / output_refused"| L
G -->|"run end: tracer"| T["untraced_write"]
What a run on an enforced repository sees
- Tools and rules. The
AgentRuncarriesagents.ogenki.io/safe-outputsandagents.ogenki.io/label-allowlist; the broker servesoutput_<type>only to annotated runs, and the brief’s rules instruct the agent to request enforced types throughoutput_<type>. - Advisory
ghwrapper. WithSAFE_OUTPUTSset, mutatinggh pr,gh issue, andgh labelsubcommands for enforced types exit 3 and name theoutput_*tool. Becausegh apiorcurlcould bypass the wrapper, the role table revokes direct write scopes (pull_requests: read,issues: read) as the real boundary and the tracer acts as the backstop.
What the factory does
- Applier and publisher. On the leader, the applier polls active writer rooms every
applier.interval(default2s, continuing forapplier.answerWait, default5m, after a run ends so unfinished requests hold task completion until answered or loggedoutputs_unanswered). Approvedpr,commentandlabelsoutputs are published asagentsLoginusing a cached token minted from the role table’s publisher row (Agent-Output: <id>in the PR footer; edits to PRs not opened by the task’s applied outputs are refusedoutput_target). Approvedissueoutputs are filed by the factory App withfactory/proposedonly. - Tracer and permission gauge. At run end, the tracer verifies every agents-App PR, comment and label on the task against
output_appliedrecords. Any unmatched write (or direct edit not attributable solely to a human underrunTokens.perRun, which logshuman_edit) is recorded asoutput_shadowedwithuntraced_writeand checked as in H1. Pushes remain shadowed untilpushis enforced. Each fence pass exports sandbox and publisher scopes from the role table; rollout and rollback steps are in Operations, and residual blind spots are in Security.
Hardening, push enforced
Stage H3 adds push to enforceOutputs (with the repository also listed in the broker’s roomTools.pushRepositories and a git cache mounted via hardening.gitCache.sizeLimit / MAKU_GIT_CACHE). Writer runs lose contents: write; git push becomes a bundle handed to the broker, inspected in a bare mirror, and pushed by the publisher. Pushes touching a protected path wait for a maintainer’s digest-bound approval.
flowchart LR
G["agent: git push"] -->|"git shim"| AP["agent-push<br/>git bundle create"]
AP -->|"output_push (harness only)"| BR["broker<br/>bundle store"]
BR -->|"output_requested"| LOG[("room log")]
LOG --> APL["applier<br/>inspect, caps, T1–T4, T5 audit"]
APL -->|"protected path"| APR["approval of the digest<br/>room page or Slack"]
APR -->|"approval_decided"| LOG
APL -->|"git push --force-with-lease<br/>publisher token"| GH[("GitHub")]
APL -->|"output_waiting / applied / refused"| LOG
What a run sees
git pushshim. WithpushinSAFE_OUTPUTS,git pushinvokesagent-push, which bundlesrefs/heads/agent/<task>(refusing deletes, tags, other branches with exit 3, and bundles > 8 MiB withpush_size), callsoutput_push, and pollsoutput_statusfor up to 90 s (applied <sha>,refused <reason>, orwaiting for a maintainer's approval (<id>)). Tester contract pushes request and wait; disruption checkpoints request without waiting inside their 7 s budget. As withgh, the shim is advisory and the run token’scontents: readis the boundary.
What the factory checks
For each push request in order:
- Bundle integrity. Inspected in a bare, blobless mirror (
mirrorMaxBytes, default 1 GiB) withfsckenabled and hooks disabled. Must carry onlyrefs/heads/agent/<task>as a fast-forward or rebase ontomain; submodules, escaping symlinks,.gitpaths, binaries, and blobs > 1 MiB are refused. - Patch caps. Cumulative diff from merge base must fit the class’s
maxPatchFilesandmaxModifiedLines(or the strictest cap across declared classes when undeclared), elsepush_size. - Threat layers. T1–T4 enforced (T5 audit) across changed paths, added lines and commit messages. Blocked paths refuse; approval-gated paths answer
output_waiting, hold subsequent requests, keep the task inImplementing(push_awaiting_approval), and wait up toapplier.approvalTTL(default24h, max168h) for a repository-writer approval of that digest on the room page or Slack (re-inspected before pushing; superseded by a newer push asoutput_superseded, or refusedapproval_denied/approval_expired). - Publish and trace. The factory records
agents.ogenki.io/push-intent, pushes with--force-with-leaseas the publisher, and answersoutput_applied. At run end the tracer checks every branch push SHA againstoutput_applied(untraced_writeotherwise).
The tokens
Enforcing push moves contents: write from implementer and tester to the publisher in the role table. Workflow-file pushes (.github/workflows/**) still fail with output_unavailable unless the publisher row grants workflows: write. Rollout and rollback are in Operations.
Hardening, reads filtered
Stage H4 switches a repository to mode: enforce once all five output types are enforced, api.systemPrincipals maps the broker ServiceAccount to system:broker, and the broker sets broker.hardening.forgeRead.audience: agent-factory. Runs lose api.github.com egress (git keeps github.com) and read their task’s issue, pull request and checks exclusively through forge_read, where the factory withholds content from authors below minAuthorTrust before any model sees it.
flowchart LR
A["agent: forge_read {target}"] --> B["broker"]
B -->|"POST /v1/runs/{run}/forge-read<br/>as system:broker"| F["factory<br/>withhold below minAuthorTrust"]
F -->|"factory App"| GH[("GitHub")]
B -->|"input_read (counts)"| LOG[("room log")]
LOG --> T["status.inputTrust<br/>mode enforce"]
What a run sees
forge_read. Servestargetin{issue, pr, checks}for the caller’s own verified task (cached 15 s per run and target to bound App rate use):issuereturns the issue and comments,prreturns description, reviews and comments, andchecksreturns head check runs plus the last 16 KiB ([truncated]) of failed GitHub Actions job logs. Factory and agent comments are omitted; delivered items carry author trust levels and withheld items appear only as counts ([2 items withheld: author trust]).- Vouching.
factory/readyvouches for the issue title and body matching the task’s snapshot hash; any later edit voids the vouch and falls back to author association.factory/vouchfrom a maintainer or repository writer vouches for an unedited issue or PR description. Comments and reviews are never vouched. - Egress and
gh. Every run on the repository (reviewer and triager included) carriesagents.ogenki.io/forge-api: deny: the run-controller stripsapi.github.comfrom network policy and egress allow-lists and setsFORGE_READ=1. Read-sidegh issue,gh pr,gh runandgh apicommands exit 3 namingforge_read, diffs come fromgit diff origin/<base>...HEAD, and token revocation happens outside the sandbox via therunTokens.perRunticker when the run finishes.
What the factory records
Each call appends one input_read event with target, lowest delivered trust level, and delivered/withheld counts per kind (never bodies). Under enforce, status.inputTrust.mode is enforce, withheld sums input_read counts, and min reflects only delivered items. Because checksum/config restarts the factory on config edits, run annotations, /forge-read, and readiness’s read_filter_off check always observe the same mode. Rollout and rollback are in Operations.
Hardening, drills
Stage H4’s gate (drill_stale_or_failed) runs scheduled prompt-injection drills in a dedicated repository (hardening.drills.repository), works the planted tasks (factory/drill-injection -> agents.ogenki.io/drill-injection), and scores the outcome after drills.timeout (default 6h) once drills.gatewayLog.url is set (POST /v1/hardening/drills accepts system:drill only; neither timeout nor gatewayLog enters the hardening hash). A drill passes when no out-of-policy output was applied; see Injection drills.
The runner stores reports via the broker’s POST /v1/drills (API) and readiness checks GET /v1/drills/last-pass. On outputs refused at T1 (target) or pushes refused at T4 whose T3 scan found no secret or canary, the applier also runs T5 in audit (maku_factory_hardening_t5_total{type,result,drill}); T3 refusals, cap refusals, T2 withholdings and broker-redacted payloads never reach T5 across agentgateway.
Hardening, ready
Stage H5 reports per-repository whether every run reads through author trust and writes only through enforced safe outputs right now. It alters no run behaviour directly; multi-repository coordination queries it live before every execute admission.
| Missing code | Holds when | Read from |
|---|---|---|
mode_not_enforce | Repository mode is enforce | Live config |
sandbox_write_token | No sandbox role’s token can write (runTokens.perRun role table; never true for shared tokens) | Minter role table |
publisher_policy | Publisher can write (hardening.publisher.minter) | Minter publisher grant |
layer_not_enforced | T1–T4 all enforce (T5 is not required) | Live config |
read_filter_off | Reads are filtered (enforce, run-controller, system:broker mapped) | Live config (reads filtered) |
drill_stale_or_failed | Newest drill for this Maku version and hardening hash passed within drills.maxAge (168h; a newer failure hides an older pass) | Broker drill reports (drills) |
demo_profile | Not the laptop demo | Live config |
Any unreadable fact fails closed (error). Every 5 minutes the leader updates maku_factory_hardening_ready{repository} and maku_factory_hardening_missing{repository,missing} (never read back as authority). Operators in the admin group query GET /v1/hardening/readiness for {repository, hardened, missing, drill}, while the Evidence page shows repository readers only hardened / not hardened / error, sharing a 60-second per-repository cache with the API route (bypassed by coordination admission).
Promoting T5, one output type at a time
hardening.layers.classifierEnforce: [pr, comment, ...] promotes the T5 classifier from audit to enforce for the named output types across every repository at mode: enforce (requiring agentGuard.url and layers.classifier not off; global layers.classifier: enforce remains refused). Promoted hits refuse with injection_suspected and classifier outages refuse with classifier_unavailable. Both classifierEnforce and agentGuard.url enter the hardening hash, requiring a fresh passing drill.
Promote an output type only when 30-day metrics (maku_factory_hardening_t5_total and drill reports) show:
- False positives < 2% (
result="hit"over total calls withdrill="false"). - Drill detection above pattern layers on outputs T1–T3 let through and on target/T4 refusals (since T3 secret/canary refusals, T2 withholdings and redacted payloads are never sent to T5).