Repository navigation
Scope the test agent's tools and stop trusting the app's output - #32
Conversation
The app under test writes the text the agents read, so the agent's tool grants and the scripts it can reach are trust boundaries. - Android and iOS agents: Read/Write/Edit were unqualified, so the agent could read .git/config and the runner's environment, and write to the workflow's own scripts. Read is now the files the briefs name (AGENT_BRIEF.md, briefs/, personas.json, bug_report.md, results/), writes stay in results/, and cat is narrowed to bug_report.md and results/ — the same shape as the web agent's grant. - The app id read from the APK reaches `adb shell`, which joins its arguments into one command the device shell parses. Refuse an id that is not a package name (scripts/device_state.py already does this check). - Restore scripts/ and results_public.pem before running encrypt_results.sh: the agent (and the app's build code) can write to the workspace, and the encrypt step runs a script by name afterwards. - collect.sh: decrypt to a file, refuse members that escape the output directory or that are symlinks, then extract. - Pass `framework` through env instead of interpolating it into the `run:` body, where a double quote turns it into shell. - Fail closed when results_public.pem is still the template's key: an unset-up clone encrypts to a key the user does not hold. Tests: python3 -m unittest discover -s tests -q (277 passed, 3 skipped), bash -n and shellcheck -S warning on every script, and collect.sh run against a mocked gh with a symlinked archive, a `../` member, and a clean archive.
…sona checkouts; Deutsch in docs language lines; BUILD_ARGS note
|
Thanks, this is a careful audit and the fixes are real. Merged, with a small follow-up: the template key check skips this repo itself (that key is mine, my own runs use it), the two cat rules are gone since Read already covers those files, and the persona checkouts now use persist-credentials: false, because adb push could still copy .git/config to the phone. For BUILD_ARGS I went with option (a): the docs now say not to put long-lived secrets in it. |
Read 22b9f32. The three changes are in the right places. persist-credentials: false is the one that actually closes the token path. I could not close it from the tool grant: adb takes a path as an argument, so Removing the two cat rules is right. Read already covers bug_report.md and results/, and every Bash rule is another surface the app's text can aim at. The template-key exception is safe as written because the workflow only triggers on workflow_dispatch. A fork that dispatches it runs with GITHUB_REPOSITORY set to the fork, so a fork that never ran ./setup.sh still fails closed instead of encrypting to your key. If you ever add a pull_request trigger, that comparison stops being enough, because a fork PR runs in the base repo's context and would carry your name; at that point it needs On BUILD_ARGS I agree with (a). A docs note is the only real control here: nothing in the workflow can keep a value out of the build step's environment when the build command comes from the app's own code. The only enforcement would be to stop passing a long-lived secret there at all. Nothing else from me on this one. The six medium/low findings are still written up in #31. Tell me if you want the mechanical ones as a second PR or would rather have them as a triage list, and I will do that. |
Fixes six of the seven high-severity findings in #31 by mini-ork run: https://console.miniork.dev/r/9XxOuNS1DWUYaEk8zoxM7w. The seventh (
BUILD_ARGSis in the environment of the step that runs the app's own build code) is a design decision and is left alone — say which way you want it and I will follow up.The short version: everything here treats the app under test as untrusted, because that is what it is.
scripts/android/run_agent.sh,scripts/ios/run_agent.sh— the agent's tool grant is now the files the briefs name, not the workspace.ReadandBash(cat:*)reached.git/config(the persona jobs persist the GitHub token there) and/proc/self/environ(the model key), and bareWritecould replacescripts/encrypt_results.sh, which the workflow runs afterwards as the runner. Writes stay inresults/. This matches what the web agent already does (scripts/web/run_agent.sh).scripts/android/run_agent.sh— the package name read from the APK is checked against[A-Za-z0-9._-]+before it reachesadb shell.adb shelljoins its arguments into one string the device shell parses, so a package namedx; idwas a command.scripts/device_state.py:24already has this guard; this is the same rule in the same place it is needed.scripts/collect.sh— the archive is listed before it is extracted; a member with..or an absolute path, or a symlink member, aborts the run with a clear message. The archive is built on runners where the app's build code and the agent can both write intoresults/, so the collector should not assume it is sane..github/workflows/agent-testers.yml— three changes:frameworkgoes throughenv:like every other input instead of being interpolated intorun:. Dispatch rights plus no secret read was previously enough for arbitrary shell in a step that holdsBUILD_ARGSandARTIFACT_PASSPHRASE.results_public.pemis still the template's key. This is the one change that can turn a previously-passing run red: a fork that has never run./setup.shwill now get a clear error instead of silently encrypting to a key someone else holds. If you would rather warn and continue, I will soften it to a::warning::— but the run's results would then be unreadable by the user and readable by whoever holds that key, so I think failing is right.scripts/andresults_public.pemfrom git before the encrypt steps, so a modified script cannot run as the runner even if a grant is widened again later.Test plan
bash -non bothrun_agent.shandcollect.sh.bash scripts/collect.shguard exercised end to end against a mockedgh/opensslwith a canary archive: a../escapemember is refused, a symlink member is refused, a clean archive extracts normally.python3 -c 'import yaml,sys; yaml.safe_load(open(sys.argv[1]))').adb,screen.py,type.py/gesture.sh,sleep,ls,catandmkdir— I listed those.Not in this PR
S3 (
BUILD_ARGSvisible to the app's build code) — your call, options are in #31.Six medium/low findings are also in the issue and not here.