T09 · Insecure Skill Coding Practices
- 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-39andscripts/codex_profile_watchdog.py:112-139
Vulnerability Type: Improper enforcement of selected session scope
Risk Level: MediumVulnerable 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
- Add a session-selection argument to
codex_profile_watchdog.pyand enforce it before entering the modification loop. - Pass
args.session_keyfromtrigger_profile_failover.pyto that watchdog argument. - 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. - Do not rely on filtering returned output as a security or scope-control mechanism.
- Validate that the selected session is authorized by the configuration, unless explicit out-of-configuration targeting is an intended and documented feature.
- Report every modified session without suppressing side effects from the output.
- Add regression tests with multiple configured targets to verify that a manual invocation changes only the selected session.
- Preserve dry-run behavior and test that dry-run and apply modes use the same effective target set.
- Add a session-selection argument to
