Back to skill

Security audit

codex-runner

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed background Codex runner, but it launches autonomous coding work with sandbox and approval protections disabled and includes unsafe shell wrappers.

Install only if you deliberately want a Chinese-language background Codex runner and are prepared to run it in an isolated throwaway workspace or container. Avoid using the provided start scripts on sensitive repositories or normal home directories unless they are rewritten to keep sandboxing and approvals enabled, validate task names and paths, safely encode JSON, quote shell arguments, and track only their own process IDs.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (5)

T09 · Insecure Skill Coding Practices

Error
Location
commands/start.sh:5
Finding

Arbitrary Shell Command Injection Through Task and Target Directory Arguments

Content
View full analysis
$LOG_FILE 2>&1 & ``` ### Technical Analysis `TARGET_DIR` and the task description in `$1` are expanded while the outer shell constructs a new program for `bash -c`. Single quotation marks included in the expanded values are not escaped before the resulting string is parsed by the child shell. Consequently, an input containing a single quote can terminate the intended quoted argument and append additional shell syntax. Quoting the variables with literal single quotes inside the constructed string does not provide protection because the expansion occurs before `bash -c` parses that string. The vulnerable shell runs independently of Codex. Therefore, the command injection occurs even before Codex applies any interpretation to the task and is not constrained by Codex sandbox settings. ### Attack Path 1. An attacker controls or influences the task description or target directory supplied to `start.sh`. 2. The attacker supplies a value containing a closing single quote, shell commands, and a comment marker. A representative task structure is: ```text '; attacker-command; # ``` 3. The outer shell expands the value into the string passed to `bash -c`. 4. The child shell interprets the injected quotation mark and separators as shell syntax. 5. `attacker ...[truncated 794 chars]
Remediation
View remediation
"$log_file" 2>&1 & ``` Additional hardening should include: 1. Validate that `target_dir` is an existing directory and resolve it with `realpath`. 2. If operation must be restricted to approved workspaces, verify that the canonical path is beneath an allowlisted root. 3. Quote every variable expansion used as an argument or redirection target. 4. Avoid `eval`, `bash -c`, or equivalent reparsing mechanisms for user-controlled data. 5. Add regression tests using task descriptions and paths containing quotation marks, semicolons, command substitutions, whitespace, glob characters, and newlines. 6. Remove the sandbox-bypass flag addressed in the separate finding. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
commands/start.sh:16
Finding

Codex Is Deliberately Launched Without Sandbox or Approval Controls

Content
View full analysis
$LOG_FILE 2>&1 & ``` The associated instructions also characterize unrestricted operation as mandatory: ```text 必须使用 `--dangerously-bypass-approvals-and-sandbox` ``` Relevant documentation occurs at `SKILL.md:117–141` and `SKILL.md:200`. ### Technical Analysis The `--dangerously-bypass-approvals-and-sandbox` option explicitly disables two security boundaries: - Sandbox restrictions that would otherwise limit filesystem and command access. - Approval prompts that would otherwise require user confirmation for sensitive operations. Repository contents can contain adversarial instructions, and task descriptions may be untrusted or ambiguous. Launching an autonomous coding agent without these controls allows such instructions to result in unrestricted user-level host operations rather than changes confined to the intended workspace. The behavior is implemented by default and described as required rather than being an exceptional, informed, per-run decision. ### Attack Path 1. A user invokes the Skill for a repository containing malicious or prompt-injecting content, or provides a task influenced by an untrusted party. 2. `start.sh` launches Codex with both sandbox and approval controls disabled. 3. Codex examines the repository and task content as part of its normal work. 4. Adversarial instructions induce operations outside the legitimate development scope. 5. Those operations execute without a sandbox boundary or an interactive approval decision. 6. Host resources accessible to the i ...[truncated 933 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
commands/start-async.sh:5
Finding

Unvalidated Task Names Are Used in Destructive Log-File Redirections

Content
View full analysis
$LOG_FILE ``` A related unsafe construction is present in `commands/start.sh:5–10` and the log destination is used for redirection at `commands/start.sh:26`. ### Technical Analysis The task name is accepted without an allowlist and embedded directly into a filesystem path. The resulting `LOG_FILE` expansion is then used without quotation marks in a truncating redirection. This creates several unsafe behaviors: - Slash characters can introduce additional path components. - Glob characters can trigger pathname expansion. - Whitespace and other shell metacharacters can alter word handling. - Existing symbolic links or attacker-prepared path components can redirect the operation. - The standalone `>` operation truncates the resolved target immediately, before any task is started. The fixed `codex-` prefix and `.log` suffix constrain some direct traversal forms, but they do not make an unvalidated, unquoted pathname safe. Exploitability of a specific external target can depend on the existing directory and symbolic-link layout. ### Attack Path 1. An attacker controls or influences the task name passed as the second argument. 2. The attacker supplies path separators, glob characters, whitespace, or a name that resolves through an attacker-prepared directory or symbolic link beneath the log location. 3. The script constructs `LOG_FILE` without validating the task name. 4. The unquoted redirection performs shell expansion and resolves the resulting path. 5. `start-async.sh` opens the resolved file with truncation semantics. 6. Existing data at that destination is destroyed or subsequent task ou ...[truncated 723 chars]
Remediation
View remediation
&2 exit 2 fi ``` 2. Explicitly reject `/`, `\`, `..`, control characters, whitespace, and glob characters. 3. Quote all path expansions: ```bash log_dir="${HOME}/.codex-logs" log_file="${log_dir}/codex-${task_name}.log" mkdir -p -- "$log_dir" : >"$log_file" ``` 4. Resolve and verify the parent directory before opening the file. Confirm that it remains beneath the canonical log directory. 5. Protect against symbolic-link redirection. Where available, use an API or helper supporting `O_NOFOLLOW`, or securely create unique files with `mktemp`. 6. Set restrictive permissions, such as `umask 077`, because task logs may contain source code or sensitive command output. 7. Apply the same validation and quoting changes to `commands/start.sh` and `commands/log.sh`. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
commands/stop.sh:4
Finding

Stop Command Terminates Unrelated Codex Processes

Content
View full analysis
Remediation
View remediation
` rather than terminating all Codex executions. 7. Use graceful termination first and apply a stronger signal only after a bounded timeout. ]]>

