T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:159
- Finding
- Unvalidated Remote Bootnode Data Is Injected into an Executable Shell Script<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 159-198 **Vulnerability Type**: Command and script injection through untrusted remote configuration **Risk Level**: High ### Vulnerable Code ```bash # Fetch official bootnode pinned to release tag (immutable reference) REPO="ProbeChain/Rydberg-Mainnet" RELEASE_TAG=$(curl -sSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | head -1 | cut -d'"' -f4) ENODE=$(curl -sSL "https://raw.githubusercontent.com/${REPO}/${RELEASE_TAG}/bootnodes.txt" | head -1) cat > ~/rydberg-agent/start-bg.sh << 'SCRIPT' #!/usr/bin/env bash cd ~/rydberg-agent ./gprobe \ --datadir ./data \ --networkid 8004 \ --port 30398 \ --http --http.addr 127.0.0.1 --http.port 8549 \ --http.api "probe,net,web3,pob,txpool" \ --http.corsdomain "http://localhost:*" \ --consensus pob \ --miner.probebase ADDR_PLACEHOLDER \ --password ./password.txt \ --ipcpath ~/rydberg-agent/gprobe.ipc \ --bootnodes "ENODE_PLACEHOLDER" \ --verbosity 3 > node.log 2>&1 & ./gprobe attach ~/rydberg-agent/gprobe.ipc --exec "admin.addPeer('ENODE_PLACEHOLDER')" 2>/dev/null SCRIPT sed -i.bak "s|ADDR_PLACEHOLDER|$ADDR|g; s|ENODE_PLACEHOLDER|$ENODE|g" ~/rydberg-agent/start-bg.sh rm -f ~/rydberg-agent/start-bg.sh.bak chmod +x ~/rydberg-agent/start-bg.sh ``` ### Technical Analysis The first line of the remotely hosted `bootnodes.txt` file is assigned to `ENODE` and substituted directly into an executable shell script using `sed`. The value is not validated against the expected enode URI syntax and is not escaped for either of the contexts in which it is embedded: 1. A double-quoted shell argument to `--bootnodes`. 2. A quoted JavaScript expression supplied to the local IPC console. Although the URL uses HTTPS and references a release tag, the tag and repository remain under upstream control. A release tag is not necessarily an immutable commit. If the repository, maintainer account, tag, or retrieved file ...[truncated 1518 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Validate `ENODE` against the complete expected enode URI grammar before using it. Reject whitespace, newlines, control characters, quotes, shell metacharacters, and unexpected URI parameters. 2. Do not generate executable source code through textual placeholder replacement. 3. Pass validated values as arguments or environment variables using shell arrays and strict quoting. 4. If replacement is unavoidable, escape all characters meaningful to both `sed` and the destination context. 5. Pin `bootnodes.txt` to an audited immutable commit hash rather than a mutable release tag. 6. Verify the file against a digest embedded in the reviewed Skill or a signature validated with an independently trusted public key. 7. Enable strict shell behavior such as `set -euo pipefail` and make failed or empty downloads abort deployment. 8. Use `curl --fail --show-error --location` and reject unexpected response content. ]]>
