T07 · Tool Hijacking and Spoofing
- Location
summarize.sh:10- Finding
Working-Directory Helper Script Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
summarize.sh, line 10
Vulnerability Type: Untrusted helper-script resolution
Risk Level: HighVulnerable Code:
bash ./extract.sh "$RSS_FILE"Technical Analysis
The script invokes
extract.shrelative to the process's current working directory rather than relative to the installed location ofsummarize.sh. This conflicts with the documented ability to run the skill from any path.Consequently,
./extract.shcan resolve to an attacker-supplied executable in the directory from which the user launches the genuinesummarize.sh. Quoting"$RSS_FILE"protects the RSS argument from shell word splitting but does not protect the helper executable's path.Attack Path
- An attacker creates or controls a directory that the victim will use as the current working directory.
- The attacker places an executable named
extract.shin that directory and embeds arbitrary shell commands in it. - The victim invokes the genuine
summarize.shby its absolute or relative path while remaining in the attacker-controlled directory. - The RSS file check succeeds for the supplied input or a local
news.rss. - At line 10,
summarize.shexecutes the attacker's./extract.shinstead of the helper shipped with the skill. - The malicious commands run with the invoking user's privileges.
Impact Assessment
Successful exploitation provides arbitrary command execution under the account running the skill. The attacker can access, modify, or delete data available to that user; execute additional local programs; and perform network or persistence actions permitted by the user's privileges. The flaw does not independently elevate privileges beyond those already held by the invoking process, so its scope is limited by that account's permissions.
- Remediation
View remediation
Remediation Suggestions
Resolve the helper relative to the directory containing
summarize.sh, not the current working directory:bash #!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" RSS_FILE="${1:-news.rss}" if [[ ! -f "$RSS_FILE" ]]; then printf 'RSS file not found: %s\n' "$RSS_FILE" >&2 exit 1 fi printf '%s\n' 'News highlights (first 10):' "$SCRIPT_DIR/extract.sh" "$RSS_FILE"Additionally:
- Ensure the packaged
extract.shis owned by a trusted account and is not writable by untrusted users. - Preserve argument quoting and use
--with supporting utilities where appropriate. - Add a regression test that launches
summarize.shfrom a directory containing a decoyextract.shand verifies that the packaged helper is used. - Consider validating that the resolved helper is a regular executable file before invoking it.
- Ensure the packaged
