@openai/codex-security 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +578 -871
  2. package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
  3. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  5. package/_bundled_plugin/schemas/patch-risk-assessment.schema.json +243 -0
  6. package/_bundled_plugin/scripts/finalize_scan_contract.py +92 -11
  7. package/_bundled_plugin/scripts/launch_codex_security_mcp +0 -0
  8. package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +88 -0
  9. package/_bundled_plugin/skills/assess-patch-risk/agents/openai.yaml +4 -0
  10. package/_bundled_plugin/skills/assess-patch-risk/references/risk-rubric.md +76 -0
  11. package/_bundled_plugin/skills/assess-patch-risk/scripts/validate_patch_risk_assessment.py +163 -0
  12. package/_bundled_plugin/skills/fix-finding/SKILL.md +16 -48
  13. package/dist/api.d.ts +1 -1
  14. package/dist/api.d.ts.map +1 -1
  15. package/dist/api.js +14 -18
  16. package/dist/api.js.map +1 -1
  17. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  18. package/dist/bulk-scan-discovery.js +6 -24
  19. package/dist/bulk-scan-discovery.js.map +1 -1
  20. package/dist/cli.d.ts +24 -2
  21. package/dist/cli.d.ts.map +1 -1
  22. package/dist/cli.js +401 -38
  23. package/dist/cli.js.map +1 -1
  24. package/dist/cloud-publish.d.ts +5 -1
  25. package/dist/cloud-publish.d.ts.map +1 -1
  26. package/dist/cloud-publish.js +307 -9
  27. package/dist/cloud-publish.js.map +1 -1
  28. package/dist/component-plan.d.ts.map +1 -1
  29. package/dist/component-plan.js +5 -1
  30. package/dist/component-plan.js.map +1 -1
  31. package/dist/github.d.ts +161 -0
  32. package/dist/github.d.ts.map +1 -0
  33. package/dist/github.js +158 -0
  34. package/dist/github.js.map +1 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/publish.d.ts +10 -0
  40. package/dist/publish.d.ts.map +1 -1
  41. package/dist/publish.js +29 -5
  42. package/dist/publish.js.map +1 -1
  43. package/dist/runtime.d.ts +0 -3
  44. package/dist/runtime.d.ts.map +1 -1
  45. package/dist/runtime.js +258 -185
  46. package/dist/runtime.js.map +1 -1
  47. package/dist/scan-comparison.d.ts +3 -0
  48. package/dist/scan-comparison.d.ts.map +1 -1
  49. package/dist/scan-comparison.js +6 -1
  50. package/dist/scan-comparison.js.map +1 -1
  51. package/dist/targets.d.ts.map +1 -1
  52. package/dist/targets.js +1 -0
  53. package/dist/targets.js.map +1 -1
  54. package/dist/thread-source.d.ts +8 -0
  55. package/dist/thread-source.d.ts.map +1 -0
  56. package/dist/thread-source.js +7 -0
  57. package/dist/thread-source.js.map +1 -0
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/dist/version.js.map +1 -1
  61. package/package.json +8 -5
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import importlib.util
6
+ import json
7
+ import sys
8
+ from pathlib import Path
9
+ from types import ModuleType
10
+ from typing import Any
11
+
12
+ PLUGIN_ROOT = Path(__file__).resolve().parents[3]
13
+ SCHEMA_PATH = PLUGIN_ROOT / "schemas" / "patch-risk-assessment.schema.json"
14
+ NON_APPLICABLE = {"no_live_effect", "wrong_owner", "duplicate", "superseded"}
15
+
16
+
17
+ def load_scan_contract_validator() -> ModuleType:
18
+ script = PLUGIN_ROOT / "scripts" / "finalize_scan_contract.py"
19
+ spec = importlib.util.spec_from_file_location("codex_security_scan_contract", script)
20
+ if spec is None or spec.loader is None:
21
+ raise RuntimeError(f"could not load scan contract validator: {script}")
22
+ module = importlib.util.module_from_spec(spec)
23
+ spec.loader.exec_module(module)
24
+ return module
25
+
26
+
27
+ SCAN_CONTRACT = load_scan_contract_validator()
28
+
29
+
30
+ def parse_args() -> argparse.Namespace:
31
+ parser = argparse.ArgumentParser(description="Validate a patch-risk assessment.")
32
+ parser.add_argument("assessment", help="Assessment JSON path, or - for stdin.")
33
+ return parser.parse_args()
34
+
35
+
36
+ def reject_duplicate_keys(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
37
+ value: dict[str, Any] = {}
38
+ for key, item in pairs:
39
+ if key in value:
40
+ raise ValueError(f"duplicate JSON object key: {key}")
41
+ value[key] = item
42
+ return value
43
+
44
+
45
+ def read_object(path: str) -> dict[str, Any]:
46
+ try:
47
+ text = sys.stdin.read() if path == "-" else Path(path).read_text(encoding="utf-8")
48
+ value = json.loads(text, object_pairs_hook=reject_duplicate_keys)
49
+ except (OSError, json.JSONDecodeError) as error:
50
+ raise ValueError(f"cannot read assessment: {error}") from error
51
+ if not isinstance(value, dict):
52
+ raise ValueError("assessment must be a JSON object")
53
+ return value
54
+
55
+
56
+ def schema_errors(value: dict[str, Any]) -> list[str]:
57
+ try:
58
+ SCAN_CONTRACT.validate_against_schema(value, SCHEMA_PATH)
59
+ except (OSError, ValueError, RecursionError) as error:
60
+ return [str(error)]
61
+ return []
62
+
63
+
64
+ def semantic_errors(value: dict[str, Any]) -> list[str]:
65
+ recommendation = value["recommendation"]
66
+ workflow_label = value["workflowLabel"]
67
+ unknowns = value["unknowns"]
68
+ evidence_plan = value["evidencePlan"]
69
+ boundaries = value["materialBoundaries"]
70
+ applicability_status = value["applicability"]["status"]
71
+ affirmative_failure = (
72
+ value["regressionLikelihood"]["rating"] == "critical"
73
+ or any(item["result"] == "contradicted" for item in boundaries)
74
+ or any(item["status"] == "failed" for item in value["validation"])
75
+ )
76
+ errors: list[str] = []
77
+
78
+ if recommendation == "merge":
79
+ if workflow_label not in {"auto_merge_candidate", "human_review_required"}:
80
+ errors.append("merge requires an auto-merge or human-review workflow label")
81
+ if value["applicability"]["status"] != "confirmed":
82
+ errors.append("merge requires confirmed applicability")
83
+ if any(item["decisionCritical"] for item in unknowns):
84
+ errors.append("merge cannot retain a decision-critical unknown")
85
+ if any(item["result"] != "supported" for item in boundaries):
86
+ errors.append("merge requires every material boundary to be supported")
87
+ if any(item["status"] == "failed" for item in value["validation"]):
88
+ errors.append("merge cannot retain a failed validation")
89
+ if evidence_plan:
90
+ errors.append("merge cannot retain an evidence plan")
91
+ elif workflow_label != recommendation:
92
+ errors.append("non-merge workflow label must match the recommendation")
93
+
94
+ if recommendation == "hold_for_evidence":
95
+ if not any(item["decisionCritical"] for item in unknowns):
96
+ errors.append("hold_for_evidence requires a decision-critical unknown")
97
+ if not evidence_plan:
98
+ errors.append("hold_for_evidence requires a bounded evidence plan")
99
+ if affirmative_failure:
100
+ errors.append("hold_for_evidence cannot defer an established defect")
101
+ elif evidence_plan:
102
+ errors.append("only hold_for_evidence may include an evidence plan")
103
+
104
+ if recommendation == "no_op":
105
+ if applicability_status not in NON_APPLICABLE:
106
+ errors.append("no_op requires an established non-applicable disposition")
107
+ if any(item["decisionCritical"] for item in unknowns):
108
+ errors.append("no_op cannot retain a decision-critical unknown")
109
+ elif applicability_status in NON_APPLICABLE:
110
+ errors.append("an established non-applicable disposition requires no_op")
111
+
112
+ if recommendation in {"revise", "block"}:
113
+ if not affirmative_failure:
114
+ errors.append(f"{recommendation} requires affirmative failure evidence")
115
+
116
+ if workflow_label == "auto_merge_candidate":
117
+ auto_merge_requirements = {
118
+ "impact.rating": value["impact"]["rating"] == "low",
119
+ "regressionLikelihood.rating": value["regressionLikelihood"]["rating"] == "low",
120
+ "regressionProtection.rating": value["regressionProtection"]["rating"] == "strong",
121
+ "regressionProtection.exactHeadChecksPassed": value["regressionProtection"][
122
+ "exactHeadChecksPassed"
123
+ ],
124
+ "recoverability.rating": value["recoverability"]["rating"] == "easy",
125
+ "confidence.rating": value["confidence"]["rating"] == "high",
126
+ "applicability.status": value["applicability"]["status"] == "confirmed",
127
+ "affectedRuntimeRoots": bool(value["affectedRuntimeRoots"]),
128
+ "statusQuoRisk.rating": value["statusQuoRisk"]["rating"] != "unknown",
129
+ "autoMergeExclusions": not value["autoMergeExclusions"],
130
+ "unknowns": not unknowns,
131
+ "validation": all(item["status"] == "passed" for item in value["validation"]),
132
+ }
133
+ for field, passed in auto_merge_requirements.items():
134
+ if not passed:
135
+ errors.append(f"auto_merge_candidate gate failed: {field}")
136
+
137
+ return errors
138
+
139
+
140
+ def validate(value: dict[str, Any]) -> list[str]:
141
+ errors = schema_errors(value)
142
+ if errors:
143
+ return errors
144
+ return semantic_errors(value)
145
+
146
+
147
+ def main() -> int:
148
+ args = parse_args()
149
+ try:
150
+ value = read_object(args.assessment)
151
+ errors = validate(value)
152
+ except ValueError as error:
153
+ print(error, file=sys.stderr)
154
+ return 1
155
+ if errors:
156
+ for error in errors:
157
+ print(error, file=sys.stderr)
158
+ return 1
159
+ return 0
160
+
161
+
162
+ if __name__ == "__main__":
163
+ raise SystemExit(main())
@@ -22,25 +22,14 @@ Never trade an earlier property for a later one. Minimal means the smallest repo
22
22
 
23
23
  ## Patch Contract
24
24
 
25
- Before editing, establish from repository evidence:
25
+ Before editing, inspect the affected implementation, its direct callers, nearby helpers, and relevant existing tests. Establish from repository evidence:
26
26
 
27
- - affected component and current source-to-sink path or broken control
28
- - attacker-controlled input and required preconditions
29
- - security invariant and narrowest plausible enforcement boundary
30
- - legitimate behavior, APIs, error semantics, and compatibility constraints to preserve or intentionally change with supporting product evidence
31
- - available PoC, reproducer, tests, evidence, and affected locations
32
- - nearest relevant helpers and implementation, error-handling, and test precedents
27
+ - the attacker-controlled input and concrete source-to-sink path or broken control
28
+ - the security invariant and narrowest shared enforcement boundary
29
+ - legitimate behavior, APIs, error semantics, and compatibility constraints that must remain
30
+ - the closest existing implementation, validation, and error-handling precedents
33
31
 
34
- Inspect the repository to fill gaps. Ask the user only when a material product, security, or compatibility decision remains.
35
-
36
- ## Runtime Validation
37
-
38
- Use this guidance whenever reproducing the finding, running tests, or validating the fix:
39
-
40
- - Complete the patch contract before broad setup; start with the smallest high-signal check through the real vulnerable boundary.
41
- - Use repository-supported setup commands. Keep repair effort bounded so it does not displace path analysis, patching, or focused verification.
42
- - Do not stop a progressing command merely because it is slow. Inspect process state, logs, artifacts, or resource use first.
43
- - If runtime validation remains unavailable, use the strongest targeted static or harness-based artifact that preserves the real integration boundary. Do not substitute a simplified harness that removes the behavior being protected. Record every unrun check as unknown.
32
+ Treat the finding as a data-flow and boundary problem, not merely the named input example. Check equivalent encodings, parser forms, aliases, callers, sinks, and every representation or copy of security-sensitive state that could bypass the proposed change. Handle unsafe state explicitly; do not silently accept, truncate, or reinterpret it into another reachable form.
44
33
 
45
34
  ## Pre-Patch Investigation
46
35
 
@@ -52,37 +41,16 @@ The investigation requires repository-relative evidence and a clear separation b
52
41
 
53
42
  ## Implementation Workflow
54
43
 
55
- 1. Revalidate and scope the finding.
56
- - Inspect repository instructions, affected code, direct callers, and only the context needed to prove the vulnerable path.
57
- - Establish concrete reachability in the current checkout; generic weakness labels, file anchors, and suspicious-looking code are not proof.
58
- - If the same broken security boundary cannot be shown after a bounded investigation, do not patch an adjacent weakness or add speculative defense in depth. Return `no_change` when evidence shows the path is already safe; otherwise return `blocked` with the missing proof.
59
- - Complete the patch contract and inspect relevant helpers, controls, and implementation and test precedents.
60
- 2. Reproduce or encode the issue before fixing when feasible.
61
- - Prefer a failing regression test, unit test, integration test, property test, or realistic-interface reproduction.
62
- - Capture the malicious condition and at least one legitimate control through the same boundary before implementation.
63
- - Keep an unsafe-behavior test only when it is safe, deterministic, and appropriate for the repository. Otherwise use the strongest repeatable validation artifact available and record the gap.
64
- - If the issue no longer reproduces before any code changes, investigate whether it was already fixed and preserve the validation evidence.
65
- 3. Choose the patch strategy.
66
- - Determine whether a narrow tactical change can close the boundary while preserving the patch contract.
67
- - Consider broader remediation only when the narrow option cannot close the boundary without breaking supported behavior. Remove or disable functionality only when repository or product evidence supports that mitigation.
68
- - If the only complete fix requires an unresolved decision about product policy, public-API compatibility, or cross-subsystem ownership, return `blocked` with the options, security tradeoff, and likely owner or codeowner when available.
69
- - Use nearby variants to test the chosen boundary. Report unrelated sibling findings or longer-term architectural work separately instead of expanding this patch.
70
- 4. Implement the fix and its proof.
71
- - Make the smallest repository-native change that fully enforces the invariant.
72
- - Prefer existing helpers and abstractions. Preserve APIs, legitimate inputs, and error semantics unless changing them is required by the security contract.
73
- - Handle unsafe state explicitly; do not silently accept, truncate, or reinterpret it.
74
- - Avoid unrelated refactors and preserve user changes outside the candidate patch.
75
- - Add focused regression coverage that fails on the vulnerable behavior and passes after the fix.
76
- - Include positive coverage for the legitimate control. Test at the lowest level that proves the invariant and through the realistic interface when feasible.
77
- 5. Verify in order.
78
- - **Applicability and buildability**: inspect the final diff for unrelated changes, then run the narrowest relevant syntax, import, build, type, or focused test check.
79
- - **Security closure**: rerun the original PoC, trigger, or strongest exploit check. Re-trace the source-to-sink or broken-control path in the patched code.
80
- - **Change-aware bypass review**: reread the finding and final diff without relying on the original rationale. Trace changed branches from direct callers, check equivalent sinks, and exercise an alternate malicious input class when practical.
81
- - **Preserved behavior**: rerun the legitimate control and confirm the recorded APIs, error semantics, and compatibility constraints remain intact.
82
- - **Repository checks**: run the focused regression tests, the owning package's relevant tests, and applicable formatter, linter, type checker, dependency, and integration checks.
83
- - Confirm the regression check would fail if the security change were removed, when practical.
84
- - Treat a failed earlier gate as disqualifying. Revise only the candidate changes or return `blocked`; never compensate for failed security closure or behavior preservation with style, smaller scope, or additional reporting.
85
- 6. Report the outcome with exact commands, results, changed files, and remaining risk.
44
+ 1. Trace the reported path and inspect only the context needed to identify the real shared boundary. Return `no_change` when repository evidence shows that the reported path is already safe; do not make a speculative change.
45
+ 2. When feasible, run the smallest high-signal reproduction through that boundary and one legitimate control through the same path.
46
+ 3. Implement the smallest repository-native fix at the shared boundary. Prefer nearby helpers and established APIs. Do not broaden into unrelated redesign, cleanup, or sibling findings.
47
+ 4. Before verification, challenge the patch rather than defending it: inspect every direct caller of each changed helper and both outcomes of each changed condition. Look for one sibling path, representation, or copy that still reaches the vulnerable sink and one ordinary or default input that the patch newly rejects or reinterprets; revise the implementation if either exists.
48
+ 5. Verify in order:
49
+ - inspect the final diff and run the narrowest syntax, import, build, or type check relevant to it
50
+ - rerun the security trigger or strongest focused substitute and review one alternate malicious input class
51
+ - rerun the legitimate control, nearest existing tests, and the owning package's applicable required checks
52
+
53
+ Return `blocked` if the vulnerability may be real, but essential evidence, tooling, access, or a product or compatibility decision is missing, so a safe fix cannot be responsibly completed or verified.
86
54
 
87
55
  ## Patch Candidate Review
88
56
 
package/dist/api.d.ts CHANGED
@@ -127,7 +127,7 @@ export declare function createSecurityInternal(config: CodexSecurityConfig | und
127
127
  export declare function initialCredentialsAvailable(environment: ProcessEnvironment, ambientHome: string, isolatedHome: string, importer?: typeof importAmbientAuth): Promise<boolean>;
128
128
  export declare function scanAuthentication(environment: ProcessEnvironment, auth?: ScanAuthMode, modelProvider?: unknown): ScanAuthentication;
129
129
  export declare function classifyConnectionFailure(error: unknown): "rate_limited" | "unauthorized" | "forbidden" | "network_error" | "timeout" | "unknown";
130
- export declare function scanRuntimeCodexConfig(config: JsonObject, stateDirectory: string, protectedCredentialHome?: string): JsonObject;
130
+ export declare function scanRuntimeCodexConfig(config: JsonObject, protectedCredentialHome?: string): JsonObject;
131
131
  export declare function scanPreflightCodexConfig(config: JsonObject): JsonObject;
132
132
  export declare function environmentValue(environment: ProcessEnvironment, requested: string): string | undefined;
133
133
  export {};
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AA2BA,OAAO,EAEL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MA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C,WAAW,EAAE,kBAAkB,EAC/B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,OAAO,iBAAqC,GACrD,OAAO,CAAC,OAAO,CAAC,CAOlB;AAukBD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,kBAAkB,EAC/B,IAAI,GAAE,YAAqB,EAC3B,aAAa,CAAC,EAAE,OAAO,GACtB,kBAAkB,CAuCpB;AAoJD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GAEZ,cAAc,GACd,cAAc,GACd,WAAW,GACX,eAAe,GACf,SAAS,GACT,SAAS,CAmCZ;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,EAClB,uBAAuB,CAAC,EAAE,MAAM,GAC/B,UAAU,CAsCZ;AA8BD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAyHvE;AAsDD,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,kBAAkB,EAC/B,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAcpB"}
package/dist/api.js CHANGED
@@ -19,6 +19,7 @@ import { ScanResult, } from "./result.js";
19
19
  import { scanActivitiesFromEvent } from "./scan-activity.js";
20
20
  import { matchCompletedScan, matchScanFindingsInternal, } from "./scan-comparison.js";
21
21
  import { scanProgressUpdatesFromEvent, workerStatusFromEvent, } from "./worker-progress.js";
22
+ import { CODEX_SECURITY_THREAD_SOURCES } from "./thread-source.js";
22
23
  import { CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION } from "./version.js";
23
24
  import { acquireCodexSecurityCredentialHomeLock, bootstrapPlugin, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, createIsolatedHome, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, planOutputArchive, prepareOutputDir, preparePersistentOutputRoot, requireModelSafeOutputDir, requireOutputOutsideRepository, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
24
25
  import { enclosingGitWorktreeRoot, normalizeRepository, normalizeTarget, repositoryRevision, resolveRepositoryPath, validatedGitEnvironment, validateCommittedDiffCheckout, validateMode, } from "./targets.js";
@@ -115,6 +116,7 @@ export class CodexSecurity {
115
116
  CODEX_SECURITY_SURFACE: this.#surface,
116
117
  }, options.auth);
117
118
  const thread = codex.startThread({
119
+ threadSource: CODEX_SECURITY_THREAD_SOURCES.validation,
118
120
  workingDirectory: outputDir,
119
121
  skipGitRepoCheck: true,
120
122
  approvalPolicy,
@@ -236,7 +238,7 @@ export class CodexSecurity {
236
238
  knowledgeBase = await prepareKnowledgeBase(options.knowledgeBasePaths, signal);
237
239
  }
238
240
  checkOpen();
239
- const session = await this.#prepareSession({ protectedRoot, stateDirectory }, options, signal, temporaryRoot, mode === "deep");
241
+ const session = await this.#prepareSession({ protectedRoot }, options, signal, temporaryRoot, mode === "deep");
240
242
  const { runtime, runtimeHome, effectiveConfig, preflightConfig, modelProvider, authentication, approvalPolicy, python, } = session;
241
243
  releaseCredentialHome = session.releaseCredentialHome;
242
244
  const deepScanConfigPath = mode === "deep"
@@ -502,6 +504,7 @@ export class CodexSecurity {
502
504
  };
503
505
  const { codex, environment } = this.#createSessionCodex(session, runtimePaths, options.auth);
504
506
  const thread = codex.startThread({
507
+ threadSource: CODEX_SECURITY_THREAD_SOURCES.scan,
505
508
  workingDirectory: scanDir,
506
509
  skipGitRepoCheck: true,
507
510
  approvalPolicy,
@@ -571,6 +574,7 @@ export class CodexSecurity {
571
574
  filesTotal: scopeFileCount,
572
575
  });
573
576
  const validationThread = codex.startThread({
577
+ threadSource: CODEX_SECURITY_THREAD_SOURCES.scan,
574
578
  workingDirectory: join(scanDir, "artifacts"),
575
579
  skipGitRepoCheck: true,
576
580
  approvalPolicy,
@@ -888,15 +892,8 @@ export class CodexSecurity {
888
892
  warnCleanupFailed(options, error);
889
893
  }
890
894
  finally {
891
- // The startup lock is normally released before workbench registration and Codex
892
- // execution. This fallback covers failures during runtime preparation or
893
- // authentication. The release only marks itself done once the lock directory is
894
- // gone, so a failure leaves an owner.json naming this still-running process;
895
- // recoverStaleCredentialHomeLock then refuses to reclaim it because that pid is
896
- // alive, and later scans in this process wait on a lock nothing frees. Reporting
897
- // success while leaving the client in that state is worse than failing, so the
898
- // failure is only downgraded to a warning when the scan already failed and that
899
- // error is the one worth keeping.
895
+ // Release any remaining startup lock, but preserve the scan's error if both
896
+ // the scan and lock cleanup fail.
900
897
  try {
901
898
  await releaseCredentialHome?.();
902
899
  }
@@ -1084,7 +1081,7 @@ export class CodexSecurity {
1084
1081
  });
1085
1082
  return { codex, environment };
1086
1083
  }
1087
- async #prepareSession({ protectedRoot, stateDirectory, }, options, signal, temporaryRoot, keepCredentialLock = false) {
1084
+ async #prepareSession({ protectedRoot }, options, signal, temporaryRoot, keepCredentialLock = false) {
1088
1085
  let releaseCredentialHome = null;
1089
1086
  const checkOpen = () => {
1090
1087
  this.#requireOpen();
@@ -1122,7 +1119,7 @@ export class CodexSecurity {
1122
1119
  }
1123
1120
  const runtimeHome = await realpath(runtime.codexHome);
1124
1121
  requireOutputOutsideRepository(protectedRoot, runtimeHome, "runtime");
1125
- const sessionConfig = scanRuntimeCodexConfig(effectiveConfig, stateDirectory, runtimeHome);
1122
+ const sessionConfig = scanRuntimeCodexConfig(effectiveConfig, runtimeHome);
1126
1123
  if (options.expectedPluginVersion !== undefined &&
1127
1124
  runtime.plugin.version !== options.expectedPluginVersion) {
1128
1125
  throw new CodexSecurityError(`The original scan used plugin version ${options.expectedPluginVersion}, but the installed version is ${runtime.plugin.version}.`);
@@ -1233,7 +1230,7 @@ export class CodexSecurity {
1233
1230
  }
1234
1231
  async #refreshPersistentRuntime(runtime, environment, signal, mergedConfig) {
1235
1232
  throwIfAborted(signal);
1236
- const config = await preserveCodexSecurityPluginRegistration(runtime.codexHome, sharedCredentialCodexConfig(mergedConfig, codexSecurityStateDirectory(environment), runtime.codexHome));
1233
+ const config = await preserveCodexSecurityPluginRegistration(runtime.codexHome, sharedCredentialCodexConfig(mergedConfig, runtime.codexHome));
1237
1234
  await writeCodexConfig(join(runtime.codexHome, "config.toml"), config);
1238
1235
  runtime.plugin = await bootstrapPlugin(runtime.codexHome, runtime.plugin.pluginRoot, {
1239
1236
  codexCommand: this.#codexCommand(),
@@ -1331,7 +1328,7 @@ export class CodexSecurity {
1331
1328
  const configuredAmbientHome = environmentValue(processEnvironment, "CODEX_HOME");
1332
1329
  const ambientHome = configuredAmbientHome ?? nodeAmbientHome;
1333
1330
  const mergedConfig = requestedConfig ?? (await mergedCodexConfig(this.config));
1334
- const codexConfig = await preserveCodexSecurityPluginRegistration(codexHome, sharedCredentialCodexConfig(mergedConfig, codexSecurityStateDirectory(processEnvironment), codexHome));
1331
+ const codexConfig = await preserveCodexSecurityPluginRegistration(codexHome, sharedCredentialCodexConfig(mergedConfig, codexHome));
1335
1332
  await writeCodexConfig(join(codexHome, "config.toml"), codexConfig);
1336
1333
  const configPath = join(bootstrapWorkspace, "config-preflight.toml");
1337
1334
  throwIfAborted(signal);
@@ -2040,7 +2037,7 @@ export function classifyConnectionFailure(error) {
2040
2037
  return "timeout";
2041
2038
  return "unknown";
2042
2039
  }
2043
- export function scanRuntimeCodexConfig(config, stateDirectory, protectedCredentialHome) {
2040
+ export function scanRuntimeCodexConfig(config, protectedCredentialHome) {
2044
2041
  const approvalPolicy = scanApprovalPolicy(config);
2045
2042
  const hardened = structuredClone(config);
2046
2043
  delete hardened["sandbox_mode"];
@@ -2072,7 +2069,6 @@ export function scanRuntimeCodexConfig(config, stateDirectory, protectedCredenti
2072
2069
  filesystem: {
2073
2070
  ":root": "read",
2074
2071
  ":workspace_roots": "write",
2075
- [stateDirectory]: "write",
2076
2072
  ...(protectedCredentialHome === undefined
2077
2073
  ? {}
2078
2074
  : { [protectedCredentialHome]: "read" }),
@@ -2081,7 +2077,7 @@ export function scanRuntimeCodexConfig(config, stateDirectory, protectedCredenti
2081
2077
  },
2082
2078
  };
2083
2079
  }
2084
- function sharedCredentialCodexConfig(config, stateDirectory, credentialHome) {
2080
+ function sharedCredentialCodexConfig(config, credentialHome) {
2085
2081
  const shared = {
2086
2082
  approval_policy: scanApprovalPolicy(config),
2087
2083
  features: { plugins: true },
@@ -2104,7 +2100,7 @@ function sharedCredentialCodexConfig(config, stateDirectory, credentialHome) {
2104
2100
  };
2105
2101
  }
2106
2102
  }
2107
- return scanRuntimeCodexConfig(shared, stateDirectory, credentialHome);
2103
+ return scanRuntimeCodexConfig(shared, credentialHome);
2108
2104
  }
2109
2105
  export function scanPreflightCodexConfig(config) {
2110
2106
  const safeString = (value) => typeof value === "string" &&