T01 · Skill Instruction Hijacking

Warning
Location
commands/start-async.sh:20
Finding

Unescaped Arguments Permit JSON and Subagent Request Injection

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (14)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill explicitly instructs use of --dangerously-bypass-approvals-and-sandbox, which disables normal safety controls and allows unrestricted code execution and file modification. For a generic background coding runner, this is excessive privilege and makes any prompt-driven task far more capable of causing destructive changes, data exposure, or execution of unsafe commands.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script explicitly documents and implements use of --dangerously-bypass-approvals-and-sandbox, which disables core safety controls for a generic background task runner. In this context, the behavior is not narrowly scoped to a controlled administrative workflow; it enables arbitrary task text ($1) to be executed by Codex with reduced protections, making the bypass materially dangerous.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The command launches Codex with approvals and sandbox protections disabled, then feeds it user-controlled task content in a detached background process. This combination permits high-risk autonomous actions without user review, and the lack of an explicit warning or confirmation increases the chance of unsafe or unintended execution.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill encourages spawning an independent subagent via sessions_spawn to carry out open-ended development tasks in a separate session. That delegation increases autonomy and reduces visibility/control, so a broad user request can turn into prolonged, unsupervised actions including code execution and filesystem changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The example tells the assistant to create folders/files and run Codex tasks in the background, but it does not clearly foreground that these actions can modify the filesystem autonomously after the main conversation returns. In the context of a long-running background agent, insufficient warning increases the risk of users authorizing actions without understanding the persistence and scope of changes.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
88% confidence
Finding

Using nohup to detach the process creates persistence beyond the interactive session, allowing the task to continue executing unattended. In this skill's context, persistence combines with autonomous coding and command execution to increase the chance of unnoticed harmful changes, runaway processes, or prolonged misuse of system/network access.

Content

Scanner excerpt · SKILL.md (reported line 121)May include surrounding context.

md
TASK_NAME=${2:-codex-task}
TARGET_DIR=${3:-.}

nohup bash -c "
  cd '$TARGET_DIR'
  
  export https_proxy=http://127.0.0.1:8118

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script prints its user-facing messages only in Chinese ("日志" / "日志文件不存在") with no indication that the skill is region-specific or that the user can choose a language. This is a natural-language policy concern because it imposes a locale on all users without opt-in or documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This shell script contains natural-language comments and output entirely in Chinese, including operational status messages and task instructions. The file does not provide any user opt-in, fallback language, or justification that it is intended only for a Chinese-language environment, which conflicts with the language/locale policy criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

User-visible comments and status messages are written in Chinese, and the script provides no option for users to select another language or locale. This creates a natural-language policy concern because the skill effectively imposes a specific language without opt-in or documented justification.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
89% confidence
Finding

Using nohup creates a persistent detached process that continues running after the initiating session ends. In this file, persistence amplifies the danger because the spawned process is a Codex run with sandbox and approval protections disabled, reducing visibility and making unsafe actions harder to interrupt or supervise.

Content

Scanner excerpt · commands/start.sh (reported line 17)May include surrounding context.

sh
echo "任务描述: $1"

# 使用 --dangerously-bypass-approvals-and-sandbox 完全跳过沙箱
nohup bash -c "
  cd '$TARGET_DIR'
  
  export https_proxy=http://127.0.0.1:8118

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script unconditionally runs pkill -f "codex.*exec", which can terminate multiple matching processes without any confirmation, dry-run, or scope validation. Because pkill -f matches against full command lines, an overly broad pattern may stop unintended processes and cause denial of service or data loss if active work is interrupted.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations. The entire user-facing description and examples are presented in Chinese, but the skill does not state that Chinese is optional, user-selected, or required for a region-specific purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script prints status messages in Chinese only ("Codex 进程状态" and "进程数量") with no indication that the skill is region-specific or that users can choose their preferred language. This is a natural-language policy concern because it imposes a specific locale on all users without opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's visible status messages are hard-coded in Chinese (停止 Codex 进程, 已停止所有 Codex 进程). This imposes a specific language on users without opt-in or justification, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.