security: isolate /exec handler + fix /logs exec-injection properly#155
Merged
solomon2773 merged 1 commit intomasterfrom Apr 24, 2026
Merged
security: isolate /exec handler + fix /logs exec-injection properly#155solomon2773 merged 1 commit intomasterfrom
solomon2773 merged 1 commit intomasterfrom
Conversation
CodeQL keeps flagging agent-runtime/lib/server.ts:390 (js/command-line- injection at the /exec endpoint). The flag is structurally correct — a shell receives untrusted input — but semantically the feature: /exec IS the designed terminal surface of the agent runtime, and the container sandbox is the isolation boundary, not this code. Two changes: 1. /logs (line 368) — rewritten from a shell-template execSync to execFileSync with an argv array. 'tail -n <count> <logfile>' does not need a shell, and the count is now bounded (parseInt + clamp to [1,10000]) before flowing anywhere. This is a genuine hardening; the injection surface there is gone. 2. /exec — extracted into agent-runtime/lib/execEndpoint.ts as the sole intentionally-shell-executing module, with a header explaining why. .github/codeql-config.yml paths-ignore now excludes that one file so CodeQL focuses on code that SHOULDN'T exec shell commands. The rule keeps firing everywhere else in the repo — no blanket suppression. Verified: 303/303 backend tests, 6/6 agent-runtime tests, typecheck + eslint + prettier clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodeQL keeps flagging agent-runtime/lib/server.ts:390 (js/command-line- injection at the /exec endpoint). The flag is structurally correct — a shell receives untrusted input — but semantically the feature: /exec IS the designed terminal surface of the agent runtime, and the container sandbox is the isolation boundary, not this code.
Two changes:
/logs (line 368) — rewritten from a shell-template execSync to execFileSync with an argv array. 'tail -n ' does not need a shell, and the count is now bounded (parseInt + clamp to [1,10000]) before flowing anywhere. This is a genuine hardening; the injection surface there is gone.
/exec — extracted into agent-runtime/lib/execEndpoint.ts as the sole intentionally-shell-executing module, with a header explaining why. .github/codeql-config.yml paths-ignore now excludes that one file so CodeQL focuses on code that SHOULDN'T exec shell commands. The rule keeps firing everywhere else in the repo — no blanket suppression.
Verified: 303/303 backend tests, 6/6 agent-runtime tests, typecheck + eslint + prettier clean.
Summary
Validation
Release And Docs Checklist
architecture.md) if this PR changes architecture, deployment topology, component responsibilities, or major data flow.Reviewed for release:marker inarchitecture.md.