Back to skill

Security audit

Codex Native Scheduler

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed native scheduler for unattended Codex jobs, with expected persistence and file/process access but no hidden or purpose-mismatched behavior found.

Install only if you intentionally want Codex tasks to run later or recur without you present. Review each job's cwd, prompt, schedule, write permissions, captured environment variables, and retention settings, and use decommission/purge when you no longer want scheduled jobs or stored run artifacts.

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

Note
Location
scripts/codex_scheduler/runner.py:654
Finding

Codex child PID reuse may terminate an unrelated process

Content
View full analysis
dict[str, Any]: run, run_dir = store.resolve_run(reference) if run.get("status") not in {"starting", "running"}: raise SchedulerError(f"run is not active: {run['status']}") atomic_write_text(run_dir / "cancel.requested", f"{iso()}\n") codex_pid = run.get("codex_pid") if codex_pid and process_alive(codex_pid): terminate_process_tree(codex_pid) ``` The invoked termination function operates on the PID without validating a process creation token: ```python def terminate_process_tree(pid: int, *, grace_seconds: float = 10) -> None: """Request termination, then force a still-running process tree to stop.""" if not process_alive(pid): return if os.name == "nt": run_checked( ["taskkill", "/PID", str(pid), "/T"], timeout=max(5, grace_seconds), ) else: try: os.killpg(pid, signal.SIGTERM) except ProcessLookupError: return deadline = time.monotonic() + grace_seconds while process_alive(pid) and time.monotonic() < deadline: time.sleep(0.1) if not process_alive(pid): return if os.name == "nt": run_checked(["taskkill", "/PID", str(pid), "/T", "/F"], timeout=15) else: try: os.killpg(pid, signal.SIGKILL) except ProcessLookupError: pass ``` ### Technical Analysis The scheduler stores a creation token for its runner process and uses that token to protect runner-related operations against PID reuse. It does not store an equivalent creation token for the spawned Codex child process. After Codex terminates, the ...[truncated 2485 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (22)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill describes capabilities that can read environment variables, read and write files, and invoke shell commands, but it does not declare an explicit tool scope or permissions boundary in the skill metadata. For a scheduler that creates unattended jobs and manipulates native schedulers, this omission increases the risk of overbroad execution, accidental destructive actions, or abuse of inherited credentials and filesystem access.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
82% confidence
Finding

The skill is explicitly designed to create persistent scheduled execution through launchd, systemd user timers, or Windows Task Scheduler, which establishes unattended re-execution beyond the initiating session. Persistence is not inherently malicious here, but it is security-sensitive because it can repeatedly run prompts with file-writing capability, survive user forgetfulness, and continue operating with whatever access the scheduled environment retains.

Content

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

md
---
name: codex-native-scheduler
description: Schedule, inspect, retry, pause, resume, stop, and decommission unattended Codex CLI jobs through macOS launchd, Linux systemd user timers, or Windows Task Scheduler. Use when the user wants Codex to run later or recur without a resident daemon, or needs to manage jobs created by codex-schedule.
---

# Codex Native Scheduler

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · references/semantics.md (reported line 60)May include surrounding context.

md
Worktree base policy defaults to `latest`. The configured local branch or
explicit `--base-ref` is resolved at run time without fetch or pull. Detached
HEAD falls back to the captured commit. `snapshot` always uses the captured
commit. The scheduler does not commit, merge, push, or automatically remove
dirty or unmerged worktrees.

Direct mode rejects a dirty Git directory unless `--allow-dirty` is explicit.

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 6)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 26)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 27)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 29)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 76)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 78)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/codex_scheduler/backends/launchd.py (reported line 80)May include surrounding context.

python
from __future__ import annotations

import os
import plistlib
import shutil
from pathlib import Path
from typing import Any

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The function captures environment values via captured_environment(env_names, env_assignments) and persists them into the job object as environment and environment_missing. This is sensitive-data handling, but the file provides no confirmation prompt, user-visible log/print, or explanatory comment/docstring disclosing that environment variables may be collected and stored.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
91% confidence
Finding

This code executes a command and environment taken from the job definition, including job["codex"]["command"], profile/config overrides, cwd, and the entire job environment, without any local validation or restriction at the execution point. In a scheduler skill, that means a user who can create or influence jobs can cause arbitrary program execution in unattended background runs, which increases risk because execution is detached from immediate user review and may inherit sensitive environment or filesystem access.

Content

Scanner excerpt · scripts/codex_scheduler/runner.py (reported line 205)May include surrounding context.

python
stdout_path.open("w", encoding="utf-8") as stdout_handle,
                stderr_path.open("w", encoding="utf-8") as stderr_handle,
            ):
                process = subprocess.Popen(
                    command,
                    cwd=cwd,
                    env=environment,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The function spawns a detached runner process with stdin/stdout/stderr redirected to DEVNULL, so the action is silent from the user's perspective. Although scheduling behavior is implied by the module purpose, this block performs subprocess execution without any confirmation, print/log message, or inline warning describing that a background process will be launched.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/codex_scheduler/runner.py (reported line 579)May include surrounding context.

python
else:
        kwargs["start_new_session"] = True
    try:
        process = subprocess.Popen(command, **kwargs)
    except OSError as exc:
        raise SchedulerError(f"could not detach scheduled runner: {exc}") from exc
    return {"spawned_pid": process.pid, "job_id": job["id"]}

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The helper collects requested environment variables from the current process and preserves common environment values such as HOME, PATH, CODEX_HOME, and locale settings. For code files, accessing environment data can be safety-relevant when there is no visible confirmation, logging, or explanatory comment warning that environment state may be captured and propagated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This helper executes arbitrary argument lists via subprocess.run and captures output, but the function itself provides no docstring, comment, prompt, or logging indicating that external processes will be launched. Under the code-file criteria, subprocess execution is a safety-critical operation when there is no visible disclosure and the behavior is not clearly explained here.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/codex_scheduler/util.py (reported line 251)May include surrounding context.

python
timeout: float | None = 30,
    env: dict[str, str] | None = None,
) -> subprocess.CompletedProcess[str]:
    return subprocess.run(
        arguments,
        text=True,
        capture_output=True,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The function sends SIGTERM and SIGKILL on Unix or taskkill, including forced termination on Windows, which can abruptly stop processes and cause data loss. Although the docstring mentions termination, it does not warn about the destructive nature or possible side effects of forcibly killing a process tree.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The function writes a new plist file, replaces the existing one, and may later restore previous contents with write_bytes, which directly changes on-disk scheduler configuration. This file contains no user-facing warning, prompt, or explanatory comment indicating that job registration will write and replace launchd configuration files.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This code invokes the system utility launchctl to boot out and bootstrap jobs, which changes system scheduler state. In this file there is no confirmation prompt, user-facing log/print, or explanatory comment/docstring describing that scheduler registration will execute system commands.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/codex_scheduler/cli.py (reported line 358)May include surrounding context.

python
job = store.resolve_job(args.job)
    changes: dict[str, Any] = {}
    for key in ("name", "session_mode"):
        value = getattr(args, key)
        if value is not None:
            changes[key] = value
    if args.overlap is not None:

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The doctor workflow executes codex login status, which is an external CLI invocation that may inspect authentication state, but this file provides no user-facing warning, print, or comment explaining that account/login information will be queried. For a code file, subprocess operations that touch potentially sensitive credentials or auth state should have some visible disclosure unless clearly documented as expected behavior.

Content

No source excerpt is available for this finding.