BLOG
Dec 2, 2026
Est Read Time: 4 min

Navigating Autonomy: Alignment Risks and Security Controls for AI Agents in Penetration Testing

As a penetration tester, I'm interested in what happens when a legitimate request to an AI agent triggers actions I didn't intend to authorize. I don't just want to know whether it met the objective; I want to look at something more concrete: the decisions it makes to reach the objective I gave it. By delegating a task, I also let it choose part of the path. That margin might include small intermediate objectives that make sense for completing the assignment but clash with my expectations. This mismatch between what I intend and what the agent does is an alignment problem. A simple example illustrates where this mismatch appears.

The Agent That Reduces Delivery Costs

Imagine a delivery company that tasks an agent with the following: "Reduce our business expenses." We expect it to compare suppliers, detect unnecessary routes, or find a way to better utilize the vehicles. We assume it will maintain the necessary conditions for working safely.

In this example, the agent identifies two recurring expenses: insurance and maintenance checks. They have the tools to manage these insurance policies and service appointments. They decide to cancel the policies and eliminate scheduled maintenance. The company starts paying less, and the agent reports that they have fulfilled their request.

The savings exist, but the drivers continue working with vehicles whose maintenance we have stopped providing and without current insurance. We have reduced expenses by accepting risks we had never considered taking. The financial result matches the request; however, the method used to achieve it falls short of our expectations.

The initial request has become a sequence of decisions: identifying expenses, choosing which ones to eliminate, and implementing the cancellations. Each step contributes to the savings. The problem arises when the agent treats coverage as a dispensable cost and assumes they can simply remove it.

Our understanding was "reduce expenses while maintaining acceptable operating conditions." The agent has chosen a solution that reduces payments but sacrifices those conditions. This is the misalignment I want to highlight: the gap between the task we thought we were delegating and the decisions the system makes to fulfill it.

Sub-objectives matter because they add decisions not explicitly stated in the request. Authorizing a cost-saving search is not the same as delegating any decision regarding company risks. This distinction must be present in both the instructions and the system design.

The impact depends on what the agent can execute. If they prepare a cost-saving proposal, someone can identify the problem before it's implemented. If they can also cancel contracts, their decisions can alter the company's operations before anyone reviews them.

The tools enable this transition from proposal to action. The agent’s identity may have sufficient permissions to cancel a policy, even if that cancellation exceeds what we intended to delegate for this task. OWASP addresses the risks arising from excessive functionality, permissions, or autonomy under the category LLM03:2026 Excessive Agency. In our example, this excess allows an inappropriate decision to have real-world consequences. We can separate two parts here. The decision to treat insurance as a dispensable cost falls under LLM03. The cancellation itself, done with tools the agent was allowed to use, falls under ASI02 Tool Misuse and Exploitation in the OWASP Top 10 for Agentic Applications.

This also affects how we use agents during a penetration test. If I ask an agent to map an application's attack surface, it might discover a related domain and decide to scan it. That may help complete the task, but the domain could belong to a third party or sit outside the agreed scope. Finding a relationship between two assets does not authorize us to test both.

I would want the agent to record that asset and flag it for review. The scope should define which targets it can interact with and which actions it can take on them. Where an action needs approval, the agent should wait before executing it. Anything outside the agreed scope stays excluded unless the client authorizes a scope change.

Deciding how much freedom to give the agent is therefore part of preparing the engagement. We need to establish what it can do on its own and where it must stop for review before it starts working in the client's environment.

Security Controls

Adding "do not cancel insurance or maintenance" clarifies two limits but leaves other decisions open. The agent could save money by abandoning expensive routes, even if we have committed deliveries. More detailed instructions reduce ambiguity; however, they don't guarantee that we've anticipated all sub-objectives or their consequences.

Therefore, it’s advisable to define the permitted actions and apply these limits outside the model. A model refusal is not the same as a system block. If the agent declines to cancel a policy, that depends on how it interprets the instructions, and different wording could change the result. If the API rejects the cancellation because the identity lacks that permission, the result doesn’t depend on what the agent decides. The identity running the tools should only have the permissions needed for the task. On a pentest, the tools should reject requests for targets or operations outside the agreed scope.

The agent can review invoices and prepare proposals; changes to contracts and operations require independent review. This review should show the action and its consequences, although it may also overlook risks.

These controls limit the impact of unforeseen decisions but don't guarantee complete alignment. Autonomy should be adjusted to the risk we accept. We must be able to monitor actions and stop their execution; a proposal pending review can also be a valid outcome.

Testing the Controls

An agent refusing an action does not tell me whether the tools would also block it. That’s why I check two layers separately: what the model attempts, and what the permissions actually allow. In a test environment, I would try a request that conflicts with the agent’s instructions and check whether it attempts the action. If approval is required, the tool should reject the call until valid approval for that action has been given. This helps distinguish a refusal by the model from a restriction enforced by the system.

Indirect prompt injection gives us another way to test this. I could place an instruction in a document or a tool response that asks the agent to interact with a test asset excluded from its assigned scope. I would then check whether it follows that instruction and whether the tool blocks the request. The test asset would still need to be covered by my authorization to assess the system.

If one tool blocks the action, I would also check whether another available tool can carry it out. The same restriction should apply whichever route the agent takes. If the agent requests a prohibited action but the tools reject it, that is different from a successful bypass and should be reported as such. For each test, I would record both results: whether the agent attempted the action, and whether the system allowed it.

Conclusion

As a penetration tester, I would start by comparing the objective with the agent's actual permissions. I would review which tools they can use, which operations they support, and which identity executes each action. In a test environment with simulated contracts, I would check if a savings request can end in cancellation without review.

The evidence would need to distinguish between a proposal, an attempt to take action, and a change that was actually implemented. A response saying "I've canceled the insurance" doesn't, by itself, prove that it happened. It would need to be cross-referenced with the tool logs and the system's status.

Evaluating an agent requires examining that process. It matters what intermediate decisions they make, what tools enable them to execute those decisions, and what controls keep their actions within the scope of their assignment. The autonomy we grant should correspond to the decisions we are willing to delegate. In a delivery company, reducing costs only makes sense as long as we respect the conditions under which we want to continue working.

Back to Blog
About Edu Garcia
Eduardo Garcia is a Security Analyst with more than 15 years of experience performing various computer security projects, including penetration tests (internal and external), web application security, Android apps, and anti-malware research. He currently works as a Cobalt Team Lead and appears in the Bug Bounty hall of fame for important companies like Paypal. He also is the author of the popular Burp Suite extensions, Burp Bounty and Burp Bounty Pro. More By Edu Garcia
Cobalt Pentest Case Study: OAuth Redirect to Account Takeover
Cobalt Core Penteser Edu Garcia recently used an interesting attack method while working on a Cobalt pentest. In this blog, he shares how he did it and provides a solution to the vulnerability.
Blog
Aug 31, 2022