Docs / Reference / Security

Security

SwarmLabRE reads files that may be hostile and lets language models act on them. This page says what it defends against, how it does that and what it does not claim. It describes version 0.1.0.

The trust boundary#

The host process is the only trusted part. It holds the model's key, the board and the reports. The sample, the agents, what the tools print and the model's answers are untrusted, and neither container has a network.

Host: trustedThe SwarmLabRE process. It parses the sample, runs the board, holds the gate and thekey, and writes the reports.Tools container--network none. Reads the sampleat /in, read-only. Runs Ghidra,jadx, Apktool and rea. Has nomodel socket.Agents container--network none. Six roles, one uideach. Reads /in and /prep,read-only. Reaches the tool socketand the model socket.Model endpointOutside the host. The gate sendsit requests and adds the key. Nocontainer reaches it. Host: trustedThe SwarmLabRE process. It parses the sample, runsthe board, holds the gate and the key, and writesthe reports.Toolscontainer--networknone. Readsthe sample at/in,read-only.Runs Ghidra,jadx, Apktooland rea. Hasno modelsocket.Agentscontainer--networknone. Sixroles, oneuid each.Reads /in and/prep,read-only.Reaches thetool socketand the modelsocket.ModelendpointOutside thehost. Thegate sends itrequests andadds the key.No containerreaches it.
What the agents can reach. Dashed red boxes are containers with no network; the dashed grey box is outside the host. Arrows go from the host to what it starts or calls.

What it assumes is hostile#

  • The sample. Its bytes and strings are written by an attacker: markers that imitate SwarmLabRE's own protocol, text that tells a model what to do, HTML, ANSI and bidi controls, spreadsheet formulas, Markdown links, over-long values, malformed ELF, PE and APK headers, and archives with odd names or links.
  • The agents. A model steered by that text may post false findings, forge lines, write hostile prose, cite tool calls it never made, or try to read another role's files.
  • What the tools print and what the containers write. That is the output of Ghidra, jadx, Apktool and rea, and every file in a run folder that a container could have written.
  • Anything that can reach the web UI's port, including a web page in a browser on the same machine.

What it protects#

AssetWhat must not happen to it
The host and its filesA sample, an agent or a tool reads or changes them.
The model's API key, if one is usedIt leaks into a container, a log, a report or a recording.
The truth of a reportText in a sample, or an agent, makes a finding look checked, or a link or tag reaches a viewer.
The recorded runAn accidental or careless edit goes unnoticed. A deliberate edit is not covered; see the last item of the limits.

What it does about each threat#

Each entry names a threat, says what SwarmLabRE does about it and names where the code and its tests are.

A sample or an agent runs code#

The sample is only read, never executed. The agents run in containers as the host user's uid and not as root, with --read-only, --cap-drop ALL, no-new-privileges, limits on memory, processors and processes, and --network none. Each agent role has its own uid and its own private tmpfs. The sandbox lists every setting.

Where to look: swarmlabre/sandbox.py, tests/test_sandbox.py.

A container reaches the network#

--network none is the only network the code will build. Before a run, a throwaway container shows that it has no interface besides loopback and cannot connect to a public address. A run does not start when the probe finds an interface or a route out, or when it gives no clear answer. A running container is also inspected for a writable root, kept capabilities, privileged mode, a mounted Docker socket and a writable proxy folder.

Where to look: Health and posture in swarmlabre/sandbox.py.

The model key reaches a container#

The key stays in the host process. A container reaches the model only through a Unix socket that the run owns and that is mounted read-only, and the gate adds the key on the host side. The agent's configuration holds no key, the scrubber hides the key in log strings, and a run does not start when the docker inspect output of a container contains it. The gate also sets temperature, seed and model, sets n to 1 and caps the output tokens, so an agent cannot spend the endpoint on another model or on many completions. Use a real model describes the gate.

Where to look: swarmlabre/gate.py, swarmlabre/client.py, tests/test_gate.py, tests/test_sandbox.py.

A forged finding line sits in a sample's strings#

A finding is read only from a line that carries the task's own nonce, in the agent's own tool-result stream. The nonce is an HMAC of a per-run key over the role and the task number, so a line copied from a sample does not carry it. The board describes the post.

Where to look: HostileStrings in tests/test_golden.py, tests/test_board.py.

A false finding looks verified#

The board checks every post again: the bytes at the offset, that each cited call exists in the run's tool log and appears in output of the agent's own session, the function list, the ATT&CK id and name against MITRE's table, and the caps and duplicates. The evidence caps the verdict and the confidence. A model's judgement never changes a count, a level or a hash. The limit on call citations is listed under what it does not claim.

Where to look: Board in swarmlabre/swarms.py, swarmlabre/report.py.

Hostile text reaches a viewer#

Everything that came from a sample, an agent or a tool is cleaned, capped and set as text. The report defangs network indicators, a CSV cell that could be read as a formula gets a leading quote, and report.md escapes <, > and link syntax.

Where to look: the golden case hostile, tests/test_report.py.

A container writes a hostile file back#

