spawn/cli/src
A 9acc239001
fix: validate token characters in _load_token_from_config to prevent curl injection (#1547)
* fix: validate token characters in _load_token_from_config to prevent curl injection

Tokens loaded from ~/.config/spawn/{cloud}.json were exported without
character validation. A tampered config file containing a token with
embedded newlines could exploit the _curl_api function's -K - (stdin
config) mechanism to inject arbitrary curl directives (e.g., output,
url), since curl interprets newlines in the config format as directive
separators.

Add allowlist validation (^[a-zA-Z0-9._/@:-]+$) matching the pattern
already used in key-request.sh _try_load_env_var and validate_api_token,
making all three token-loading paths consistent.

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address review feedback on token validation PR

- Update backslash test to expect validation failure (backslashes not
  valid in any known API token format; the old expectation was wrong
  after validation was added)
- Fix test so exit code comes from _load_token_from_config directly,
  not the trailing echo which always exits 0
- Add comment in shared/common.sh explaining why the pattern includes
  colon vs key-request.sh pattern (Fly.io FlyV1 tokens use colons)

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address review feedback — widen token charset for base64 segments

The original regex rejected + and = which are valid base64 characters
found in API tokens (e.g. sk-or-v1-abc/def+ghi==). This caused a
pre-existing test to fail. Widen the allowlist to include + and =
while keeping the security comment documenting the pattern difference
with key-request.sh.

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21 01:18:34 -05:00
..
__tests__ fix: validate token characters in _load_token_from_config to prevent curl injection (#1547) 2026-02-21 01:18:34 -05:00
commands.ts fix: use destroy_server for sprite delete to support org users (#1538) 2026-02-20 19:34:58 -05:00
guidance-data.ts refactor: extract error guidance data structures into separate module (#1335) 2026-02-16 19:45:28 -08:00
history.ts fix: unbreak spawn delete and align error handling conventions (#1534) 2026-02-20 18:17:29 -05:00
index.ts fix: deduplicate isInteractiveTTY and remove dead OVH env wrapper (#1457) 2026-02-19 01:54:47 -05:00
manifest.ts fix: unbreak spawn delete and align error handling conventions (#1534) 2026-02-20 18:17:29 -05:00
picker.ts feat: add spawn pick command and interactive GCP project/zone/machine-type pickers (#1443) 2026-02-18 11:30:52 -05:00
security.ts fix: unbreak spawn delete and align error handling conventions (#1534) 2026-02-20 18:17:29 -05:00
unicode-detect.ts fix: Switch build target from node to bun to fix UTF-8 mojibake 2026-02-10 09:36:28 +00:00
update-check.ts fix: validate RAW_BASE URL in update-check to prevent future injection (#1533) 2026-02-20 12:52:02 -05:00