AI Penetration Testing: How Agentic Pentesting Works
Skip to content

AI Penetration Testing

AI penetration testing is security testing in which an AI model does work that a human penetration tester would otherwise do by hand.

On this page

In its agentic form, also called agentic pentesting, AI agents read the target, choose the tests, run them and record the evidence. The agents still work inside a scope, limits and approvals that people set.

This guide explains what the terms mean, how agentic testing compares with manual and automated testing, how an agent run works, where a human tester is still needed, and the controls that keep testing safe on production systems.

What AI Penetration Testing Means

The term AI penetration testing, often shortened to AI pentesting, covers several ways of working, from a model that assists a human tester to agents that run the test themselves. The United Kingdom’s National Cyber Security Centre describes a penetration test as a way of gaining assurance in the security of a system by attempting to breach it with the tools and techniques an adversary might use. The guide to penetration testing covers the types, phases and rules of a test.

The terms in use overlap. They differ in who decides the next step.

  • AI-assisted testing: A human tester leads the test and uses a model to read code, draft test requests or summarize tool output.
  • Automated penetration testing: Software runs a prepared sequence of scans and exploits without a person at each step, and it may contain no AI model at all.
  • Agentic penetration testing: AI agents decide what to test next from what they have learned so far, run the tools themselves and keep a record of each result. Autonomous penetration testing is another name for it.

Joint guidance from ASD’s ACSC, CISA, the NSA and partner agencies, Careful Adoption of Agentic AI Services, describes an agentic AI system as one or more agents that rely on an AI model to interpret the state of the world, make decisions and take actions.

Testing the security of AI models themselves is a different subject, usually called AI red teaming.

Manual, Automated and Agentic Testing

Manual, automated and agentic testing differ mainly in how the next step is chosen and in how often a test can run.

Area Manual testing Automated testing Agentic testing
Who decides the next step A human tester A prepared playbook AI agents, inside limits set by people
Adapts to the target Yes, through the tester’s judgment Only where the playbook allows for it Yes, the plan changes with each result
Frequency Typically once or twice a year On a schedule On each change and on a rolling schedule
Strongest at Business logic, novel flaws, people and premises Repeating known exploit chains Reading each system and testing access, sign-in and configuration
Result A report at the end of the engagement A list of exploited paths Confirmed findings as they are found, each with proof
Retest By arrangement Next scheduled run When a fix is reported

Automated testing is older than the current AI models, and it stops where a target behaves differently from what the playbook expects. Agentic testing adapts to a target the way a tester would and repeats the work as often as software can.

A vulnerability scanner is a different tool again, and the guide to penetration testing vs vulnerability scanning compares the two.

Degrees of Agent Autonomy

Autonomy in agentic testing is a setting chosen for each scope, and it ranges from an agent that proposes every step to one that works alone inside an enforced policy. The setting decides which choices are delegated to the agents and which stay with a person.

  • Step approval: The agent reads the target and proposes each test, and a person approves it before anything is sent.
  • Approval by test class: Reading and low-impact checks run unprompted, while named classes, such as using a discovered credential or testing a sign-in with real accounts, wait for a person.
  • Bounded autonomy: The agent plans, tests and confirms on its own inside the policy, and people review the findings and the run record afterward.

The joint agentic AI guidance recommends graduated autonomy, in which an agent’s independence increases step by step while human oversight is kept. It also recommends continuous evaluation to decide when to widen a system’s scope and when to roll its autonomy back.

In testing, that translates to a level recorded for each target. A new or fragile system typically starts with step approval, and an unreproducible finding or a blocked attempt to leave the scope is a reason to move a level down. Scope, excluded methods and logging apply equally at every level, so autonomy changes who chooses the next test while the boundary on what any test may do stays where the system owner set it.

How an Agent Run Works

