fix: block newlines in installer Bash allowlist#198
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix: block newlines in installer Bash allowlist#198devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
The installer agent's Bash permission gate (installerCanUseTool) blocked ; ` $ ( ) | and & but not newlines. The shell treats a newline as a command separator equivalent to ;, and matchesAllowedPrefix splits on \s+ (which matches \n), so a payload like 'npm install\n<arbitrary command>' passed validation and both statements executed. This let poisoned project content drive arbitrary command execution and exfiltration of the WORKOS_API_KEY the installer writes to .env.local just before the agent runs. Add \n and \r to DANGEROUS_OPERATORS so any command containing a newline/carriage return is denied, and cover the bypass with regression tests.
Contributor
Author
Original prompt from Linear User
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR blocks newline-based command injection in the installer Bash allowlist. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: block newlines in installer Bash al..." | Re-trigger Greptile |
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.
Summary
Automated first-pass fix for SEC-1361. Requires human security review before merge.
installerCanUseTool()insrc/lib/agent-interface.tsis the sole sandbox constraining Bash commands theworkos installagent runs over untrusted project content. It denied;`$()|and&, but itsDANGEROUS_OPERATORSchar class omitted newline/carriage return — which the shell treats as a command separator equivalent to;. Combined withmatchesAllowedPrefix()splitting on/\s+/(which matches\n), a payload like:was validated only on its first token (
npm→install), returned{ behavior: 'allow' }, and the shell then executed both lines. Because the installer writesWORKOS_API_KEY/WORKOS_CLIENT_IDinto.env.local(configureEnvironment) immediately before the agent phase (runAgent), a poisoned repo could drive arbitrary command execution and exfiltrate the freshly-written credentials.Change
Any command containing a newline or carriage return is now denied before allowlist matching. Adds regression tests in
agent-interface.spec.tscovering the newline and carriage-return bypasses plus a negative control (plainnpm install/pnpm run buildstill allowed).Validation
pnpm test(agent-interface.spec.ts, 22 passing),pnpm typecheck,pnpm lint,pnpm format:checkall pass.allowand a shell executed the injectedcurl, uploading a fake.env.localto a localhost collector. Post-fix the gate returnsdeny.Follow-ups (not addressed here — left for human triage)
The finding also flags two compounding weaknesses that this minimal fix does not close: non-Bash tools (
Write/Edit) are allowed unconditionally with no path scoping, andmatchesAllowedPrefixuses loosestartsWithmatching. These warrant separate, more considered changes.Link to Devin session: https://app.devin.ai/sessions/0c519650c20041f5b32644abdcf9eafa