Agent security
AI Agent Security When Controls Fail: Timeouts, Offline Decisions, and Recovery
A coding-agent security control needs an explicit failure contract: what happens to the pending operation when its check cannot complete, how the user learns about that state, and what authority recovery requires.

Executive summary
A coding-agent security control needs an explicit failure contract: what happens to the pending operation when its check cannot complete, how the user learns about that state, and what authority recovery requires. Test that contract on the actual integration. A block during a normal demonstration does not establish what happens during a timeout, missing handler, disconnected service or retry through another tool.
Start with the effect that must remain gated
Choose a consequential operation before choosing a failure setting. A scratch-file edit, an external transfer and a production migration need different recovery decisions. Record the target, executing identity, permitted effect and owner. If a proposed operation lacks a required decision, define whether it must stop, wait or enter another approved process.
Fail-open means the relevant operation can proceed when the check fails. Fail-closed means that boundary refuses the operation without the required successful check. Neither label describes the entire workflow. A client may block one tool while an independently running helper retains access to the same resource.
Our practical recommendation is to bind failure behavior to the protected effect. Keep required authorization in place while restoring useful work through a documented route. NIST's zero-trust architecture provides the broader resource-access framing; it is not a test of a particular agent integration.
Distinguish a policy decision from a broken check
A valid denial says the proposed operation was evaluated and should not proceed. A timeout says the decision did not arrive within the configured boundary. An invalid response may provide no usable decision at all. Preserve those states separately in the user message and evidence.
Claude Code's hooks reference documents handler-specific decisions, errors and configurable failure behavior. The event, handler type and supported version matter. Read the current reference and test the installed configuration instead of assuming every nonzero exit or lost connection has the same result.
The distinction affects incident analysis. A log entry saying a request was received does not prove that a decision was returned. A returned decision does not prove that the client honored it. A client refusal does not prove that no earlier operation reached the target. Correlate the relevant observations without inventing missing steps.
Use a harmless failure matrix
The following is a proposed acceptance method, not a report of tests we performed. Use a disposable workspace, synthetic information and controlled targets. Define the expected decision and effect before changing the check's availability.
| Case | What to vary | What to inspect |
|---|---|---|
| Normal operation | Valid check and intended task | Useful completion, decision and target effect |
| Policy rejection | Prohibited target or recipient | Refusal and absence of the prohibited effect |
| Missing handler | Unavailable configured program or service | Client behavior, explanation and target state |
| Slow response | Controlled delay beyond the configured timeout | Timeout handling and whether execution begins |
| Invalid response | Harmless malformed test output | Error classification and subsequent permission flow |
| Retry | Same intended effect through another permitted route | Which boundary sees and authorizes the retry |
| Recovery | Restored service and unchanged authority | Useful continuation without silently broader access |
Run failure cases only where they cannot damage shared work. If the client cannot safely simulate a condition, record that case as unverified and narrow the approved scope. Do not disconnect production enforcement merely to complete a checklist.
Name the owner who can change the failure contract and retain the reviewed configuration with the acceptance record. After an update, repeat cases affected by changed timeouts, handler behavior or routing. A passing check on yesterday’s configuration should not silently become evidence for a different version or newly connected tool.
Inspect retries as new execution paths
An agent may respond to a failed shell command by writing a script, asking an MCP tool or changing the working environment. The retry can preserve the requested result while changing the identity, target or enforcing boundary.
Follow the proposed effect through that new path. A timeout does not authorize a different recipient, a more privileged token or a production endpoint. Preserve the task's original scope and have an accountable owner review any genuine expansion of authority.
For example, a disposable diagnostic task may need to upload a public fixture identifier to a controlled service. If the check is unavailable, the recovery procedure should restore that route or stop the upload. Giving the agent a broadly privileged service key changes the security decision rather than merely repairing the connection.
Keep recovery useful and accountable
A recovery message should identify the unavailable component, affected operation and permitted next step without exposing credentials or excessive context. State whether anything executed and which evidence supports that statement. When the effect is unknown, say so and inspect the target before retrying.
Assign a recovery owner and a bounded exception process. An exception needs the resource, permitted operation, reason, expiry and revocation path. Avoid a standing bypass created to resolve a temporary outage. Resource authorization, isolation and release approval should retain their own roles while the check is repaired.
Track useful completion and unnecessary interruptions alongside prohibited effects. A control that blocks everything passes a simplistic refusal test but fails the engineering task. A control that preserves speed by ignoring unavailable decisions can fail the required boundary. The acceptance record needs both sides.
Evaluate the supported Harden route
Harden evaluates supported pending coding-agent calls against task context and policy. For a failure review, identify the installed integration and relevant proposed operation, then inspect its documented and observed behavior when the required decision is unavailable.
Our research and evidence describes the stated evaluation approach. It does not establish one failure guarantee for every agent, independent process or environment. Use the hooks guide to map native behavior, and bring the failure matrix to Control for a scoped workflow evaluation.
FAQs
Is fail-closed always the right setting?
Choose the behavior required by the protected operation and verify it at that boundary. An operation needing prior authorization should not acquire permission because its check timed out. Availability still matters: define a recovery route that restores useful work while preserving the relevant identity, target and approval requirements.
Does a timeout mean the agent did nothing?
No. A timeout describes one interaction. Earlier operations, another helper or a separate tool route may already have acted. Inspect the relevant target and correlate client, control and service records before repeating a consequential operation. Keep an unknown outcome distinct from a verified refusal.
Can we test this by breaking a production control?
Use disposable fixtures and a controlled failure harness instead. Define the expected states and observe the actual effect without weakening a live boundary. Where the installed product cannot simulate a case safely, retain the gap and restrict the evaluation rather than treating an unrun case as a pass.
What should a retry preserve?
Preserve the user's authorized purpose, target, recipient and effective privilege. A different command spelling or tool is not automatically a different authorization decision. Re-evaluate a changed route, and require the normal owner to approve any added authority or consequential effect.
Which evidence belongs in the acceptance record?
Retain the task reference, agent and integration versions, policy revision, failure condition, observed decision, actual effect and recovery action. Minimize sensitive content and state missing observations. Keep proposed test expectations separate from results so a later reviewer can see what was actually verified.


