security: validate RAW_BASE immediately before curl|bash invocation (#1822)

Fixes #1819

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-23 16:31:53 -08:00 committed by GitHub
parent fccb73d147
commit 0bca426980
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.8.2",
"version": "0.8.3",
"type": "module",
"bin": {
"spawn": "cli.js"

View file

@ -196,6 +196,11 @@ function reExecWithArgs(): void {
function performAutoUpdate(latestVersion: string): void {
printUpdateBanner(latestVersion);
// Validate RAW_BASE immediately before use to prevent command injection (CWE-78, #1819)
if (!GITHUB_RAW_URL_PATTERN.test(RAW_BASE)) {
throw new Error(`Security: RAW_BASE failed pre-execution validation: ${RAW_BASE}`);
}
try {
executor.execSync(`curl -fsSL ${RAW_BASE}/cli/install.sh | bash`, {
stdio: "inherit",