T09 · Insecure Skill Coding Practices
- Location
SKILL.md:120- Finding
Predictable Plaintext Temporary File Used for AWS Resource Inventory
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 120-121
Vulnerability Type: Unsafe temporary-file handling and plaintext storage of cloud resource metadata
Risk Level: MediumComplete Code Snippet:
bash aws ec2 describe-instances > /tmp/ec2-instances.json # Cache resource list cat /tmp/ec2-instances.json | jq '.Reservations[*].Instances[*].InstanceId' # Read subsequent data from cacheTechnical Analysis
The skill instructs the agent to write the full response from
aws ec2 describe-instancesto a fixed, predictable path under the shared/tmpdirectory. It does not require secure file creation, restrictive permissions, ownership validation, atomic writes, or cleanup.On a multi-user system, another local user may monitor or pre-create this path. If the path is a symbolic link, shell redirection follows it and truncates or overwrites the linked file when the agent has permission to write to the target. If the generated cache has permissive permissions, other users may read AWS instance metadata. The full AWS response can contain substantially more infrastructure information than the instance IDs selected by the later
jqcommand.Attack Path
- A local attacker anticipates that the skill will use
/tmp/ec2-instances.json. - The attacker either monitors that predictable path or creates it as a symbolic link to another file writable by the agent.
- The agent executes the documented
aws ec2 describe-instancescommand using its configured AWS identity. - Shell redirection follows the existing path and writes the full EC2 inventory to it.
- The attacker reads the resulting cloud metadata or causes an unintended writable target file to be truncated and replaced.
- Because no cleanup is specified, cached infrastructure information may remain available after the task.
Exploitation requires local access to the same host and sufficient filesystem access to interact with t ...[truncated 763 chars]
- A local attacker anticipates that the skill will use
- Remediation
View remediation
Remediation Suggestions
-
Avoid caching the response unless repeated processing genuinely requires it.
-
Request only the necessary fields from AWS rather than storing the full response:
bash aws ec2 describe-instances \ --query 'Reservations[*].Instances[*].InstanceId' \ --output json -
If caching is required, create a private temporary directory and enforce owner-only permissions:
bash umask 077 cache_dir="$(mktemp -d)" || exit 1 trap 'rm -rf -- "$cache_dir"' EXIT cache_file="$cache_dir/ec2-instances.json" aws ec2 describe-instances \ --query 'Reservations[*].Instances[*].InstanceId' \ --output json > "$cache_file" -
Do not use a fixed filename in a shared temporary directory.
-
Validate file ownership and type before reuse, and reject symbolic links.
-
Use atomic creation or replacement where cached data must persist.
-
Delete temporary cloud inventory immediately after use.
-
Document the cache's lifetime and invalidate it after infrastructure changes.
-