An agent run follows the order a human tester would follow, with a planning agent directing worker agents and a shared record holding what has been learned. NIST SP 800-115 groups a penetration test into planning, discovery, attack and reporting, with results from the attack phase feeding further discovery. An agent run keeps that loop and goes around it many times.

  1. Load the task. People define the targets, exclusions, test accounts, permitted methods, time window and goal before the run starts.
  2. Read the target. The agent collects what each host serves, from pages, scripts and API descriptions to sign-in flows, configuration files, software versions and certificates.
  3. Form a plan. The planning agent turns what was read into specific tests, for example checking whether an API route that returns an invoice by its number accepts a number belonging to another account.
  4. Run the tests. Worker agents take one test each, run tools such as nmap and curl, and write the request, the response and the outcome to the shared record.
  5. Confirm the result. A suspected weakness is repeated and reduced to the least intrusive request that demonstrates it. A result that cannot be reproduced is dropped or passed to a person.
  6. Follow the path. Where a confirmed weakness gives new access, the planning agent adds tests from that position, stays inside the scope, and stops at any step that needs approval.
  7. Report and retest. Each finding is recorded with the affected asset, the proof, a severity and the fix, and the same test runs again when the fix is reported.

AI models can also state things that are untrue, and the confirmation step exists for that reason. A finding counts when a recorded request and response prove it.

How the Plan Adapts

The plan adapts because each result is written to the shared record, and the planning agent reads that record before it chooses the next test. Take a run against a staging site that an organization left online after a project ended.

  1. First reading. The site serves a directory listing that names a backup archive, and a sign-in page for an administration console that shows its product name and version.
  2. First plan. The planning agent lists tests for what was read: whether the archive is served to an anonymous visitor, and whether a published advisory covers that console version.
  3. A result that adds tests. A request for the archive’s headers alone returns its size and type. That proves the file is served, and nothing is downloaded. The agent records the finding and adds a check for other files that follow the same naming pattern.
  4. A test that waits. An advisory describes an authentication bypass in the console version. Proving it would open an administrator session, so the test is queued for a person to approve.
  5. A result that is dropped. A redirect that looked exploitable on the first request behaves normally on the second. The agent drops it, and both requests stay in the run record.

A playbook would have sent this host the same list of checks as any other. Here the later tests exist only because of what the earlier ones returned, and the guide to inside an agentic penetration test follows a single test with the evidence kept at each step.

Where Agents Are Strong

Agents are strong where testing calls for reading a large amount of material, covering many systems evenly and repeating work without delay.

  • Even coverage: A small or forgotten host receives the same attention as the main application, which a time-boxed engagement can rarely afford.
  • Speed after a change: A test can start minutes after a new host appears or a fix is reported, and the guide to continuous penetration testing covers what triggers a test and how often to run one.
  • Reading at volume: Agents read every script, API description and configuration file a host serves, where a person samples them.
  • Chained weaknesses: The shared record lets one agent build on what another found, so separate weaknesses are combined into a single path.
  • Known exploited vulnerabilities: When a product appears in CISA’s Known Exploited Vulnerabilities Catalog, agents can check every exposed instance the same day.
  • Exact retests: The request that proved a weakness is stored, so the retest repeats the original test exactly.

Where a Human Tester Leads

A human tester is still needed where a test depends on understanding the business, on people and premises, or on independent assurance. NIST SP 800-115 describes penetration testing as labor-intensive work that requires great expertise, and the NCSC advises that third-party tests be performed by qualified and experienced staff.

Area Why a person leads
Business logic Knowing that a refund should never exceed the order, or that an approval step can be skipped, requires knowing what the application is for.
Social engineering and physical access NIST notes that penetration testing often includes non-technical methods, such as calling the help desk while posing as a user, which sit outside what a software agent tests.
Novel vulnerability research Finding a new class of flaw in custom code or a protocol typically takes sustained human investigation.
Fragile and safety-critical systems Where a malformed request can stop a process, a person decides what is safe to send and when.
Independent assurance Standards, regulators and customers may call for a test by an independent, qualified party with a signed report.
Objective-led exercises Red teaming tests detection and response against a goal over weeks, with human operators making the decisions.

In most environments the models run together. Agents cover the exposed estate between engagements, and the human-led test spends its limited days on the areas in the table.

Safety Controls on Production Systems

Agentic testing is made safe on production by limits that are set before the run and enforced outside the AI model. NIST SP 800-115 states that penetration testing poses a high risk because it uses real exploits against production systems.

