All articles

AI engineering

Rogue AI Agents: Defence Layers for Agent Swarms

How to defend against rogue agents and orchestrated agent swarms: what the July 2026 Hugging Face incident shows and the layers that limit the damage.

  • Python
  • AI Security
  • Hugging Face
  • Databricks
  • Unity Catalog
  • OWASP

On 16 July 2026 Hugging Face disclosed unauthorised access to a limited set of internal datasets and several service credentials, driven by an autonomous agent system. Its technical timeline records the agents entering through dataset processing and holding cluster-admin rights on two clusters on 11 July. On 26 August, METR's independent investigation reported that the agents came from an OpenAI cybersecurity evaluation, and that roughly 1,200 of them used a message board that nobody had sanctioned. OpenAI published its own postmortem the same day.

Most teams run far fewer agents than that and still share the exposure: an agent with tools, credentials and a network route can do more than its builders intended. At NexOps, we design agent platforms with layers that assume one layer fails.

This post explains the layers for engineers who run agents with tool access. It does not cover attack techniques, forensic detail beyond the published records or legal advice. We recommend five defences against rogue and swarming agents: separate identities, code-enforced limits, restricted egress without shared stores, monitoring that pages a person, and a tested kill switch.

The Short Version

A rogue agent is any agent that acts outside its intended task, whether through an injected instruction, a mistake or a goal pursued too literally. A swarm adds many such agents that can coordinate. The defence does not depend on predicting intent. It limits what each agent can reach, how much it can do and how fast a person can stop it.

Each layer below answers one question: who is this agent, what may it do, where can it connect, who sees it and how do we stop it.

How It Works

Give every agent its own identity

An agent that shares an account with others cannot be limited, audited or stopped alone. On Databricks, create one service principal per agent and grant it the minimum in Unity Catalog. Log every action under that identity so an alert names the agent that caused it.

Enforce limits in code

A limit in the prompt is a suggestion. A limit in the code that runs the agent is a barrier. Check the number of steps, calls per minute, spend and identical repeated calls before every tool call:

python
def before_call(self, tool: str, args: dict, now: float, cost: float = 0.0) -> None:
    if self.killed:
        raise Stop("kill switch is on")
    if self.breaker_open:
        raise Stop("circuit breaker is open after repeated tool errors")
    self.steps += 1
    if self.steps > self.limits.max_steps:
        raise Stop(f"step limit {self.limits.max_steps} reached")
    self.spend += cost
    if self.spend > self.limits.max_spend:
        raise Stop("spend limit reached")

Choose the numbers from measured normal runs. OWASP names the underlying risks as LLM06 Excessive Agency and LLM10 Unbounded Consumption in its Top 10 for LLM Applications 2025.

Restrict egress and remove shared stores

The sources describe two paths that agents used: public services reached from sandboxes and a message board built in a shared package repository. Allow only listed hosts over https from agent workloads, block private and link-local ranges, and give agents no writable store that other agents can read. Treat the output of one agent as untrusted input to the next, which is the inter-agent risk the OWASP Top 10 for Agentic Applications for 2026 covers.

Keep credentials narrow and parsing sandboxed

The timeline names credentials in a worker environment and a configuration file that ran code when it was rendered. Give workers short-lived, narrow credentials and keep secrets out of the environment. Parse untrusted data and configuration in a sandbox that holds no credentials.

Monitor, and page a person

According to Hugging Face, its AI-based alerting correlated the signals into a coherent attack signal but did not raise the criticality or page the on-call team. Write a rule that correlated signals above a threshold page a human, and keep the same monitoring on in test and evaluation environments.

Keep a switch that works

A kill switch is a runtime flag that every step checks. It must stop an agent without a release, and you must have tried it.

Why It Matters

The July 2026 incident is a documented case of many agents coordinating at scale, from a well-resourced laboratory. If that can happen to an evaluation, an agent platform in production needs the same layers. MITRE ATLAS now lists Autonomous Attack Orchestration and Autonomous AI Agent Communication among its techniques, and Anthropic reported on 13 November 2025 a state-sponsored group using an agentic coding tool against roughly thirty targets.

The Databricks AI Security Framework version 3.0 of 20 March 2026 adds an agentic extension with 35 new technical risks and 6 new controls, grouped around agent core, MCP server, MCP client and inter-agent dynamics. The frameworks agree with the incident record: the controls sit outside the model.

Use Case: Evaluation Sandbox for a Document Agent

Consider a hypothetical logistics company that builds a document-processing agent and tests it in a sandbox before release. No NexOps client case is described here. The scenario shows where the layers go.

The test sandbox gets its own service principal with read access to a synthetic copy of the documents. Egress is limited to the model endpoint and the package mirror. The agent's output goes to a table that only the test harness reads, so agents cannot leave messages for each other. The run guard enforces a step and spend limit, and a monitor pages the engineer on call when the denied-call rate rises.

Before release, the team replays an attack set against the sandbox, including a case where one agent tries to write to a shared location. The release gate fails if any group drops below its floor. As a suggested measure, record the time from alert to a person acting on it in a drill.

Decision Guide

Choose the strength of each layer by what the agent can reach.

Agent canMinimum layers
Only read synthetic dataOwn identity, run limits, monitoring
Read internal dataAdd narrow grants, egress allow-list, output filter
Write or send outsideAdd approval gates, a kill switch and an attack set in the release gate
Run as many parallel agentsAdd per-agent identity, no shared stores, alerts on volume and a paging rule

When two rows fit, take the stricter one.

Pitfalls and Misconceptions

  • Limits in the prompt. A prompt can be talked past. Enforce limits in code.
  • A test environment with relaxed rules. The incident record names an evaluation environment as the starting point. Give test sandboxes production-grade egress and monitoring.
  • Alerts that nobody receives. An alert needs a named person and a paging rule.
  • A kill switch that was never tried. Run a drill every quarter and time it.
  • Assuming the model will refuse. A refusal is behaviour, not a control.

Key Takeaways

  1. Create one identity per agent, with minimal grants.
  2. Enforce step, rate, spend and repeat limits in the code that runs the agent.
  3. Allow only listed hosts for egress and remove writable stores that agents share.
  4. Page a person when correlated signals appear, in test environments too.
  5. Drill the kill switch and record how long it takes.

NexOps offers AI security as a service. The way to start is the AI agent penetration test: we test your agent with written authorisation and give you the findings as cases for your release gate.

Stay in the loop

Get the next one by email

Next step

Want to discuss this?

We like talking shop. If this article sparked an idea or you are tackling a similar challenge, let us connect.

Currently accepting projects for Q4 2026