T09 · Insecure Skill Coding Practices
- Location
SKILL.md:43- Finding
Predictable Temporary File Allows Local File Overwrite and Data Exposure
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 43–45
Vulnerability Type: Unsafe temporary-file handling
Risk Level: MediumVulnerable Code
bash jq -n --arg token "$TOKEN" --arg query "$USER_QUERY" '{token: $token, query: $query}' | curl -s -X POST https://wendao-skill-prod.ctrip.com/skill/query -H "Content-Type: application/json" -d @- > /tmp/wendao-result.md cat /tmp/wendao-result.mdTechnical Analysis
The documented command writes the remote API response to the fixed and predictable path
/tmp/wendao-result.mdusing ordinary shell redirection. It does not securely create the file, check its ownership or type, enforce restrictive permissions, or remove it afterward.On systems where
/tmpis shared among users, another local user can pre-create this path as a symbolic link. Shell redirection will normally follow that link and truncate the linked destination if the skill's process has permission to write it. Concurrent invocations can also overwrite or read one another's results. In addition, the response—which may contain user travel queries, itineraries, booking recommendations, or other contextual information—can remain on disk after execution.The API token is passed in the request body through a pipe and is not written to this result file by the shown command. The confirmed exposure concerns the API response and the unsafe file-write primitive, not direct token persistence.
Attack Path
- An attacker with local access predicts the documented output path
/tmp/wendao-result.md. - Before the skill runs, the attacker creates that path as a symbolic link to another file writable by the account executing the skill.
- The user invokes the skill and the shell evaluates the output redirection.
- The shell follows the symbolic link and truncates or replaces the target with the API response.
- Alternatively, the attacker monitors or races access to the predictable file to obt ...[truncated 1019 chars]
- An attacker with local access predicts the documented output path
- Remediation
View remediation
Remediation Suggestions
Prefer processing or displaying the response directly without storing it in a temporary file:
bash jq -n --arg token "$TOKEN" --arg query "$USER_QUERY" \ '{token: $token, query: $query}' | curl --fail-with-body --silent --show-error \ -X POST 'https://wendao-skill-prod.ctrip.com/skill/query' \ -H 'Content-Type: application/json' \ --data-binary @-If temporary storage is required:
- Apply
umask 077before creating the file. - Create a unique file with
mktemprather than using a fixed name. - Check that temporary-file creation succeeds.
- Quote the generated path in every command.
- Install a trap that deletes the file on normal exit and interruption.
- Do not reuse temporary files across requests.
- Avoid logging the token or sensitive response content.
Example:
bash umask 077 result_file="$(mktemp "${TMPDIR:-/tmp}/wendao-result.XXXXXX")" || exit 1 trap 'rm -f -- "$result_file"' EXIT HUP INT TERM jq -n --arg token "$TOKEN" --arg query "$USER_QUERY" \ '{token: $token, query: $query}' | curl --fail-with-body --silent --show-error \ -X POST 'https://wendao-skill-prod.ctrip.com/skill/query' \ -H 'Content-Type: application/json' \ --data-binary @- > "$result_file" || exit 1 cat -- "$result_file"- Apply