The joint agentic AI guidance adds a second reason for caution: it advises organizations to assume that agentic AI systems may behave unexpectedly and to prioritize reversibility and risk containment. The controls below follow from both documents.

  • Written authorization: The system owner confirms ownership of the targets and signs the rules of engagement before any run.
  • Scope in network policy: The agent runs in an isolated environment whose outbound connections reach in-scope targets only, so an out-of-scope request fails whatever the model decided.
  • Excluded methods: Denial of service, data modification and data removal are typically excluded outright.
  • Least intrusive proof: The agent demonstrates a weakness with the smallest action available, such as reading one record in place of a full export.
  • Rate limits and time windows: Request rates are capped, and sensitive systems can be limited to agreed hours.
  • Human approval: Higher-impact tests wait for a person, and the guidance says the decision about when approval is required belongs to designers and operators and is never delegated to the agent.
  • Interruption: An operator can watch a run and stop it while it is in progress.
  • Protected logs: Every request and tool call is logged, the tools come from an approved list, and the guidance recommends that agents have no write access to the logs.

Prompt Injection From the Target

A tested page can contain text written to instruct the agent that reads it. The NCSC explains in Prompt injection is not SQL injection (it may be worse) that a language model has no inherent boundary between instructions and data, and it advises deterministic safeguards outside the model that constrain what the system can do.

For a testing agent, the scope and the excluded methods are those safeguards. Because they are enforced by the sandbox and the tool layer, text in a tested page cannot widen them.

Data the Agents Handle

An agentic test passes target data through one more place than a manual test, because whatever the agents read is sent to an AI model to be interpreted. NIST SP 800-115 asks for data handling requirements to be documented in the assessment plan or the rules of engagement, covering how assessment data is collected, stored, transmitted and destroyed. For an agent run, the same document also covers the model.

  • Content sent to the model: Pages, responses and files the agents read become model input, so the agreement names the model provider, the region where processing takes place and whether inputs are retained.
  • What the proof keeps: A proof holds the request, the response status and an identifier, and personal data in a response body is left out of the record.
  • Test accounts: Credentials supplied for a test are limited to that test, and the joint guidance recommends ephemeral credentials that expire when the job is complete in place of static, long-lived secrets.
  • Secrets found on a target: A key or password the agents discover is reported by its location and type with the value masked, and using it is a higher-impact test that waits for approval.
  • Stored records: NIST notes that assessment data in an adversary’s hands would provide a roadmap for exploiting the organization’s systems, and it recommends encryption and access limited to the people whose roles require it.
  • Retention and removal: The agreement states how long run records are kept and how they are removed when the period ends.

Where an organization has data residency obligations, the region in which the model processes its input matters as much as the region in which the records are stored.

Records an Agent Run Leaves

An agentic test should leave enough records for a third party to reconstruct what was tested, how and with whose approval.

Run record What a reviewer learns Kept in
Authorization and rules of engagement Who approved which targets, methods and time windows. A signed document held by the system owner and the provider.
Enforced test policy The targets, exclusions, rate cap and excluded methods as configured, and any blocked attempt to leave the scope. The test policy in the provider’s console and the sandbox’s network policy and log.
Request and response log Every request the agents sent, with its time and the response. The provider’s run log, which should match the target’s own web server and firewall logs.
Source addresses and user agent Which requests in the target’s logs were the agents’. The provider’s published test addresses, compared with the target’s access logs.
Finding proof The minimal request and response that demonstrate the weakness. The finding record.
Agent reasoning and tool calls Why each test was chosen and which tool ran it. The run trace, in a form a person can read.
Approval history Who approved a higher-impact test, and when. The finding or run history.
Retest result The stored proof request sent again after the fix, and what came back. The finding history.

The target’s own logs are the independent check on the provider’s record. Where the system is monitored, the security operations team should see the test traffic, which also tests detection.

Checking Agent Quality

The quality of agentic testing is measured by how often the agents’ findings hold up and how reliably the limits hold. Each measure below is calculated from records a run already leaves.

