T09 · Insecure Skill Coding Practices
- Location
SKILL.md:69- Finding
Predictable Temporary Files Expose Image Data and Enable Symlink Attacks
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 69-80
Vulnerability Type:T09: Insecure Skill Coding Practices
Risk Level: MediumThe documented local-image workflow stores the complete base64-encoded image and JSON request body at fixed locations in the shared
/tmpdirectory.bash base64 < /absolute/path/to/image.jpg | tr -d '\n' > /tmp/food_image.b64Build payload:
bash printf '{"image_base64":"' > /tmp/food_image.json cat /tmp/food_image.b64 >> /tmp/food_image.json printf '"}' >> /tmp/food_image.jsonTechnical Analysis
The workflow uses predictable filenames without secure file creation, ownership validation, restrictive permissions, or cleanup. Shell redirection follows symbolic links. An attacker with access to the shared temporary directory can therefore create
/tmp/food_image.b64or/tmp/food_image.jsonas a symbolic link before the workflow runs.If a targeted link points to a file writable by the invoking user, the redirection can overwrite or corrupt that file using the invoking user's privileges. The files may also be created with permissions derived from the user's current
umask; a permissive configuration could make the encoded image readable by other local users. Both temporary files remain on disk after the API call and retain the complete submitted image.Attack Path
- A local attacker predicts the documented filenames.
- The attacker creates
/tmp/food_image.b64or/tmp/food_image.jsonas a symbolic link to a file writable by the user who will invoke the workflow. - The user follows the documented image-analysis procedure.
- Shell redirection follows the attacker's symbolic link.
- The target file is overwritten or corrupted with base64 or JSON content.
- Alternatively, if the files are created normally with permissive permissions, another local user reads the retained image data from
/tmp.
Impact As
...[truncated 463 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a private temporary directory or files with
mktempinstead of fixed filenames. - Set
umask 077before creating files containing image data. - Quote all generated paths and verify that temporary files are regular files owned by the invoking user.
- Register an exit trap that removes temporary data on success, failure, and interruption.
- Prefer streaming the generated JSON directly to
curlso that the encoded image is not persisted. - A hardened shell workflow could use:
bash umask 077 tmpdir="$(mktemp -d)" || exit 1 trap 'rm -rf -- "$tmpdir"' EXIT HUP INT TERM image_json="$tmpdir/food_image.json" { printf '{"image_base64":"' base64 < /absolute/path/to/image.jpg | tr -d '\n' printf '"}' } > "$image_json" curl --silent --show-error --location \ 'https://deepeat.ai/step.aispark.api.API/AnalyzeWholeFood' \ --header 'Content-Type: application/json' \ --data-binary @"$image_json"- Create a private temporary directory or files with
