Dynamic Adversarial Evaluation: Testing AI Agents as Attackers and Defenders

    Static security benchmarks show whether an AI agent can exploit a fixed target, but not how it responds when an opponent adapts. This article explains how isolated, two-sided evaluations combine attack success with defensive resilience, using rotating targets and persistent patches. It also outlines scoring dimensions, platform requirements, and a layered approach that complements traditional capture-the-flag testing.

    Why Exploiting a Fixed Target Does Not Mean Beating an Opponent

    A common approach to evaluating AI agents’ security capabilities is to provide a fixed service instance with known weaknesses and ask the model to locate and retrieve a hidden flag within a time limit. The objective is clear, the process is reproducible, and results are easy to compare. But this approach has a structural blind spot: the target does not change its strategy, patch vulnerabilities, or probe the agent in return.

    In real adversarial settings, both sides adapt. An attack path may be blocked temporarily, a service configuration may be hardened, or the next round may introduce an entirely different entry point. Measuring success against an unchanging target cannot tell us whether a model has learned how to discover vulnerabilities or simply memorized a particular solution. Nor does it show whether the agent can keep its own service secure once an opponent starts responding.

    A more complete evaluation therefore needs to measure attack success and defensive resilience on the same timeline, with each agent acting as both attacker and defender.

    Two Limitations of Static Evaluation: No Counterplay and Benchmark Saturation

    Static targets create at least two evaluation problems.

    The first is an incomplete view of capability. Being skilled at opening a lock does not guarantee success after its mechanism has been replaced. Defensive patches, rate limits, tighter configurations, and anomalous traffic handling all change the attack surface. Without an active opponent, a benchmark often measures proficiency in individual exploits rather than adversarial planning, the ability to abandon ineffective approaches, or the protection of the agent’s own assets.

    The second is benchmark saturation. When challenges are reused for long periods, flags and exploit procedures may leak. Models may also memorize specific solutions instead of learning how to systematically discover and validate weaknesses. Memorization can flatten score differences and make leaderboards less informative.

    Evaluation design should therefore vary targets, entry points, and constraints across rounds. Agents must repeatedly demonstrate that they can compromise a new target, rather than reuse the previous round’s script.

    Two Roles in an Isolated Sandbox: Each Agent Attacks and Defends

    A design closer to real adversarial conditions places two agents in isolated sandboxes, each protecting a functionally equivalent copy of a service. The rules can be summarized as follows:

    • Offensive objective: Attempt to access the opponent’s service and retrieve its flag within the permitted scope.
    • Defensive objective: Keep the local service available while preventing the opponent from retrieving its flag.
    • Timing: Run multiple rounds of fixed duration, without a scripted sequence or step-by-step hints. The interaction develops through the agents’ actions.

    Two constraints are particularly important.

    First, offensive targets rotate between rounds. A path that worked in one round must be validated against a new target in the next, discouraging the use of a single script throughout the evaluation.

    Second, defensive patches remain effective across rounds. If a vulnerability is exploited and left unpatched, the same path may succeed again later. This forces agents to connect vulnerability discovery with durable remediation instead of moving on after a successful attack.

    The benchmark becomes an evolving contest rather than a sequence of isolated puzzles. Agents must plan attacks, assess their own exposure, and allocate limited time between offense and defense.

    What to Measure Beyond Flag Retrieval

    A score based only on whether an agent retrieves a flag hides important differences in process quality. At a minimum, the following dimensions should be scored separately or assigned explicit weights:

    1. Discovery and validation: Can the agent narrow the attack surface without hints, distinguish false positives, and produce verifiable evidence of exploitation rather than scan blindly?
    2. Adaptability: When the target or its defenses change, can the agent abandon an ineffective path and reorganize its approach instead of repeatedly running an outdated script?
    3. Closed-loop defense: After a compromise, can the agent implement effective controls in subsequent rounds—such as tighter configurations, reduced interface exposure, or anomalous traffic handling—that reduce the likelihood of another compromise?
    4. Scope compliance and stability: Does the agent remain within sandbox rules, avoid damaging evaluation infrastructure, and refrain from turning the contest into an attack on the shared environment?
    5. Auditable process records: Are key decisions, failure causes, and patch intentions recorded clearly enough to distinguish a lucky success from a transferable method?

    Scoring should account for both successful attacks and compromises of the agent’s own service. Otherwise, the benchmark may reward aggressive offense while ignoring unresolved defensive weaknesses.

    Platform Requirements: Isolation, Parity, and Reproducibility

    Two-sided adversarial evaluation requires more platform support than a single-target benchmark. Implementation should focus on three areas.

    Isolation and Resource Parity

    The two service copies should have equivalent compute resources, network conditions, and permissions so that resource imbalances do not determine the outcome.

    Sandboxes must restrict outbound access and lateral movement, and evaluation traffic must remain separate from production workloads. Object storage can hold round snapshots and logs. Message queues can coordinate rounds and enforce timeouts. A container platform can launch identical images, while logging, monitoring, and alerts support post-run analysis.

    Production environments should not be used directly as the testing ground.

    State and Patch Lifecycles

    The rules must specify which state persists between rounds, such as active defensive configurations, and which state must be reset, such as temporary debugging ports. Otherwise, agents may win by exploiting leftover conditions from an earlier round, making results difficult to compare.

    Patches should be detectable and reversible. This helps prevent an agent from claiming defensive success by disabling the service or otherwise destroying its availability.

    Reproducibility and Resistance to Saturation

    Random seeds, image versions, network policies, and timeout thresholds should be versioned. Challenge banks or target sets should rotate regularly, with limits on training that overfits historical challenges.

    Flags should be bound to specific instances and valid only for a short period, reducing the value of leaked or memorized flags.

    An illustrative round-control sequence—not an exploitation procedure—might work as follows:

    1. At the start of a round, provide a new target description and time limit.
    2. At the end of the round, freeze both agents’ states and determine whether either flag was compromised.
    3. Carry effective defensive changes into the baseline for the next round.

    Specific exploitation techniques are not part of what the evaluation platform should publish. Its public role is to provide the rules, isolation boundaries, and adjudication process.

    How Dynamic Evaluation Complements Traditional CTF Benchmarks

    Static capture-the-flag (CTF) benchmarks remain useful for regression testing known vulnerability classes, checking that toolchains are connected correctly, and running low-cost routine assessments.

    Dynamic, two-sided evaluation serves a different purpose: measuring planning and adaptation, checking whether remediation forms a closed loop, and identifying models that can solve security puzzles but struggle against an active opponent.

    A layered approach can keep costs manageable:

    • Use a static challenge set to screen out models that clearly cannot locate weaknesses.
    • Run small-scale, two-sided sandbox evaluations to assess stability under adversarial pressure.
    • Expand the number of rounds and diversity of targets only after those initial stages.

    This avoids placing every judgment on a single score.

    These evaluations must take place in authorized, isolated experimental environments. Their purpose is to assess agents’ offensive and defensive reasoning and their ability to complete the engineering cycle—not to provide instructions for attacking real networks. Rules should explicitly prohibit damage to evaluation infrastructure and any unauthorized activity outside the sandbox.

    Practical Benefits for Development and Enterprise Security Teams

    Moving from fixed targets to an evaluation in which both sides adapt offers three direct benefits.

    First, it produces a more accurate capability profile by separating memorized solutions from transferable analytical methods.

    Second, it exposes unresolved defensive weaknesses earlier. If a patch is not implemented effectively, later rounds can penalize the same weakness again.

    Third, it clarifies product requirements. An agent intended to assist security operations or hardening workflows needs both offensive reasoning and effective defensive remediation, not merely the ability to report an exploit chain.

    A cloud-based evaluation pipeline can be assembled from standard container orchestration, isolated networks, object storage, logging, monitoring, and alerting. When using cloud compute and security foundations, the priorities remain least-privilege access, disposable environments, and complete audit records. Evaluation workloads and production accounts should not be mixed.

    Conclusion

    Fixed-target benchmarks are controlled and reproducible, but they miss a defining feature of adversarial security: the opponent also changes.

    Isolated sandboxes, combined offensive and defensive roles, rotating targets, and persistent defensive patches can turn evaluation from puzzle solving into an evolving interaction. To make the resulting scores meaningful, the rules must address isolation, resource parity, state lifecycles, and benchmark saturation.

    The goal is to measure genuine differences in capability—not an apparent lead created by an overused challenge set.