Measure How it is calculated What it shows
Reproduction rate The share of reported findings that a person reproduces from the stored proof. Whether the confirmation step works.
Withdrawn findings Findings that were reported and later withdrawn after review. How many false results reach the organization.
Blocked requests Out-of-scope connection attempts recorded in the sandbox’s network log. How often the agents try to leave the scope, and whether the enforcement stops them.
Approval requests The number raised, the share approved and the time each one waited. Whether the approval threshold sits at the right level.
Log agreement The share of requests in the provider’s log that also appear in the target’s own logs. Whether the provider’s record is complete.
Planted weaknesses found Results from a run against a test application built with known weaknesses. What the agents miss.
Run consistency The difference in findings between repeated runs against an unchanged target. How far the results depend on chance.

These measures are worth collecting from the first run, since an agent’s behavior may change when the AI model behind it is updated or replaced. The joint guidance recommends multiple independent monitoring systems that cross-validate agent reports and system logs, which is the purpose of the log agreement measure.

Time from change to test and time to fix measure the program around the agents, and they belong with continuous testing.

Agentic Testing in a Security Program

Agentic testing is one part of a wider program and depends on the practices around it.

  • Attack surface discovery: Agents test only the systems that are known, so testing follows external attack surface management, which finds them.
  • Exposure management: In a continuous threat exposure management program, agentic testing supplies the validation stage.
  • The attacker’s method: Attackers run agents of the same design against organizations. The guide to AI hacking covers that side and the traces such agents leave.

The output of the agents reaches several roles, and each uses it differently.

  • Security lead: The security lead sets the scope, the autonomy level and the approval classes for each system, and reviews the quality measures.
  • System owner or IT manager: The owner receives each finding with its proof and fix steps, schedules the fix and reports it so that the retest can run.
  • SOC manager: The SOC manager holds the test source addresses, and treats test activity that raised no alert as a detection gap to close.
  • MSP or MSSP: A provider keeps a separate scope, authorization and run record for every client it delivers testing to.

Size changes the starting point. A small organization with no testing program typically begins with its internet-facing systems, while a larger one with its own testers hands the agents the repetitive coverage and keeps its people on business logic and research.

Questions to Ask a Provider

The answers to these questions belong in writing before any test starts.

  • Scope enforcement: Ask where the scope is enforced, and whether an out-of-scope request is blocked by the network or only discouraged in the agent’s instructions.
  • Excluded methods: Ask for the list of test types the agents never run and the list that waits for approval.
  • Confirmation: Ask how a finding is confirmed before it is reported, which findings a person reviews, and to see a sample finding with its proof.
  • Model and data: Ask which AI model provider receives what the agents read, where it is processed, and what is kept afterward.
  • Stopping a run: Ask who can stop a run and how quickly it takes effect.
  • Test traffic: Ask for the source addresses and user agent, so the monitoring team can tell the test from an attack.
  • Human-led work: Ask what the service leaves to a human-led test, such as business logic and social engineering.

Coverage, retest terms, pricing and audit outputs apply to any testing subscription, and the guide to penetration testing as a service covers how to choose a provider on those points.

A First Scope at Low Autonomy

The first weeks are best spent on a small scope at a low autonomy level, with the records checked by hand before the scope widens. The joint guidance advises limiting the initial use of agentic AI to low-risk, well-defined tasks, and the same approach suits a first test.

  1. Choose a first scope. Pick a few internet-facing systems that tolerate ordinary traffic, and place fragile or business-critical systems on the exclusion list for now.
  2. Enter the policy and test it. Have the targets, exclusions, request rate, hours, excluded methods and approval classes configured, then ask the provider to show an out-of-scope request being blocked.
  3. Run with step approval. Approve the first tests one at a time and read the agent’s reasoning for each, which shows how it chooses.
  4. Reconcile the logs. Compare the provider’s request log with the web server and firewall logs for the same hours, and have any request that appears on one side only explained.
  5. Reproduce the first findings. Have a person replay each proof request before a fix is assigned.
  6. Route the findings. Agree where findings arrive, who owns the fixes for each system and how a fix is reported so that the retest runs.
  7. Widen one change at a time. Add hosts, a test class or a higher autonomy level separately, and review the measures after each change.

