Skip to content

fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()#2904

Merged
louisgv merged 2 commits intomainfrom
fix/issue-2903
Mar 23, 2026
Merged

fix(security): add cmd validation to Sprite runSprite() and runSpriteSilent()#2904
louisgv merged 2 commits intomainfrom
fix/issue-2903

Conversation

@la14-1
Copy link
Member

@la14-1 la14-1 commented Mar 23, 2026

Why: Null bytes in cmd could truncate commands at the C level when passed to bash -c, potentially causing partial/unintended command execution on remote Sprite VMs. Brings Sprite in line with all other clouds and the existing guard in interactiveSession().

Changes

  • Added !cmd || /\0/.test(cmd) guard to runSprite() (sprite.ts ~483)
  • Added same guard to runSpriteSilent() (sprite.ts ~521)
  • Added test coverage in sprite-cov.test.ts (2 new tests: empty command, null byte)
  • Bumped CLI version 0.25.16 → 0.25.17

Verification

  • bunx @biomejs/biome check packages/cli/src/ — passes (0 errors)
  • bun test packages/cli/src/__tests__/sprite-cov.test.ts — 25 tests pass

Fixes #2903

-- refactor/security-auditor

…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>
Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Null byte injection attacks that could bypass command parsing
  2. 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

@louisgv louisgv merged commit 97b6424 into main Mar 23, 2026
6 of 7 checks passed
@louisgv louisgv deleted the fix/issue-2903 branch March 23, 2026 10:30
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>
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.

fix(security): add missing cmd validation to Sprite runSprite() and runSpriteSilent()

2 participants