Archives are parsed and never extracted. Paths are resolved inside the container, files are opened with O_NOFOLLOW, sizes and counts are capped, and the run folder is treated as untrusted data.

Where to look: read_tar in swarmlabre/swarms.py.

A web page or another user drives the UI#

The server listens on loopback by default. Every api/* call needs a bearer token. The token is made on first use, kept in a file with mode 0600 in the state folder and printed in the address fragment that serve prints at every start. A Host header that is not loopback is refused, which stops DNS rebinding. JSON bodies are capped at 1 MiB. The page is sent with default-src 'none', connect-src 'self' and frame-ancestors 'none'. The files the page offers for download are report.html, iocs.csv, iocs.stix.json, iocs.misp.json and detection.yar; they are sent as attachments with a Content-Security-Policy of sandbox, so they are never rendered in the server's origin. The web UI has the details.

Where to look: swarmlabre/server.py, tests/test_server.py.

A recorded run is changed afterwards, by accident#

manifest.json holds the SHA-256 of every input and output. swarmlabre replay exits 1 on a differing byte, an edited recorded file, a sample that is not the one the manifest names, or an output file in a bundle that is not the recorded one. serve --replay and the demo build refuse a run that does not replay. A bundle is copied without following links and with a size cap. Reproducibility covers what replay checks.

Where to look: swarmlabre/replay.py, tests/test_replay.py.

What it does not claim#

  • Docker is not a perfect boundary. A flaw in the kernel or the container runtime could let a process leave a container. Run SwarmLabRE on a machine and an account where that would be survivable, and keep Docker and the kernel current. The host firewall rules of the project it came from are not included, and --network none is the only network control here.
  • No run on real malware is part of any check. The tests, the golden cases and the demo use generated benign files only, with reserved example domains, documentation addresses and code that only exits. How the parsers, Ghidra, jadx or the agents behave on hostile real-world files is not verified here.
  • The parsers have not been fuzzed. The ELF, PE and APK readers are hand-written Python with size limits and tests on hand-built files. A crafted file may crash a run, and a failed run keeps what the board built.
  • A verdict is a model's opinion. byte-checked means that the bytes are at that offset and not that the agent understood them. A report can still be wrong, incomplete or misleading about what a file does.
  • A model can be steered. The defences stop a sample from forging the protocol and from becoming a verified fact without evidence. They do not stop a model from believing, repeating or acting on text in a sample inside its own sandbox, and they do not make the Reporter's prose accurate.
  • Live runs are not repeatable. Only replay of a recording is byte-identical; Reproducibility says what a live run pins.
  • One environment was tested. Everything was run on Linux arm64 with Python 3.12.3, one Docker installation and one locally served model for the live checks. Other kernels, CPU architectures, Python minor versions, Docker versions and container runtimes are untested. The tools image builds for arm64 only.
  • The web UI is for one person on one machine. It has no user accounts, no HTTPS and no rate limiting. A non-loopback --host prints a warning, and the token is then the only protection and travels in clear text. Do not put it on the internet.
  • The static demo and replay mode show a recording. They add no evidence and check nothing again; the byte-for-byte check is swarmlabre replay.
  • A call citation is attributed by text and not by the tool server. A finding is call-cited when each cited call id exists in the run's tool log and appears in the output of a command in that agent's own session. An agent that can run shell commands can print another role's call id, and SwarmLabRE cannot tell that from a real call of its own. So call-cited means that the call exists in this run's tool log and that the agent's session printed its id, and not that this agent made it. The roles share one tool server, and attributing calls per role by peer uid is not built.
  • The agents' tool socket binds only some tools to the sample. On the locked socket the Android tools (inspect_android_* and the related search, decode and trace tools) accept only the pinned sample path. Other tools that take a file path, for example inspect_artifact, inspect_signature and inspect_pe_resources, are allowed but not bound, so a steered agent could point one at another file inside the tools container. That is the run's input folder, the tool output and the result cache, with no key or host file mounted there. Binding them needs the tool schemas of the real rea image and was not done.
  • Tamper evidence is not authentication. manifest.json holds hashes and nothing signs it. Someone who edits a recorded file can recompute its hash and the manifest's, and replay then agrees. The hashes detect an accidental change and a forgery that forgot the manifest, not a determined one. Keep the origin of a run by other means, such as a signature or a trusted copy of the manifest hash, if that matters.
  • No third party has reviewed this code. The two skills in skills/ are prompts for a model and not security controls.
  • Third-party software is installed into the images at build time. Ghidra, jadx, Apktool, Binwalk, mitmproxy, the pi agent and rea are pinned to a version. The Debian packages are not, and the Node base image is pinned only to its tag, node:22-slim. A vulnerability in any of them is outside this repository's control. THIRD_PARTY.md lists what is used.

The golden cases do not cover a failed, stopped or timed-out run, a packed, multi-DEX or 32-bit sample, or other machines, and those gaps apply here too. Golden cases lists them, and CI says what runs on every push.

Reporting a problem#

SECURITY.md says how to report a vulnerability and which versions get fixes.

SwarmLabRE alpha 0.1.0Edit this page on GitHub