Skip to content

security: isolate /exec handler + fix /logs exec-injection properly#155

Merged
solomon2773 merged 1 commit intomasterfrom
fix/codeql-exec-endpoint-isolation
Apr 24, 2026
Merged

security: isolate /exec handler + fix /logs exec-injection properly#155
solomon2773 merged 1 commit intomasterfrom
fix/codeql-exec-endpoint-isolation

Conversation

@solomon2773
Copy link
Copy Markdown
Owner

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 ' 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.

Summary

  • Describe the user-visible or maintainer-visible change.

Validation

  • List the commands, tests, or manual checks you ran.

Release And Docs Checklist

  • Updated public architecture docs (architecture.md) if this PR changes architecture, deployment topology, component responsibilities, or major data flow.
  • If this is a release-prep PR, updated the Reviewed for release: marker in architecture.md.

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>
@solomon2773 solomon2773 merged commit f9a362c into master Apr 24, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants