Back to skill

Security audit

Codex Profile Failover

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent profile-failover purpose, but it can persistently change Codex session profile state and the manual trigger can modify more sessions than the selected session implies.

Review before installing. Use dry-run first, avoid starting the nohup watchdog until you have a clear stop procedure, and do not rely on trigger_profile_failover.py --session-key to limit changes unless the code is fixed to enforce that scope before applying 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

Warning
Location
scripts/trigger_profile_failover.py:15
Finding

Manual Failover Applies Profile Changes Beyond the Selected Session

Content
View full analysis

Vulnerability Details

File Location: scripts/trigger_profile_failover.py:15-39 and scripts/codex_profile_watchdog.py:112-139
Vulnerability Type: Improper enforcement of selected session scope
Risk Level: Medium

Vulnerable Code

scripts/trigger_profile_failover.py:15-39:

python
parser = argparse.ArgumentParser(description="Manually trigger Codex profile failover for a session")
parser.add_argument("--config", required=True, help="Watchdog config path")
parser.add_argument("--session-key", default=DEFAULT_SESSION_KEY, help=f"Session key to evaluate (default: {DEFAULT_SESSION_KEY})")
parser.add_argument("--state-dir", default="/home/node/.openclaw", help="OpenClaw state directory")
parser.add_argument("--timeout", type=int, default=15, help="Per-profile usage timeout seconds")
parser.add_argument("--dry-run", action="store_true", help="Only inspect, do not apply a switch")
args = parser.parse_args()

command = [
    sys.executable,
    str(SKILL_DIR / "scripts" / "codex_profile_watchdog.py"),
    "--once",
    "--json",
    "--config",
    args.config,
    "--state-dir",
    args.state_dir,
    "--timeout",
    str(args.timeout),
]
if not args.dry_run:
    command.append("--apply")

completed = subprocess.run(command, capture_output=True, text=True, check=False)
if completed.returncode != 0:
    sys.stderr.write(completed.stderr)
    return completed.returncode

payload = json.loads(completed.stdout)
payload["sessions"] = [item for item in (payload.get("sessions") or []) if item.get("sessionKey") == args.session_key]

scripts/codex_profile_watchdog.py:112-139:

python
for session_key in config.get("sessionTargets") or []:
    entry = sessions.get(session_key)
    if not isinstance(entry, dict):
        results.append({"sessionKey": session_key, "status": "missing_session"})
        continue

    evaluation = evaluate_session(entry, usage_rows, profiles, threshold, switch_on_usage_error, now_ms)
    evaluation["sessionKey"] = 
...[truncated 3010 chars]
Remediation
View remediation

Remediation Suggestions

  1. Add a session-selection argument to codex_profile_watchdog.py and enforce it before entering the modification loop.
  2. Pass args.session_key from trigger_profile_failover.py to that watchdog argument.
  3. Construct the effective target list before evaluating or modifying any session. For example, use only the requested session when a selector is present; otherwise, use configured sessionTargets.
  4. Do not rely on filtering returned output as a security or scope-control mechanism.
  5. Validate that the selected session is authorized by the configuration, unless explicit out-of-configuration targeting is an intended and documented feature.
  6. Report every modified session without suppressing side effects from the output.
  7. Add regression tests with multiple configured targets to verify that a manual invocation changes only the selected session.
  8. Preserve dry-run behavior and test that dry-run and apply modes use the same effective target set.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill clearly instructs use of shell commands, file reads/writes, and a long-running watchdog that modifies session state, yet it declares no explicit tool scope or permission boundaries. In an agent environment, this increases the chance the skill is invoked with overly broad default capabilities, enabling unintended file modification, background execution, or networked profile checks without clear operator consent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The entire skill description and operational guidance are written in Turkish, with no indication that language choice is optional or that the skill is intentionally limited to a Turkish-speaking audience. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
88% confidence
Finding

The skill recommends launching a persistent background watchdog with nohup and shell redirection, which creates ongoing session-mutating behavior outside normal interactive control. In this skill's context, the process can continue changing authProfileOverride over time, writing logs and state indefinitely, and may be difficult to audit, stop, or constrain if misconfigured.

Content

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

Watchdog'u başlat

bash
nohup python3 scripts/codex_profile_watchdog.py --config /path/to/workspace/config/codex-profile-watchdog.json --apply >> /path/to/workspace/state/codex-profile-watchdog.log 2>&1 &

