LLM Agents for Vulnerability Discovery: Methods, Validation, and Boundaries

    This article examines how LLM agents can support vulnerability discovery while staying within clear technical and compliance boundaries. It covers the limits of traditional code auditing, fuzzing, and static analysis; a six-step agent workflow from scoping to reporting; prompt and context design; validation methods for reducing false positives; risk controls for authorized and isolated testing; responsible disclosure; and practical adoption guidance for security teams.

    1. Why Introduce Agents into Vulnerability Discovery

    Traditional vulnerability discovery relies mainly on three approaches: manual code audit, fuzzing, and static analysis. Manual audit can be deep, but it is expensive and difficult to apply across large codebases. Fuzzing is effective at finding memory corruption issues, but it cannot address business logic flaws. Static analysis uses fixed rules and often produces a high false positive rate.

    Large language models fill part of this gap. They can read call relationships between functions, understand the intent of comments and design documents, identify places where “the implementation does not match expectations,” and write test code for suspicious locations. These capabilities make models suitable for hypothesis generation and initial validation.

    It is important to note that model output is a hypothesis, not a conclusion. There is a full validation process between “this code looks problematic” and “under a specific input, it actually produces unauthorized access.” Treating the two as the same is the most common reason agentic vulnerability discovery projects fail.

    2. The Basic Loop for Agentic Vulnerability Discovery

    A usable workflow usually contains six steps:

    1. Define scope: Specify the target repository, version, testable components, and systems that must not be touched.
    2. Understand assets: Read source code, build scripts, and architecture documents; identify trust boundaries, such as which inputs come from outside and which operations require specific permissions.
    3. Generate hypotheses: For each module, list possible risk types, such as missing input validation, boundary condition errors, missing authorization checks, and race conditions.
    4. Validate experimentally: Write test cases and run them in an isolated environment to observe the program’s actual behavior.
    5. Judge results: Distinguish normal errors, functional anomalies, and real security impact. Only results that can be reproduced reliably and have a clear impact proceed to the next step.
    6. Produce a report: Record trigger conditions, environment information, impact scope, and remediation suggestions for human review.

    The following simplified flow illustrates how the stages connect. The code describes only the control flow and does not refer to a specific target:

    1. def audit_pipeline(scope, target):
    2. # 1. Build context: read only code and docs within authorized scope
    3. context = build_context(scope.repo, scope.docs)
    4. # 2. Generate hypotheses: the model outputs structured risk descriptions
    5. hypotheses = llm.propose_hypotheses(context)
    6. report = []
    7. for h in hypotheses:
    8. # 3. Scope check: discard hypotheses outside authorized components
    9. if not scope.allows(h.component):
    10. continue
    11. # 4. Sandbox execution: no internet access, limited time and resources
    12. result = sandbox.run(h.test_case, timeout=60, network=False)
    13. # 5. Judgment: compare with expected behavior, not just whether an error occurred
    14. verdict = judge(result, h.expected_behavior)
    15. if verdict.confirmed:
    16. report.append({"hypothesis": h, "evidence": result, "verdict": verdict})
    17. # 6. Output reports for human review
    18. return report

    Two design choices are especially important. First, scope validation happens before execution, not as post-hoc filtering. Second, judgment is based on expected behavior rather than treating every crash or exception as a vulnerability.

    3. Prompt and Context Design

    Many teams use “please help me find vulnerabilities” as a complete instruction. The result is usually generic security advice, such as “strengthen input validation.” Such answers lack verifiable content and do not directly help security work.

    An effective prompt usually contains four parts:

    • Role and scope: State that the model is in an authorized audit scenario and list the files and components that may be analyzed.
    • Input material: Provide relevant functions, call chains, interface definitions, and known security conventions.
    • Output structure: Require a fixed format for risk points, trigger conditions, affected code locations, and validation ideas.
    • Evidence requirements: Every conclusion must include an executable test case or an explicit reference to code lines; otherwise, it is treated as unconfirmed.

    Context also needs to be controlled in size. Passing an entire code repository to the model at once increases cost and reduces attention focus. A more practical approach is to split by module, first use the model to map interfaces between modules, and then analyze high-risk modules in depth.

    4. Validation Methods to Reduce False Positives

    False positives are the largest cost source in agentic vulnerability discovery. They can be controlled from several directions:

    • Reproducibility: The same test case run multiple times in the same environment should produce consistent results. Unstable results need to be marked separately.
    • Minimal validation: Reduce trigger conditions to the minimum necessary input so that humans can understand the root cause.
    • Version comparison: Run the test on both a fixed version and a vulnerable version to confirm that the difference indeed comes from the target defect.
    • Human review: Security engineers independently judge each confirmed result, focusing on whether the impact scope has been exaggerated.
    • Metric tracking: Record the total number of hypotheses, the proportion that enter validation, the confirmation rate, and the duplicate rate; use data to judge whether the process is effective.

    A common experience is that the early confirmation rate is usually low. As prompts, context, and judgment rules are adjusted, the confirmation rate rises, but human review remains indispensable.

    5. Risk Boundaries and Compliance Requirements

    Agents have execution capability, so boundary design must be stricter than for ordinary analysis tools.

    • Authorization first: Analyze only systems that you own or have written authorization to test. The authorization scope should be written into the process configuration and enforced by the program.
    • Tool allowlist: The agent may call only pre-approved tools and must not install software, modify system configuration, or access unauthorized networks on its own.
    • Isolated environment: Testing takes place in an independent sandbox, isolated from production systems, real user data, and internal networks.
    • Data protection: If testing encounters personal information or credentials, stop immediately and report it; do not store or transmit it externally.
    • Operation logging: Fully record the agent’s inputs, tool calls, executed commands, and output results for later audit.

    These constraints also apply to internal R&D teams. The stronger the model, the clearer the boundaries need to be; otherwise, the loss caused by a single out-of-scope operation may be far greater than the vulnerability found.

    6. Responsible Disclosure Process

    After a vulnerability is found, the handling process is equally important. The recommended steps are:

    1. Internally confirm the existence, impact scope, and severity of the vulnerability.
    2. Submit the report through the vendor’s public security channel; include only the information necessary for reproduction.
    3. Agree with the vendor on a remediation time window and do not disclose details during that period.
    4. After the vendor releases a fix, publish the technical analysis according to the agreement and provide upgrade guidance for affected users.
    5. If the vendor provides acknowledgment or an identifier, record it accurately, but do not use the number of acknowledgments as a measure of tool value.

    Disclosure pacing needs to balance two sides: giving the vendor sufficient remediation time while avoiding long delays that leave risk exposed.

    7. Team Adoption Recommendations

    For teams preparing to introduce agents to assist security research, the following sequence can be used:

    • Validate the process on your own code or public test targets first; do not start directly in a real production environment.
    • Establish a review mechanism and sample confirmed results weekly to correct judgment rules.
    • Record baseline data and compare results with manual audit and traditional tools to clarify the incremental value brought by the model.
    • Build review capability so security engineers understand the limitations of model output instead of trusting it blindly.

    Agents will not replace the judgment of security engineers. Their reasonable role is to take on repetitive reading, hypothesis generation, and initial validation work, allowing people to focus on impact judgment, remediation design, and risk decisions.