Uh oh!
There was an error while loading. Please reload this page.
security: consolidate shellQuote and null-byte validation across all clouds - #2535
Merged
Conversation
louisgv
approved these changes
Mar 12, 2026
louisgv
left a comment
Collaborator
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: a71faf1
Summary
This PR consolidates shell quoting and null-byte validation across all cloud providers. It moves shellQuote from gcp/gcp.ts to shared/ui.ts and applies it consistently across AWS, DigitalOcean, Hetzner, GCP, and the connect command.
Findings
No security issues found. This is a positive security improvement.
Security improvements:
- ✅ Centralized
shellQuote()function eliminates inconsistent escaping - ✅ Added null-byte validation at all command entry points (
runServer,interactiveSession) - ✅ Replaced ad-hoc quote escaping with centralized function
- ✅ Applied defense-in-depth (null-byte checks at entry point + in shellQuote)
- ✅ Environment variable generation now uses
shellQuote()instead of inline escaping
Changed files:
packages/cli/src/shared/ui.ts— AddedshellQuote()exportpackages/cli/src/shared/agents.ts— UsesshellQuote()for env vars, added null-byte checkpackages/cli/src/aws/aws.ts— Added null-byte validation, usesshellQuote()packages/cli/src/digitalocean/digitalocean.ts— Added null-byte validation, usesshellQuote()packages/cli/src/hetzner/hetzner.ts— Added null-byte validation, usesshellQuote()packages/cli/src/gcp/gcp.ts— Re-exportsshellQuote()from shared/uipackages/cli/src/commands/connect.ts— UsesshellQuote()for SSH commands
Tests
- ✅ bun test: PASS (1400/1400 tests)
- ✅ biome lint: PASS (117 files, 0 issues)
- ✅ null-byte validation: Present in all entry points
- ✅ shellQuote coverage: Test exists at
__tests__/gcp-shellquote.test.ts
Risk Assessment
Risk level: NONE — This is a hardening change that improves security posture.
-- security/pr-reviewer
PR #2533 hardened GCP with shellQuote() and null-byte rejection, but left Hetzner, DigitalOcean, AWS, and connect.ts using inline .replace(/'/g, "'\\''") without null-byte validation. - Move shellQuote to shared/ui.ts as the single source of truth - Add null-byte validation to runServer in Hetzner, DO, and AWS - Replace inline shell escaping with shellQuote in interactiveSession across all clouds, connect.ts, and agents.ts buildEnvBlock - Re-export shellQuote from gcp.ts for backwards compatibility Agent: security-auditor Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgvforce-pushed
the
security/consolidate-shellquote
branch
from
March 12, 2026 16:52
a71faf1 to
7d0ae37CompareUh oh!
There was an error while loading. Please reload this page.
2 tasks
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 12, 2026
…OpenRouterLabs#2535) PR OpenRouterLabs#2533 hardened GCP with shellQuote() and null-byte rejection, but left Hetzner, DigitalOcean, AWS, and connect.ts using inline .replace(/'/g, "'\\''") without null-byte validation. - Move shellQuote to shared/ui.ts as the single source of truth - Add null-byte validation to runServer in Hetzner, DO, and AWS - Replace inline shell escaping with shellQuote in interactiveSession across all clouds, connect.ts, and agents.ts buildEnvBlock - Re-export shellQuote from gcp.ts for backwards compatibility Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
la14-1 pushed a commit
that referenced
this pull request
Mar 13, 2026
Dead backwards-compat re-export left over from the shellQuote consolidation (PRs #2533, #2535, #2546). Zero consumers import shellQuote from gcp/gcp.ts — all correctly import from shared/ui.ts. Per CLAUDE.md: avoid backwards-compatibility hacks; delete unused code. Agent: code-health Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…OpenRouterLabs#2535) PR OpenRouterLabs#2533 hardened GCP with shellQuote() and null-byte rejection, but left Hetzner, DigitalOcean, AWS, and connect.ts using inline .replace(/'/g, "'\\''") without null-byte validation. - Move shellQuote to shared/ui.ts as the single source of truth - Add null-byte validation to runServer in Hetzner, DO, and AWS - Replace inline shell escaping with shellQuote in interactiveSession across all clouds, connect.ts, and agents.ts buildEnvBlock - Re-export shellQuote from gcp.ts for backwards compatibility Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv added a commit
that referenced
this pull request
Mar 13, 2026
Dead backwards-compat re-export left over from the shellQuote consolidation (PRs #2533, #2535, #2546). Zero consumers import shellQuote from gcp/gcp.ts — all correctly import from shared/ui.ts. Per CLAUDE.md: avoid backwards-compatibility hacks; delete unused code. Agent: code-health Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
5 tasks
louisgv added a commit
that referenced
this pull request
Mar 13, 2026
Dead backwards-compat re-export left over from the shellQuote consolidation (PRs #2533, #2535, #2546). Zero consumers import shellQuote from gcp/gcp.ts — all correctly import from shared/ui.ts. Per CLAUDE.md: avoid backwards-compatibility hacks; delete unused code. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
AhmedTMM pushed a commit
to AhmedTMM/spawn
that referenced
this pull request
Mar 13, 2026
…OpenRouterLabs#2535) PR OpenRouterLabs#2533 hardened GCP with shellQuote() and null-byte rejection, but left Hetzner, DigitalOcean, AWS, and connect.ts using inline .replace(/'/g, "'\\''") without null-byte validation. - Move shellQuote to shared/ui.ts as the single source of truth - Add null-byte validation to runServer in Hetzner, DO, and AWS - Replace inline shell escaping with shellQuote in interactiveSession across all clouds, connect.ts, and agents.ts buildEnvBlock - Re-export shellQuote from gcp.ts for backwards compatibility Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <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 freeto 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.
Why: PR #2533 hardened GCP's shell escaping with
shellQuote()(null-byte rejection + POSIX single-quote escaping), but left Hetzner, DigitalOcean, AWS, andconnect.tsusing inline.replace(/'/g, "'\\''")without null-byte validation. A null byte in a command string could cause truncation at the C/OS level, potentially bypassing shell escaping. This closes the defense-in-depth gap across all cloud providers.Changes
Shared infrastructure
shared/ui.ts— AddedshellQuote()as the canonical shared implementationgcp/gcp.ts— Replaced localshellQuotedefinition with import + re-export fromshared/ui.tsNull-byte validation added to
runServer()hetzner/hetzner.ts— Added!cmd || /\0/.test(cmd)guarddigitalocean/digitalocean.ts— Added!cmd || /\0/.test(cmd)guardaws/aws.ts— Added!cmd || /\0/.test(cmd)guard + replaced inline.replace()withshellQuote()Inline shell escaping replaced with
shellQuote()ininteractiveSession()hetzner/hetzner.ts— Null-byte validation +shellQuote(cmd)digitalocean/digitalocean.ts— Null-byte validation +shellQuote(cmd)aws/aws.ts— Null-byte validation +shellQuote(cmd)Additional hardening
commands/connect.ts— Replaced inline.replace()withshellQuote()shared/agents.tsbuildEnvBlock()— Added null-byte rejection for env var values + replaced inline escaping withshellQuote()Tests & version
__tests__/gcp-shellquote.test.ts— Updated import toshared/ui.tspackage.json— Patch bump0.16.17→0.16.18Verification
bunx @biomejs/biome check src/— 0 errorsbun test— 1400 pass, 0 fail-- refactor/security-auditor