Manuel tetikleme

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The code extracts token contents to decode the user's email and later stores the access token in collected profile data. Handling credentials is safety-relevant, but there is no user-facing notice, prompt, or explanatory comment warning that local profile tokens are being accessed and processed.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/codex_profile_runtime.py (reported line 33)May include surrounding context.

python
payload = access.split(".")[1]
        payload += "=" * (-len(payload) % 4)
        decoded = json.loads(base64.urlsafe_b64decode(payload.encode()).decode())
        return ((decoded.get("https://api.openai.com/profile") or {}).get("email"))
    except Exception:
        return None

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This function transmits authentication material and account context to a remote endpoint using an Authorization header and optional ChatGPT-Account-Id header. There is no visible prompt, log message, or comment disclosing that the script will contact an external service with profile-derived credentials.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This code rewrites sessions.json and changes authProfileOverride, which affects persistent agent session state. Although the CLI flag name suggests mutation, there is no confirmation prompt, inline warning comment/docstring, or user-facing log before the file write occurs in this file.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% 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 · references/setup.md (reported line 88)May include surrounding context.

md
"nextCommands": {
            "dryRun": f"python3 {SKILL_DIR / 'scripts' / 'codex_profile_threshold_guard.py'} --config {threshold_path} --state-dir {args.state_dir} --json",
            "applyOnce": f"python3 {SKILL_DIR / 'scripts' / 'codex_profile_threshold_guard.py'} --config {threshold_path} --state-dir {args.state_dir} --apply --json",
            "startWatchdog": f"nohup python3 {SKILL_DIR / 'scripts' / 'codex_profile_watchdog.py'} --config {watchdog_path} --state-dir {args.state_dir} --apply >> {workspace / 'state' / 'codex-profile-watchdog.log'} 2>&1 &",
            "manualTrigger": f"python3 {SKILL_DIR / 'scripts' / 'trigger_profile_failover.py'} --config {watchdog_path} --state-dir {args.state_dir}",
        },
    }

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% 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/install_codex_profile_failover.py (reported line 61)May include surrounding context.

python
"nextCommands": {
            "dryRun": f"python3 {SKILL_DIR / 'scripts' / 'codex_profile_threshold_guard.py'} --config {threshold_path} --state-dir {args.state_dir} --json",
            "applyOnce": f"python3 {SKILL_DIR / 'scripts' / 'codex_profile_threshold_guard.py'} --config {threshold_path} --state-dir {args.state_dir} --apply --json",
            "startWatchdog": f"nohup python3 {SKILL_DIR / 'scripts' / 'codex_profile_watchdog.py'} --config {watchdog_path} --state-dir {args.state_dir} --apply >> {workspace / 'state' / 'codex-profile-watchdog.log'} 2>&1 &",
            "manualTrigger": f"python3 {SKILL_DIR / 'scripts' / 'trigger_profile_failover.py'} --config {watchdog_path} --state-dir {args.state_dir}",
        },
    }

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code conditionally adds the "--apply" flag and then executes another script via subprocess, which can change the active profile state. Although the CLI description mentions triggering failover, there is no confirmation prompt, explicit user-facing warning at execution time, or explanatory comment/docstring near the safety-relevant operation.

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/trigger_profile_failover.py (reported line 38)May include surrounding context.

python
if not args.dry_run:
        command.append("--apply")

    completed = subprocess.run(command, capture_output=True, text=True, check=False)
    if completed.returncode != 0:
        sys.stderr.write(completed.stderr)
        return completed.returncode

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file includes operational instructions in Turkish for lines L014-L030, while the rest of the document is primarily in English. That imposes a language expectation on users without opt-in or justification, which fits the language/locale policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
75% confidence
Finding

The helper writes JSON payloads to disk, which can modify user data, but the file provides no visible confirmation, logging, or descriptive comments about this behavior. In isolation this is a generic file-write primitive, yet it still lacks any disclosure expected for safety-relevant modification of local files.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

This function creates directories and appends JSON events to a file, modifying the local filesystem without any visible user notice. Because logging can persist potentially sensitive operational data, the absence of disclosure reduces transparency.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
73% confidence
Finding

The function duplicates an existing file to a timestamped backup path, which is a filesystem-modifying operation. There is no confirmation, print statement, or explanatory comment to make users aware that backups will be created.

Content

No source excerpt is available for this finding.