2 2
3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.
4 4
5Use Codex Security to turn an accepted security finding into a focused,5Start with one finding whose evidence you accept. Generate a patch,
6verified patch. You can work in the Security workbench or run the remediation6review it, and verify the original issue against the changed code. A generated
7workflow from a prompt, the command line, or CI/CD. Codex validates the issue7or applied patch isn't yet a verified fix.
8and, when testing is safe and practical, adds a focused regression test that8
9fails before the fix and passes after it. It also checks that legitimate9In the desktop workbench, generation leaves the selected checkout unchanged.
10behavior still works. If a regression test is unsafe or infeasible, Codex10Applying the patch changes that checkout. Verification checks the patch and
11records the proof gap and provides the strongest repeatable validation11records evidence without automatically closing the finding.
12artifact instead.
13
14Start with one accepted finding and review the proposed patch and verification
15evidence. If the workflow meets your standards, process other accepted
16findings one at a time in separate Codex tasks or CI/CD jobs. Keeping each task
17scoped makes its code changes and evidence easier to review.
18 12
19## Fix a finding in the UI13## Fix a finding in the UI
20 14
21Open an accepted finding from **Findings** or a completed scan in **Scans**.15Open an accepted finding from **Findings** or a completed scan in **Scans**.
22Review its evidence, then use **Patch** to generate, review, apply, and verify16Review its evidence, then use **Patch** to generate, review, apply, and verify
23one focused fix.17a fix.
24 18
25<WorkflowSteps variant="headings">19<WorkflowSteps variant="headings">
26 20
271. Generate a focused patch211. Generate a patch
28 22
29 Open the finding, select the **Patch** tab, and select **Generate patch**.23 Open the finding, select the **Patch** tab, and select **Generate patch**.
30 Codex validates or reproduces the issue when feasible and writes a patch24 Codex validates or reproduces the issue when feasible and writes a patch
32 26
332. Review the proposed diff272. Review the proposed diff
34 28
35 Read every changed source, regression test, and validation artifact. Reject29 Check the affected code and tests. Confirm that the change addresses the
36 broad refactors, unrelated cleanup, or changes that weaken another security30 finding without unrelated refactors or weakened security controls.
37 control.
38 31
393. Apply the patch locally323. Apply the patch locally
40 33
44 37
454. Verify the fix384. Verify the fix
46 39
47 Select **Verify fix**. Codex reruns the original reproducer or the strongest40 Select **Verify fix**. Codex reruns the original reproducer or another
48 available exploit check. If a regression test is safe and practical, Codex41 exploit check. When it can run a regression test, it checks that the test
49 checks that it fails before the fix and passes after it. If the test is42 fails before the fix and passes after it. Otherwise, it records the
50 unsafe or infeasible, Codex records the proof gap and provides the43 verification gap and the checks it could complete. It also checks
51 strongest repeatable validation artifact instead. It also checks44 legitimate behavior, nearby bypasses, and repository tests.
52 legitimate behavior, nearby bypasses, and relevant repository tests.
53 45
545. Close the finding deliberately465. Close the finding
55 47
56 Verification doesn't automatically close a finding. Review the commands,48 Verification doesn't automatically close a finding. Review the commands,
57 results, and remaining proof gap, then close the finding with an accurate49 results, and remaining proof gap, then close the finding with an accurate
71 </figcaption>63 </figcaption>
72</figure>64</figure>
73 65
74## Fix a finding from the CLI66## Fix a finding in a conversation
75
76Use the Codex CLI for an accepted finding from a scan, ticket, advisory,
77disclosure, security assessment, or internal review.
78 67
79Install Codex Security in the `CODEX_HOME` that `codex exec` uses before you68Use the installed plugin with a finding from a scan, ticket, advisory, or other
80run these commands. A fresh CI runner doesn't include marketplace plugins by69review. Supply the finding ID and report path, plus a reproducer or validation
81default.70command if you have one:
82 71
83```text72```text
84Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Validate the issue, make the smallest safe change, and add a focused regression test that fails before the fix and passes after it. If that test is unsafe or infeasible, record the proof gap and provide the strongest repeatable validation artifact instead. Verify that the issue no longer reproduces.73Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Verify the issue against this checkout, fix it, and test the original failure and legitimate behavior. Record any verification you couldn't complete.
85```
86
87Include the known source, sink, attacker input, impact, expected invariant,
88reproducer, affected files, and validation command. Codex can inspect the
89repository for missing technical details. It should ask before assuming a
90product policy or intended security invariant.
91
92For an automated run, check out the code, make the finding report available,
93and install the plugin in the runner's `CODEX_HOME`. Then enable workspace
94writes and pass the prompt to `codex exec`:
95
96```bash
97codex exec --sandbox workspace-write 'Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Validate the issue, make the smallest safe change, and add a focused regression test that fails before the fix and passes after it. If that test is unsafe or infeasible, record the proof gap and provide the strongest repeatable validation artifact instead. Verify that the issue no longer reproduces.'
98```74```
99 75
100## Scan and fix findings in CI/CD76This authorizes edits to the checkout. Codex can inspect the repository for
77missing technical details, but may need you to clarify an intended security
78policy before choosing a fix.
101 79
102Install Codex Security in the runner's `CODEX_HOME` before you invoke either80## Run remediation without interaction
103skill. The commands below use the installed plugin; they don't install it.
104 81
105In CI/CD, separate the change scan from remediation and require the scan to82For repeatable scans and patch generation, use the standalone
106leave the checkout unchanged. Preserve the completed scan directory as a job83CLI [validate and patch commands](https://learn.chatgpt.com/docs/security/cli/reference#codex-security-validate-and-codex-security-patch).
107artifact, review the findings, and start a separate Codex task or job for each
108finding accepted for remediation.
109 84
110By default, `codex exec` uses a read-only sandbox. Run both the change scan and85To invoke the installed plugin through Codex CLI, install Codex Security in
111remediation with `--sandbox workspace-write`. The scan needs that permission86the runner's `CODEX_HOME` first. A fresh runner doesn't include marketplace
112to save temporary artifacts, but its prompt must still require `Do not modify87plugins by default. Use a separate checkout or job for each accepted finding:
113the checkout`. Remediation needs the same permission to write the focused
114patch and verification evidence. See [Permissions and
115safety](https://learn.chatgpt.com/docs/non-interactive-mode#permissions-and-safety).
116
117For each scan and accepted finding:
118
1191. Resolve the base and head revisions for the change.
1202. Run `$codex-security:security-diff-scan` against that diff without modifying
121 the checkout.
1223. Preserve the complete scan directory and select the findings to fix.
1234. Invoke `$codex-security:fix-finding` once for each accepted finding, passing
124 its finding ID and completed scan directory.
1255. Generate one focused patch and add a regression test that fails before the
126 fix and passes after it. If that test is unsafe or infeasible, record the
127 proof gap and use the strongest repeatable validation artifact instead.
1286. Verify the original issue and legitimate behavior. Return each patch, test
129 or fallback validation artifact, verification command, and any proof gap
130 independently.
131
132First, scan the change without modifying the checkout:
133 88
134```bash89```bash
135codex exec --sandbox workspace-write 'Use $codex-security:security-diff-scan to review changes from <base-revision> to <head-revision> for security regressions. Do not modify the checkout.'90codex exec --sandbox workspace-write 'Use $codex-security:fix-finding to fix finding <finding-id> from <report-path>. Verify the issue against this checkout, fix it, and test the original failure and legitimate behavior. Record any verification you could not complete.'
136```91```
137 92
138Then fix one accepted finding from the completed scan:93The writable sandbox allows the workflow to edit source and tests. Preserve
139 94the patch and verification evidence for review. For installation, scan setup,
140```bash95and artifact handling, see [Automate reviews in
141codex exec --sandbox workspace-write 'Use $codex-security:fix-finding to fix finding <finding-id> from <completed-scan-directory>. Validate the finding, generate one minimal patch, and add a focused regression test that fails before the fix and passes after it. If that test is unsafe or infeasible, record the proof gap and provide the strongest repeatable validation artifact instead. Verify that the issue no longer reproduces.'96CI/CD](https://learn.chatgpt.com/docs/security/plugin/code-changes#automate-reviews-in-cicd).
142```
143 97
144Repeat the second command in an independent task or job for each remaining98After verification, merge the change through your normal code-review process.
145accepted finding. After verification, merge each patch through your normal99If verification is incomplete, keep the finding open with the remaining work.
146code-review and release process. To hand findings to another team before
147remediation, see [Export or track
148findings](https://learn.chatgpt.com/docs/security/plugin/export-findings).