T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:211
- Finding
- Predictable Temporary Files Expose Manifests to Disclosure and Symlink-Based File Clobbering## Vulnerability Details **File Location**: `SKILL.md`, lines 211–213 **Vulnerability Type**: Predictable and insecure temporary-file handling **Risk Level**: Medium ### Vulnerable Code ```bash # Extract rendered manifests argocd app manifests <app-name> --source live > /tmp/live-manifests.yaml argocd app manifests <app-name> --source git > /tmp/git-manifests.yaml ``` ### Technical Analysis The documented commands write rendered Kubernetes manifests to fixed paths in the shared `/tmp` directory. They do not securely create the files, restrict their permissions, verify that the destinations are regular files, or remove them after use. Shell output redirection opens the destination with truncation and ordinarily follows symbolic links. A local attacker able to create files in `/tmp` can therefore pre-create `/tmp/live-manifests.yaml` or `/tmp/git-manifests.yaml` as a symbolic link to another file writable by the account running the Skill. When the command executes, the linked file may be truncated and replaced with manifest data. Rendered manifests may contain Kubernetes `Secret` objects, environment variables, internal service addresses, repository details, security settings, or other operationally sensitive configuration. Depending on the process umask and local environment, fixed output files may also be readable by other users and remain available after the analysis ends. ### Attack Path 1. A local attacker predicts the fixed temporary path, such as `/tmp/live-manifests.yaml`. 2. Before the analysis runs, the attacker creates that path as a symbolic link to a file writable by the Skill's operating-system account. 3. The operator follows the Skill instructions and runs the manifest extraction command. 4. Shell redirection follows the symbolic link and truncates or overwrites the linked target with rendered Kubernetes manifests. 5. Alternatively, if the resulting temporary file has permissive permis ...[truncated 1015 chars]
- Remediation
- ## Remediation Suggestions - Create a private temporary directory with `mktemp -d` rather than using predictable filenames. - Set `umask 077` before creating files so only the current operating-system user can access them. - Register a cleanup trap to remove the directory and its contents on normal exit, interruption, or failure. - Avoid storing rendered manifests when possible; stream command output directly into the required analysis tool. - Run the analysis under a dedicated, least-privileged account and avoid running it as `root`. - Treat all rendered manifests as sensitive because they may include Secret resources or credentials. - If files must be retained, use a protected directory with explicit ownership and mode `0600`, and establish a defined retention policy. Example hardened pattern: ```bash umask 077 tmpdir="$(mktemp -d)" || exit 1 trap 'rm -rf -- "$tmpdir"' EXIT HUP INT TERM argocd app manifests "$app_name" --source live > "$tmpdir/live-manifests.yaml" argocd app manifests "$app_name" --source git > "$tmpdir/git-manifests.yaml" ```
