Back/Engineering/Codex
IntermediateEngineering

Automate Security Vulnerability Remediation with AI

Turn a vulnerability report into scoped code fixes, tests, and a traceable remediation record.

Automate Security Vulnerability Remediation with AI

08:28 to 11:00: Claire exports a security assessment, gives the findings to Codex, and uses the coding agent to investigate and remediate the issues in the real codebase.

Before you start

What you need

  • A current vulnerability export with identifiers and severity
  • The affected repository and test commands
  • Rules for secrets, production access, and excluded systems

What you’ll make

A focused remediation branch that resolves confirmed findings and records evidence for any accepted exception.

Tools used

  • Codex

    OpenAI's cloud-based AI software engineering agent that can execute code, run tests, and handle complex multi-file tasks autonomously.

    VisitCodex

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

4 steps

Step01

Export Vulnerability List

Download or export the list of security issues identified by your security scanning tool, such as OpenAI's Codex Security product, into a CSV file. This file will serve as the complete context for the AI.

Example prompt
Export finding ID, severity, affected path, evidence, and recommended mitigation in a machine-readable file.
Step02

Upload to Codex

Upload the CSV file containing the list of vulnerabilities directly into the OpenAI Codex interface. The model will use this file as its source of truth for the required fixes.

Example prompt
Open the target repository and load the security report without accessing production secrets.
Step03

Prompt the AI for Remediation

Provide a direct, high-level command instructing the AI to analyze the issues from the CSV, group them thematically, propose architectural changes, and then implement those changes in the code.

Example prompt
For each finding, confirm whether it is real, reproduce it safely, implement the smallest fix, and add a regression test.
Step04

Review and Validate

The AI will analyze the list, propose architectural changes, and implement the code fixes. Your task is to perform a thorough human review. Validate the logic of the architectural changes and the quality of the generated code before merging the fixes.

Example prompt
Review the diff against every finding and run the security and regression checks before closing any item.

What good looks like

  • Each change maps to a specific finding
  • The exploit or failing condition is reproduced before the fix when safe
  • Security and regression tests pass on the changed surface

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

The scanner finding is a false positive
Inspect the cited path and document why the condition cannot occur.
The agent fixes symptoms but not the boundary
Define the trust boundary and add a regression test for the exploit condition.
The patch expands into a broad refactor
Limit the task to confirmed findings and necessary tests.

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready