ARTEX/docker-compose.ghidra.yml
tifo234123 c0b6d4f29b feat(agent): add optional hardened Ghidra static-analysis sidecar tools (#591)
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.
2026-11-29 21:47:40 +01:00

60 lines
2.3 KiB
YAML

# Optional Ghidra sidecar for static binary analysis (skills/ghidra, ghidra_* tools).
# Enable by adding this overlay to every compose command:
# docker compose -f docker-compose.yml -f docker-compose.ghidra.yml up -d
# Without this overlay the main compose file is unchanged and the ghidra_* tools
# report that the service is not configured.
services:
artex:
environment:
# Empty in .env falls back to the bundled sidecar. Point it at an external
# sidecar to keep this one unused (the container still starts, harmlessly).
ARTEX_GHIDRA_URL: ${ARTEX_GHIDRA_URL:-http://ghidra:9090}
ARTEX_GHIDRA_API_KEY: ${ARTEX_GHIDRA_API_KEY:-}
networks:
- default
- ghidra-internal
depends_on:
ghidra:
condition: service_healthy
ghidra:
# Pinned to the immutable digest: the tag alone can be moved by its publisher.
# The image is linux/amd64 only; on an arm64 host Docker Desktop runs it under
# emulation, which is slow but works.
image: biniamfd/ghidra-headless-rest:1.2.1@sha256:971591a3a8448d8ed969079b452306e806f36079c3ddd298f4a618d6e2f1442d
# No host port and attached ONLY to the internal network: the sidecar has no
# authentication of its own and no outbound internet egress.
networks:
- ghidra-internal
volumes:
- ghidra-data:/data/ghidra_projects
# Read-only root filesystem with bounded tmpfs scratch dirs for Ghidra JVM/temp
# files; the image runs as uid/gid 10001 with HOME=/home/ghidra, so mount
# /home/ghidra directly (never /home) with matching ownership. Analysis
# projects persist in the writable ghidra-data volume above.
read_only: true
tmpfs:
- /tmp:rw,noexec,nosuid,size=512m
- /var/tmp:rw,noexec,nosuid,size=128m
- /home/ghidra:rw,nosuid,size=128m,uid=10001,gid=10001,mode=0700
cap_drop:
- ALL
security_opt:
- "no-new-privileges:true"
pids_limit: 256
mem_limit: 4g
cpus: 2.0
environment:
# One analysis at a time: Ghidra already uses every core it can, and a
# queued job costs nothing but a poll.
MAX_CONCURRENT_ANALYSES: "1"
# Uploads larger than this are refused by the sidecar, not truncated.
MAX_UPLOAD_SIZE: "536870912"
restart: unless-stopped
networks:
ghidra-internal:
internal: true
volumes:
ghidra-data: