T09 · Insecure Skill Coding Practices
- Location
scripts/0xscada.sh:8- Finding
Arbitrary External Project Execution Through Insufficient Directory Validation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/0xscada.sh, lines 8 and 25–36
Vulnerability Type: Untrusted external project execution
Risk Level: Highbash SCADA_DIR="${SCADA_DIR:-$(cd "$SKILL_DIR/../../.." && pwd)}" cmd_start() { if is_running; then echo "0xSCADA already running on $BASE_URL" return 0 fi # Security validation: Ensure we are running the actual 0xSCADA project if [[ ! -f "$SCADA_DIR/server/index.ts" || ! -f "$SCADA_DIR/package.json" ]]; then echo "Error: SCADA_DIR ($SCADA_DIR) does not appear to contain the 0xSCADA project." echo "Expected to find server/index.ts and package.json." echo "Please set the SCADA_DIR environment variable to the correct 0xSCADA repository root." exit 1 fi echo "Starting 0xSCADA from $SCADA_DIR..." cd "$SCADA_DIR" npm run dev &Technical Analysis
The script accepts
SCADA_DIRfrom an environment variable and uses it as the working directory fornpm run dev. Its validation only verifies thatserver/index.tsandpackage.jsonexist. These filename checks do not establish repository identity, integrity, ownership, trustworthiness, or whether the selected directory is within an approved path.An attacker who can influence
SCADA_DIRor control the referenced directory can create the two expected files and define an arbitrarydevlifecycle script inpackage.json. The subsequentnpm run devcommand then executes that attacker-controlled script with the privileges and environment of the user running the skill.This is not shell metacharacter injection through
SCADA_DIR, because the variable is quoted. The vulnerability instead arises from treating an insufficiently authenticated external project and its package script as trusted executable code.Attack Path
- The attacker creates or controls a directory accessible to the skill.
- The attacker places a
server/index.tsfile in that directory. - The attacker creates a `package.jso ...[truncated 1442 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not execute package scripts from an environment-selected, unauthenticated directory.
- Bundle the required server implementation with the reviewed artifact where practical, or configure an administrator-controlled canonical path that ordinary callers cannot override.
- Resolve the selected path with
realpathand verify that it is located beneath an explicitly approved root directory. - Verify repository identity and integrity before execution, such as by pinning an expected commit or release and validating cryptographic hashes or signatures.
- Validate trusted ownership and permissions on the repository,
package.json, relevant source files, and parent directories. Reject locations writable by untrusted users. - Do not rely only on the existence of expected filenames. Validate expected package identity and ensure the invoked command is fixed and reviewed.
- Prefer invoking a specific audited executable with fixed arguments instead of running a mutable npm lifecycle script.
- Remove or tightly restrict the
SCADA_DIRenvironment override. If configurability is necessary, require explicit administrator approval during setup rather than accepting it at every invocation. - Run the external service with least privilege, a minimal environment, restricted filesystem access, and constrained network permissions.
- Require clear user confirmation before executing code from any repository outside the audited skill package.
