T09 · Insecure Skill Coding Practices
- Location
vercel-config-generator.sh:4- Finding
Unconditional Overwrite of Existing Vercel Configuration
- Content
View full analysis
Vulnerability Details
File Location:
vercel-config-generator.sh, lines 4–14
Vulnerability Type: Destructive file overwrite without confirmation or backup
Risk Level: MediumVulnerable Code
bash cat > vercel.json << 'JSON' { "buildCommand": "npm run build", "outputDirectory": "dist", "framework": null, "functions": { "api/**/*.js": { "runtime": "nodejs18.x" } } } JSONTechnical Analysis
The
>redirection operator createsvercel.jsonor truncates it if it already exists. The script does not check for an existing configuration, request confirmation, create a backup, or write the new content atomically.Consequently, invoking the generator in an existing project silently destroys the project's current Vercel configuration and replaces it with a fixed Serverless configuration. The
TYPEvariable assigned earlier in the script is unused, so supplied deployment-mode arguments do not alter or prevent this behavior.This is an insecure coding practice because a routine generation operation can cause irreversible configuration loss and alter subsequent deployment behavior without adequately informing the operator.
Attack Path
- A user has a project containing a trusted
vercel.jsonwith application-specific routes, headers, runtime settings, or access controls. - The user invokes the generator according to its documented usage, potentially supplying an advertised deployment mode.
- The shell opens the existing
vercel.jsonwith truncation enabled. - The original configuration is discarded and replaced with the hardcoded content.
- A later Vercel deployment uses the unintended configuration, potentially omitting required deployment or security settings.
Exploitation requires the script to run with write access to the project directory. No privilege escalation beyond the invoking user's filesystem permissions was identified.
Imp
...[truncated 669 chars]
- A user has a project containing a trusted
- Remediation
View remediation
Remediation Suggestions
- Check whether
vercel.jsonalready exists and refuse to overwrite it by default. - Require an explicit option such as
--forcebefore replacing an existing file. - Display a clear warning and request confirmation when running interactively.
- Preserve the original file in a timestamped backup before replacement.
- Generate the new configuration in a securely created temporary file, validate it as JSON, and then atomically rename it into place.
- Implement the documented type, framework, and region arguments, or reject unsupported arguments with a nonzero exit status.
- Use strict shell settings and error handling, such as
set -euo pipefail, so failures do not produce incomplete or misleading results.
- Check whether
