T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/oa_workspace_smoke_test.sh:27
- Finding
- Predictable Temporary Log File Enables Local File Clobbering and Information Disclosure## Vulnerability Details **File Location**: `scripts/oa_workspace_smoke_test.sh`, lines 27–30 and 34 **Vulnerability Type**: Predictable unsafe temporary file **Risk Level**: Medium ### Vulnerable Code ```bash oa collect -c "$CONFIG_PATH" >/tmp/oa-skill-smoke-collect.log 2>&1 || { cat /tmp/oa-skill-smoke-collect.log >&2 fail "oa collect failed" } ok "oa collect succeeded" HEALTH_BODY="$(mktemp)" GOALS_BODY="$(mktemp)" TEAM_BODY="$(mktemp)" trap 'rm -f "$HEALTH_BODY" "$GOALS_BODY" "$TEAM_BODY" /tmp/oa-skill-smoke-collect.log' EXIT ``` ### Technical Analysis The script redirects command output to the fixed, publicly predictable path `/tmp/oa-skill-smoke-collect.log`. Unlike the response-body files created with `mktemp`, this log is not created atomically with a unique name. An attacker with local access to the same temporary directory can create that pathname before the script runs. If the path is a symbolic link and the operating system's link protections and filesystem permissions permit following it, shell redirection may open and truncate the link target. Concurrent script executions can also overwrite or delete one another's logs. The output permissions depend on the invoking process's `umask`. Consequently, diagnostic output from `oa collect`—potentially including configuration errors, workspace paths, agent identifiers, or other operational details—could become readable by other local users. The script also prints the log to standard error on failure, but that behavior is expected; the vulnerability is the unsafe creation and storage of the log in a shared temporary directory. ### Attack Path 1. The attacker has local access sufficient to create files or symbolic links under `/tmp`. 2. Before a privileged or more trusted user starts the smoke test, the attacker creates `/tmp/oa-skill-smoke-collect.log`. 3. The attacker either: - links the path to a file writable by the victim process, or - creates a normal file and monitors it for diagno ...[truncated 1418 chars]
- Remediation
- ## Remediation Suggestions Create every temporary file atomically with `mktemp`, apply restrictive permissions, and install the cleanup trap immediately after creation. For example: ```bash COLLECT_LOG="$(mktemp "${TMPDIR:-/tmp}/oa-skill-smoke-collect.XXXXXX")" HEALTH_BODY="$(mktemp "${TMPDIR:-/tmp}/oa-skill-health.XXXXXX")" GOALS_BODY="$(mktemp "${TMPDIR:-/tmp}/oa-skill-goals.XXXXXX")" TEAM_BODY="$(mktemp "${TMPDIR:-/tmp}/oa-skill-team.XXXXXX")" chmod 600 "$COLLECT_LOG" "$HEALTH_BODY" "$GOALS_BODY" "$TEAM_BODY" trap 'rm -f -- "$COLLECT_LOG" "$HEALTH_BODY" "$GOALS_BODY" "$TEAM_BODY"' EXIT if ! oa collect -c "$CONFIG_PATH" >"$COLLECT_LOG" 2>&1; then cat -- "$COLLECT_LOG" >&2 fail "oa collect failed" fi ``` Additional hardening measures: 1. Set `umask 077` near the beginning of the script so newly created diagnostic files are private by default. 2. Avoid fixed names anywhere in a shared temporary directory. 3. Quote all cleanup paths and use `rm -f --` to terminate option processing. 4. Register cleanup as soon as temporary files are created so early failures do not leave diagnostics behind. 5. Consider creating one private temporary directory with `mktemp -d`, storing all artifacts inside it, and removing that directory on exit. 6. Avoid running the smoke test with elevated privileges unless the OA workspace explicitly requires them.
