T09 · Insecure Skill Coding Practices
- Location
nas-download.sh:23- Finding
Remote Shell Command Injection Through Magnet URI Input
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This NAS download skill does what it claims, but its shell script handles remote commands and credentials unsafely enough that users should review it before installing.
Install only if you are comfortable reviewing and fixing the shell script first. Move the qBittorrent password out of the script, avoid admin credentials, quote or redesign the SSH/curl calls so magnet links cannot become shell syntax, use private temporary files with cleanup, and require explicit confirmation before adding downloads or copying torrent files to the NAS.
nas-download.sh:23Remote Shell Command Injection Through Magnet URI Input
nas-download.sh:4Plaintext qBittorrent Password Storage and Command-Line Exposure
nas-download.sh:14Predictable Shared Temporary Files Expose Session and Torrent Data
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
case "$1" in
list)
if [[ "$2" == "-all" ]]; then
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data]"
else
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data if t['progress'] < 1.0]"
fi
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
case "$1" in
list)
if [[ "$2" == "-all" ]]; then
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data]"
else
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data if t['progress'] < 1.0]"
fi
The skill declares shell tool usage but does not constrain tool scope with explicit permissions or allowed-tools metadata. In a skill that can invoke a shell script to manage NAS downloads over SSH, this increases the chance of unintended command execution or broader-than-necessary access if the agent or surrounding platform grants shell capabilities implicitly.
The documentation explains how to add magnet links and torrent files but does not clearly warn that doing so will immediately initiate downloads and change the state of the user's NAS. This can lead to unintended system modification, bandwidth consumption, storage usage, or policy/legal issues if a user invokes the skill without understanding the side effects.
The skill documentation tells users to configure credential-related values, including a qBittorrent password and SSH connection details, without any warning about secure secret storage or handling. This encourages placement of sensitive credentials in script variables or skill files where they may be exposed through logs, backups, permissions misconfiguration, or accidental sharing.
The script embeds a qBittorrent administrative password directly in source code and uses it silently during remote operations. Hardcoded credentials are dangerous because they can be disclosed through source distribution, logs, backups, or local inspection, enabling unauthorized access to the NAS downloader service.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
case "$1" in
list)
if [[ "$2" == "-all" ]]; then
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data]"
else
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data if t['progress'] < 1.0]"
fi
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
case "$1" in
list)
if [[ "$2" == "-all" ]]; then
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data]"
else
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie >/dev/null && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie http://localhost/api/v2/torrents/info" | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f\"{t['name'][:60]:60} {t['state']:12} {t['progress']*100:5.1f}% {t['dlspeed']/1024/1024:6.1f}MB/s\") for t in data if t['progress'] < 1.0]"
fi
The skill performs remote SSH, SCP, and qBittorrent API actions without any explicit warning, approval step, or dry-run mode. In this skill context, network transmission and remote state changes are expected, but the lack of disclosure and confirmation makes accidental remote actions and unintended file transfer more likely.
The add operation inserts untrusted user input directly into a single-quoted remote shell command: -d 'urls=$2' inside the SSH command string. A magnet value containing a single quote can break quoting and inject arbitrary commands on the NAS, turning an expected API request into remote command execution.
;;
add)
if [[ "$2" =~ ^magnet: ]]; then
ssh $NAS_HOST "curl -s --unix-socket $QBT_SOCK -X POST http://localhost/api/v2/auth/login -d 'username=admin&password=$QBT_PASSWORD' -c /tmp/qbt_cookie && curl -s --unix-socket $QBT_SOCK -b /tmp/qbt_cookie -X POST http://localhost/api/v2/torrents/add -d 'urls=$2'"
echo "Magnet link added"
elif [[ -f "$2" ]]; then
scp "$2" $NAS_HOST:/tmp/torrent.tmp
The implementation exceeds the stated capability by accepting a local file path, copying that file to the NAS, and uploading it to qBittorrent, while the manifest only discloses magnet-link handling. This is dangerous because it broadens data access and exfiltration behavior beyond user expectations, increasing the chance that a local sensitive file is transmitted to the remote host without informed consent.