-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Security Issue
Severity: CRITICAL
File: packages/cli/src/aws/aws.ts:329
Function: lightsailRest()
Description
The AWS SigV4 signing implementation constructs HMAC keys by directly concatenating the awsSecretAccessKey into the signing key derivation:
const kDate = hmac(`AWS4${awsSecretAccessKey}`, dateStamp);While AWS secret keys are under user control, the lack of validation before HMAC operations creates a potential injection vector if an attacker can control the AWS_SECRET_ACCESS_KEY environment variable (e.g., via a compromised config file at ~/.config/spawn/aws.json).
Impact
If an attacker controls the secret access key value, they could potentially:
- Inject crafted binary sequences into the HMAC computation
- Manipulate the signing process via control characters
- Bypass authentication checks if the HMAC library has unexpected behavior with malformed input
Evidence
Location: packages/cli/src/aws/aws.ts:329
const kDate = hmac(`AWS4${awsSecretAccessKey}`, dateStamp);
const kRegion = hmac(kDate, region);
const kService = hmac(kRegion, service);
const kSigning = hmac(kService, "aws4_request");The awsSecretAccessKey is loaded from:
- Environment variable
AWS_SECRET_ACCESS_KEY(line 516) - Config file
~/.config/spawn/aws.json(line 72)
The loadCredsFromConfig() function validates length (>= 16 chars) but not format (line 79).
Recommendation
Add strict validation for AWS secret access key format before using it in cryptographic operations:
// At line 516 or in loadCredsFromConfig()
function validateAwsSecretKey(key: string): boolean {
// AWS secret access keys are 40 characters: A-Za-z0-9/+=
return /^[A-Za-z0-9/+=]{40}$/.test(key);
}
// Before HMAC operations (line 329)
if (!validateAwsSecretKey(awsSecretAccessKey)) {
throw new Error("Invalid AWS secret access key format");
}This prevents injection of control characters, newlines, or other unexpected data into the HMAC signing process.
References
- AWS Secret Access Key format: 40 alphanumeric characters +
/,+,= - OWASP: Input Validation
- Related: Issue security: GITHUB_TOKEN validation missing control character checks #2239 (GITHUB_TOKEN validation)
Discovered: Automated security scan of files modified in last 24 hours
Scan Date: 2026-03-16