Written authorization, ownership checks and third-party consent come before any of these steps, as they do for a human-led test.

AI Penetration Testing With ThreatDefence

ThreatDefence applies the controls in this guide to its own agentic penetration testing, which is available now. The service is part of an AI SOC platform, with a 24x7 SOC behind it, built to automate security monitoring, compliance and cyber risk management.

  • Scope in a sandbox: The testing agent works from an isolated sandbox, and the sandbox’s network policy lets it reach confirmed and authorized targets only.
  • Least intrusive proof: A weakness is shown with the smallest action that demonstrates it, and denial of service and any change to or removal of data are excluded.
  • Approval for higher impact: A test that could have a larger effect waits for a person to approve it, and SOC analysts review significant findings.
  • A full record: Each request the agent sends and each result it gets back is logged for review.

Where an organization needs social engineering, internal network testing or a formal attestation, an independent human-led test can run alongside.

Frequently Asked Questions

What is the difference between AI pentesting and agentic pentesting?

AI pentesting is the broad term for any penetration test in which an AI model does part of the work, including a human tester using a model as an assistant. Agentic pentesting is the narrower case where AI agents choose the tests, run the tools and record the results themselves. Autonomous penetration testing usually means the same thing as agentic.

Is AI penetration testing the same as automated penetration testing?

No. Automated penetration testing runs a prepared sequence of scans and exploits, and it may contain no AI model. AI penetration testing in its agentic form writes its plan for each target and changes that plan as results arrive, so it can test a route or sign-in flow that no playbook anticipated.

Can AI agents replace human penetration testers?

No. Agents cover exposed systems broadly and repeat the work as often as needed, but a person still leads on business logic, social engineering, physical access, novel research and fragile systems. Standards and customers may also call for a test by an independent, qualified tester. In most environments the agent and the human tester work on different parts of the problem.

What stops a pentesting agent from leaving its scope?

The scope is enforced outside the AI model. The agent runs in an isolated sandbox whose network policy permits connections to in-scope targets only, so a request to any other host fails regardless of what the model decided. Excluded methods and approval steps are enforced in the tool layer in the same way.

Can a tested website manipulate a pentesting agent?

Yes, it can try. A page may contain text written as instructions for the agent, which is known as prompt injection, and the NCSC has explained that a language model cannot reliably separate instructions from data. The defense is to keep scope, permitted methods and credentials under controls the model cannot change.

Do AI pentesting agents report false positives?

Yes, they can, because an AI model may describe a weakness that does not exist. A well-built service handles this with a confirmation step: a finding is reported only when a recorded request and response demonstrate it, and anything the agent cannot reproduce is dropped or passed to a person. Ask a provider how confirmation works.

Will agentic testing trigger security alerts?

Yes, it may, and that is useful. Test traffic looks like attack traffic, so the monitoring team should receive the source addresses and user agent in advance. Comparing what the agents did with what the monitoring detected shows how well the same activity from a real attacker would be seen.

Can a person stop a pentesting agent during a run?

Yes. A run can be watched while it is in progress and stopped by an operator, and higher-impact tests pause for approval before they are sent. The joint agentic AI guidance from ASD’s ACSC, CISA and partner agencies recommends human control points throughout an agent’s workflow, including live monitoring and interruption during task execution. A provider should say who holds that control and how quickly a stop takes effect.

Is target data sent to an AI model during an agentic test?

Yes. Whatever the agents read on a target, including pages, responses and files, is passed to an AI model to be interpreted. The agreement with the provider should name the model provider, the region where processing takes place, whether inputs are retained, and how long proofs and run records are kept.

Do repeated agent runs against the same target give the same results?

No, they may differ. The joint agentic AI guidance notes that agents may generate different actions even when prompts appear identical, so a second run can choose its tests in a different order or stop at a different depth. A retest is the exception, because it replays the stored proof request exactly.

Talk to Our Experts

See how ThreatDefence automates security monitoring, compliance and cyber risk management in one platform.

    I'm an MSP, MSSP, or reseller

    By submitting this form, you accept the terms in our privacy policy.