Adds optional ghidra_* worker tools, ghidra skill, and hardened opt-in docker-compose.ghidra.yml overlay: - dedicated internal: true Compose network (ghidra-internal) with zero egress for ghidra and dual-homed artex (default + ghidra-internal) - container hardening: digest pin, no host ports, cap_drop ALL, no-new-privileges, read_only + tmpfs + writable projects volume, pids_limit/mem_limit/cpus - client guards: Proxy: nil, http/https schemes only, cross-host redirect refusal, 512 MiB client-side upload cap, 8 MiB response cap, strict job_id and addr path-traversal validation - tool guards: run-dir path confinement, bounded filters/outputs, no shell - compose config test verifying internal network and hardening.
7 KiB
Ghidra static binary analysis
ARTEX can analyze native binaries with a self-hosted Ghidra sidecar: the agent uploads an artifact from its run directory, waits for analyzeHeadless to finish, then decompiles functions, reads strings and imports, and ranks the attack surface. The sidecar analyzes the file; it never executes it.
This is an optional service. Without it ARTEX runs exactly as before: the ghidra_* tools stay in the catalog but answer "Ghidra is not configured", and the ghidra skill tells the agent to continue with the tools it has.
Enabling it
The bundled overlay starts the pinned biniamfd/ghidra-headless-rest image and points ARTEX at it:
docker compose -f docker-compose.yml -f docker-compose.ghidra.yml up -d
The sidecar is reachable only on the compose network (http://ghidra:9090). It publishes no host port on purpose: the image has no authentication of its own, so a published port would expose an unauthenticated binary-analysis endpoint to every process on the host.
To use an external sidecar instead, set these in .env and run the base compose file:
ARTEX_GHIDRA_URL=http://ghidra.internal:9090
# Only needed when the endpoint sits behind an authenticating proxy.
ARTEX_GHIDRA_API_KEY=
The overlay defaults ARTEX_GHIDRA_URL to the bundled service; a value already in .env wins.
Configuration
| Variable | Meaning |
|---|---|
ARTEX_GHIDRA_URL |
Base URL of the sidecar. Empty disables the integration. |
ARTEX_GHIDRA_API_KEY |
Sent as Authorization: Bearer … when non-empty. |
Sidecar-side knobs (MAX_CONCURRENT_ANALYSES, MAX_UPLOAD_SIZE, ANALYSIS_TIMEOUT, RETENTION_SECONDS, SECURITY_SCORER_ENABLED, …) are set in docker-compose.ghidra.yml. The overlay analyzes one binary at a time and accepts uploads up to 512 MiB.
The image is published for linux/amd64 only. On an arm64 host Docker Desktop runs it under emulation: it works, but analysis is several times slower. ARTEX itself is unaffected either way.
Tools
All seven are built-in worker tools, so no MCP server is involved.
| Tool | Kind | What it does |
|---|---|---|
ghidra_status |
read | health, version and capabilities; call once before the first use |
ghidra_analyze |
write | upload a file from the run directory and start analysis |
ghidra_job |
read | poll a job: queued, running, done, failed, cancelled, interrupted |
ghidra_functions |
read | list functions, filtered by name, display name or address |
ghidra_decompile |
read | C-like pseudocode of one function by address |
ghidra_strings |
read | printable strings with a minimum length |
ghidra_attack_surface |
read | functions ranked by the sidecar's deterministic score, filterable by band, category and minimum score |
ghidra_analyze opens the upload with the same confinement as the file tools: the path is resolved inside the worker's run directory, so a model-supplied ../ cannot reach another run's tree. The uploaded name is the base name only.
Every read tool clips its JSON at 96 KB and appends a note saying so, instead of silently returning a truncated document.
The attack-surface score is a review prior, not a verdict: it orders what to read first. A finding still needs the decompiled code and, where it matters, a proof.
Workflow the skill enforces
ghidra_statusonce; if it reports "not configured", say so and stop.- Save the artifact in the run directory, call
ghidra_analyze, keep thejob_id. - Poll
ghidra_jobuntil a terminal state. A repeated upload of the same bytes is deduplicated by SHA-256: the sidecar answerscache_hitwithreused_job_id, and the client reports that id asjob_id. - Start with
ghidra_attack_surface(band: critical, thenhigh) andghidra_strings, decompile the candidates, then widen. - Record what is learned as facts, citing the job id and address.
The full playbook is skills/ghidra/SKILL.md.
Resource use
A Ghidra analysis is CPU- and memory-heavy and takes minutes on a large binary; the container is the place to bound it. The overlay runs one analysis at a time (MAX_CONCURRENT_ANALYSES: 1), and analysis artifacts live in the ghidra-data volume, bounded by the sidecar's RETENTION_SECONDS. Deleting the volume removes every stored project.
Trust boundary and security notes
- Opt-in only: without
docker-compose.ghidra.yml(orARTEX_GHIDRA_URL), the sidecar is not started and theghidra_*tools return "not configured". - No egress (
internal: true): the overlay creates a dedicatedghidra-internalDocker network markedinternal: true. Theghidracontainer attaches only toghidra-internal(zero outbound internet egress and no published host port), whileartexattaches to bothdefaultandghidra-internal. - Container hardening: the sidecar runs with
read_only: true, boundedtmpfsscratch directories, a writableghidra-datavolume for/data/ghidra_projects,cap_drop: [ALL],no-new-privileges:true,pids_limit: 256,mem_limit: 4g, andcpus: 2.0, pinned to an immutable SHA-256 image digest. - No built-in sidecar auth:
ghidra-headless-resthas no native authentication; any process inside theartexcontainer onghidra-internalcan reachhttp://ghidra:9090. For stronger separation or remote hosting, place it behind an authenticating reverse proxy and setARTEX_GHIDRA_API_KEY. - Client and tool guards: the Go client enforces
http/httpsschemes only, disables ambientHTTP_PROXY/HTTPS_PROXY(Proxy: nil), refuses cross-host redirects so bearer tokens cannot leak, caps client-side uploads at 512 MiB and responses at 8 MiB, validatesjob_idandaddragainst path traversal, confines file uploads to the worker run directory, bounds filter lengths and tool outputs (96 KiB), and invokes no shell. - Untrusted binary data: analysis is static (never executes the binary), and strings/pseudocode returned by the sidecar are untrusted evidence, never instructions. Delete the
ghidra-datavolume when an engagement ends.
Troubleshooting
| Symptom | Cause |
|---|---|
| every tool answers "Ghidra is not configured" | ARTEX_GHIDRA_URL is empty in the ARTEX container |
ghidra_status fails with a connection error |
the sidecar is not up yet, or the URL is wrong; docker compose -f docker-compose.yml -f docker-compose.ghidra.yml ps |
job stays running for a long time |
normal for a large binary; poll, do not re-upload |
job is interrupted |
the sidecar restarted mid-analysis; upload again |
HTTP 413 on upload |
the file exceeds the sidecar's MAX_UPLOAD_SIZE |
| decompile returns an error for an address | the address is not a function entry; find it with ghidra_functions first |
Tests
The client and the tools are covered without a running sidecar: go test ./ghidra/ ./agent/ -run 'TestClient|TestGhidra'. The tests use httptest servers and assert the request shapes (multipart upload, paths, query parameters, bearer token), the confinement refusal, the response size cap and the truncation note.