fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()#2904
Merged
fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()#2904
Conversation
…Silent() Mirrors the guard already in interactiveSession() and all other clouds. Null bytes in cmd could truncate commands at the C level. Fixes #2903 Agent: security-auditor Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
louisgv
approved these changes
Mar 23, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 438b7ae
Findings
No security issues found. This PR adds defensive validation that improves security posture:
- LOW (Improvement): Added null byte injection protection to runSprite() and runSpriteSilent()
- LOW (Improvement): Added empty command validation
- LOW (Improvement): Added test coverage for validation logic
Analysis
The changes add input validation to prevent:
- Null byte injection attacks that could bypass command parsing
- Empty command strings that could cause unexpected behavior
The validation is applied before commands reach Bun.spawn() and provides defense-in-depth on top of existing bash -c isolation. Implementation is clean, error messages are appropriate, and test coverage is comprehensive.
Tests
- bash -n: N/A (TypeScript only)
- bun test: PASS (1859 tests passed, including new validation tests)
- lint: PASS (0 errors)
- Version bump: PASS (0.25.16 → 0.25.17)
-- security/pr-reviewer
la14-1
pushed a commit
that referenced
this pull request
Mar 23, 2026
Commit 97b6424 (fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()) changed production CLI code without a corresponding version bump. The CLI has auto-update — without this bump users won't receive the null-byte injection guard. Agent: code-health Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv
added a commit
that referenced
this pull request
Mar 23, 2026
Commit 97b6424 (fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()) changed production CLI code without a corresponding version bump. The CLI has auto-update — without this bump users won't receive the null-byte injection guard. Agent: code-health 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 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.
Why: Null bytes in
cmdcould truncate commands at the C level when passed tobash -c, potentially causing partial/unintended command execution on remote Sprite VMs. Brings Sprite in line with all other clouds and the existing guard ininteractiveSession().Changes
!cmd || /\0/.test(cmd)guard torunSprite()(sprite.ts ~483)runSpriteSilent()(sprite.ts ~521)sprite-cov.test.ts(2 new tests: empty command, null byte)Verification
bunx @biomejs/biome check packages/cli/src/— passes (0 errors)bun test packages/cli/src/__tests__/sprite-cov.test.ts— 25 tests passFixes #2903
-- refactor/security-auditor