Back to skill

Security audit

OpenAI Codex Operator

Security checks for vulnerabilities and agentic risk

Overview

The skill is purpose-aligned, but it tells agents to launch a code-changing Codex agent through raw command strings and background sessions without enough safeguards.

Review this skill before installing. Use it only for repositories where you are comfortable allowing Codex to read and change files, verify the target workdir every time, avoid interpolating untrusted task text into shell command strings, supervise background sessions, and review diffs before keeping generated changes.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:20
Finding

Shell Command Injection Through Unsafe Task Interpolation

Content
View full analysis
"` ``` `SKILL.md:31-32`: ```markdown ### Long-running background task 1. Start with `exec(background:true, pty:true, workdir, command:"codex exec ...")` ``` `references/codex-usage-recipes.md:4-8`: ```markdown ## 1) Quick implementation - Tool: `exec` - Params: - `pty:true` - `workdir:/path/to/repo` - `command:"codex exec \"Implement X and add tests\""` ``` `references/codex-usage-recipes.md:10-14`: ```markdown ## 2) Code review pass - Tool: `exec` - Params: - `pty:true` - `workdir:/path/to/repo` - `command:"codex exec \"Review current changes and list critical issues\""` ``` `references/codex-usage-recipes.md:17-20`: ```markdown ## 3) Long task with monitoring - Start: - `exec(background:true, pty:true, workdir, command:"codex exec \"...\"")` ``` ### Technical Analysis The skill instructs the agent to construct an `exec.command` string by placing a task inside double quotes. The task can originate from an untrusted user request. Double quotes do not neutralize shell command substitution, and an attacker can also terminate the quoted argument and append additional shell commands. For example, if a task is interpolated without robust shell escaping: ```text "; id > /tmp/codex-injection-proof; # ``` the resulting command can become: ```bash codex exec ""; id > /tmp/codex-injection-proof; #" ``` The shell treats `id > /tmp/codex-injection-proof` as a separate command. Other shell constructs, including command substitution such as `$(command)`, may remain active inside double quotes depending on how the execution tool inv ...[truncated 1987 chars]
Remediation
View remediation
" ``` 3. **If only a shell command string is supported, apply robust shell escaping.** Quote every argument using a well-tested shell-escaping library. Do not implement escaping through simple quote replacement or rely solely on double quotes. 4. **Prefer the bundled wrapper script after validating its path and permissions.** Invoke it with separately represented arguments where possible. Preserve the existing quoted expansions: ```bash cd "$PROJECT_DIR" codex exec "$TASK" ``` 5. **Validate repository paths independently.** Resolve the requested working directory to a canonical path and enforce an allowlist or approved workspace boundary before execution. 6. **Apply least privilege and sandboxing.** Run Codex and OpenClaw with only the repository access required for the task. Restrict access to credentials, home-directory secrets, unrelated repositories, and unnecessary network destinations. 7. **Add adversarial tests.** Verify that task strings containing characters and constructs such as `"`, `'`, `;`, `&&`, `|`, backticks, `$()`, newlines, and redirections are delivered to Codex as one literal argument and never interpreted by a shell. 8. **Update every documented execution pattern.** Correct both `SKILL.md` and `references/codex-usage-recipes.md` so agents are not directed back to the unsafe string-interpolation pattern. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (3)

External Model or Provider Selection

High
Category
Excessive Agency
Confidence
90% confidence
Finding

The script invokes an external AI coding agent (codex exec) using a user-supplied task string inside a target repository. This can cause unreviewed code generation and modification in the specified project directory, potentially introducing insecure code, exfiltration logic, destructive changes, or supply-chain-impacting commits if used in automation or with elevated repository access. The skill context makes this more dangerous because its stated purpose is to delegate implementation and debugging work directly to Codex, so external model-driven actions are the core behavior rather than an incidental callout.

Content

Scanner excerpt · scripts/run-codex-example.sh (reported line 21)May include surrounding context.

sh
fi

cd "$PROJECT_DIR"
codex exec "$TASK"

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documented examples directly invoke exec to run codex in a repository and include an implementation workflow that is expected to modify code and tests, but they provide no warning about side effects or the need for explicit user confirmation. In an agent skill context, recipe-style guidance strongly shapes downstream behavior, so omission of safety guidance can lead to unintended repository changes, especially if used in the wrong working directory or with ambiguous prompts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The background execution recipe describes starting a long-running Codex task, monitoring it, and even sending interactive approval (process submit ... "yes") without warning that the process may continue making changes until explicitly stopped. In this skill's context, that makes the issue more dangerous because it enables unattended or semi-attended code modification workflows that can persist beyond the operator's immediate awareness.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.