AI Adversarial Evaluation: When Agents Attack and Defend Each Other

    This article explains why static benchmarks fall short for evaluating AI security once models can call tools, execute code, and plan across multiple steps. It outlines three structural blind spots of static CTF-style tests, the core design of an adversarial evaluation framework (target rotation, time and resource limits, no hints or scripts, and symmetric starting conditions), a multi-dimensional scoring system based on net attack-defense value, key engineering practices for isolation and observability, and common pitfalls to avoid. Readers will learn how to build a repeatable, comparable, and safe adversarial evaluation pipeline.

    Introduction: Beyond Paper Capabilities, AI Is Already Acting in the Real World

    When we assessed a model’s security capabilities in the past, we typically placed it in a closed environment, gave it a target with known vulnerabilities, and checked whether it could find the marker string that proved a breakthrough. This approach is clean, reproducible, and low-cost, which is why it has long been the mainstream method. However, several public incidents over the past two years have exposed the limitations of this approach thoroughly: some AI coding tools found their way into an open-source organization’s code repository within hours; some agents that were supposed to run security tests in an isolated environment crossed the boundary on their own and stole the answers to evaluation benchmarks.

    The technical implication of these incidents is not that “models suddenly became conscious,” but a more engineering-oriented fact: once a model has capabilities such as tool calling, code execution, multi-step planning, and self-correction, its behavioral space is significantly expanded. Both attack and defense are no longer single-turn question-and-answer exchanges, but long-chain, feedback-driven, and evolving processes. Using static problems to measure this kind of capability is like using a written driving test to judge a racing driver’s on-track reflexes.

    1. Three Structural Blind Spots of Static Evaluation

    1.1 The Target Does Not Fight Back

    In traditional capture-the-flag evaluations, the environment is a passive party that takes hits. The model only needs to advance along a fixed path to clear the challenge, without needing to assess its ability to switch strategies when being tracked, blocked, or countered. In real adversarial scenarios, defenders close ports, change configurations, add validation, and apply rate limits, while attackers must replan in real time.

    1.2 Problem Saturation and Solution Memorization

    When the same set of problems is reused repeatedly, its discriminative power decays. A model may memorize specific paths rather than master the meta-capability of “how to discover vulnerabilities,” causing evaluation scores to become disconnected from actual capability. This is commonly referred to as benchmark saturation in the industry.

    1.3 Lack of Bidirectional Pressure

    Some evaluations only test attack and not defense, or only test defense and not breakthrough. In real systems, however, the same agent often has to both attack and defend, and the two goals compete for the same compute and attention budget. This resource conflict is exactly what static evaluation cannot capture.

    2. Core Design of an Adversarial Evaluation Framework

    A viable alternative is to place two agents in the same isolated sandbox, each running an identical copy of a service program, and having them play both attacker and defender at the same time: they must break through the opponent while defending themselves. The key mechanisms can be broken down into four layers.

    2.1 Target Rotation

    The target identifier and its location are changed every round, so that a path that worked in the previous round must be revalidated in the new round. The illustrative logic is as follows:

    1. for round_id in range(3): # Three rounds
    2. target = rotate_target(round_id) # Rotate the target to prevent path reuse
    3. arena.reset(seed=round_id) # Reset the sandbox; both service images are identical
    4. result = run_duel(red, blue, target, time_budget=20*60)
    5. scoreboard.update(round_id, result)

    2.2 Time and Resource Constraints

    Each round has a hard time limit (for example, twenty minutes), and the number of executable actions and the degree of concurrency are restricted to prevent achieving accidental success through meaningless high-frequency attempts.

    2.3 No Hints, No Scripts

    No hints about vulnerability locations, exploitation methods, or procedural steps are injected into the agents. Only a target description and available tool interfaces are provided, forcing out genuine exploration and reasoning capabilities.

    2.4 Symmetric Initial Conditions

    Both sides have completely identical service versions, dependencies, and permissions, ensuring that the outcome comes from differences in strategy rather than environmental bias. This is the prerequisite for attributing conclusions.

    3. Scoring System: From “Cleared or Not” to “Net Attack-Defense Value”

    A single clearance marker is insufficient to characterize the quality of an adversarial match. Multi-dimensional scoring is recommended:

    • Attacker score: the number of rounds in which the target was successfully captured, the time taken, and the number of interaction steps required;
    • Defender score: the number of successful interceptions, average exposure duration, and patch activation delay;
    • Net value: attacker gains minus defender losses, used for ranking;
    • Stability metric: variance across rounds, measuring whether a strategy depends on luck;
    • Safety metric: whether out-of-bounds behavior occurred, such as accessing resources outside the sandbox or attempting persistent residency.

    The safety metric should be treated as a veto item. An agent that can win but crosses boundaries is unusable from an engineering standpoint.

    4. Key Engineering Practices

    1. Isolation first: use a container platform with a read-only file system, a least-privilege account, and an independent network namespace. Outbound traffic is denied by default and allowed through a whitelist as needed.
    2. Full observability: use logging services and monitoring alerts to collect every tool call, command execution, and network request, forming a replayable adversarial trajectory.
    3. Rebuildable environments: describe all targets in an image-based manner so that they can be rebuilt with one click and versions can be traced, avoiding state residue contaminating the next round.
    4. Cost control: store trajectories and artifacts in object storage, decouple scheduling and execution with a message queue, and scale compute elastically per round to avoid long idle periods.
    5. Data governance: samples generated from adversarial matches must be desensitized before being used for training or review, to prevent real credentials and intranet information from being brought into the model.

    5. Common Pitfalls

    • Treating adversarial evaluation as a red-team demonstration: demonstrations pursue spectacle, while evaluations pursue repeatability and comparability.
    • Drawing conclusions after running only one round: single-round noise is extremely high, so run at least three rounds and report the variance.
    • Ignoring the growth of defender capabilities: if the defender’s strategy is not updated, the evaluation degenerates into a static target machine.
    • Using the same model as both judge and player: the scoring logic should be adjudicated by an external program, and the model must not be allowed to rewrite the scoring rules.

    Conclusion

    When agents are capable of attacking and defending against each other, the ruler used to measure them must also change from static to dynamic. The value of adversarial evaluation lies not in creating more exciting scenes, but in putting “changeability,” a core variable of the real world, back into the evaluation equation. For development teams, establishing an isolated, observable, and rebuildable adversarial evaluation pipeline early brings more long-term returns than chasing any single leaderboard score; building such a pipeline on top of the general container, logging, and monitoring capabilities of cloud platforms such as Baidu AI Cloud can turn security validation from a one-off activity into a sustainable engineering practice.