Files
mctf/ops/tulip/README.md
T
TakuyaYagam1 6043bc346b fix(towercore): allow peer inventory checks
- keep peer context reads denied with native 0x0203
- preserve opcode 0x23 empty authorized response path
2026-11-29 16:06:23 +03:00

86 lines
4.5 KiB
Markdown

# Tulip deployment
This is a small Docker Compose deployment of [OpenAttackDefenseTools/tulip](https://github.com/OpenAttackDefenseTools/tulip) for Debian 12 on x86_64. It follows upstream `master` at commit `523e5179043a5b6ae1bbcc1990d774f23166319b` (2025-10-06, GPL-3.0). Upstream publishes Compose build definitions rather than release images: TimescaleDB, API, assembler, and the Vite frontend are the minimum useful flow-analysis stack. Optional flag-ID scraping, Suricata enrichment, and PCAP-over-IP are deliberately omitted.
The checkout is pinned, local images use non-`latest` names, and the capture base image is pinned to the current Debian 12 amd64 digest. Upstream Dockerfiles still use mutable language/Timescale base tags and one mutable `pg_hint_plan` branch, so builds are operationally repeatable from a fixed Tulip tree but not bit-for-bit reproducible. Preserve built images for an event and review upstream before changing the commit.
## Required inputs
Copy `.env.example` to `.env`, then set:
- `TICK_START`, `TICK_LENGTH`, `FLAG_REGEX`, and `FLAG_LIFETIME` for the game.
- `VM_IP` and `TULIP_SERVICES`, a one-line JSON array of `{ip, port, name}` objects.
- `TULIP_BIND_ADDRESS`. Keep `127.0.0.1` and use an SSH tunnel, or bind the VPS VPN address. Tulip may display captured flags, so do not bind `0.0.0.0` without a separate authenticated reverse proxy and firewall policy.
- `CAPTURE_INTERFACE=game` when the OpenVPN interface exists on the same VPS.
An empty `capture.bpf` captures all packets on `game`. Put a normal tcpdump/libpcap filter in that file to restrict capture, for example `tcp port 8080 or tcp port 8081`.
## Prepare and start
Run from this directory:
```sh
cp .env.example .env
# Edit .env and capture.bpf before continuing.
git clone --filter=blob:none https://github.com/OpenAttackDefenseTools/tulip.git upstream
git -C upstream checkout --detach 523e5179043a5b6ae1bbcc1990d774f23166319b
test "$(git -C upstream rev-parse HEAD)" = 523e5179043a5b6ae1bbcc1990d774f23166319b
install -d -m 0750 data/traffic data/traffic/.spool
docker compose config --quiet
docker compose build
docker compose --profile capture up -d
```
If captures arrive by `rsync`, NFS, or another sniffer instead, omit the capture profile and place only completed `.pcap` files in `data/traffic`:
```sh
docker compose up -d
```
The first database initialization runs the three SQL files from the pinned upstream checkout. Changing them later does not migrate an existing volume.
## Capture privilege boundary
Tulip itself only receives a read-only capture-directory mount. The optional `capture` service alone uses host networking to see the OpenVPN interface. It is not privileged, mounts no Docker socket or host filesystem, drops every capability, then adds `CAP_NET_RAW` for packet sockets and `CAP_NET_ADMIN` for TUN capture. `tcpdump -p` keeps promiscuous mode disabled. The process remains constrained by `no-new-privileges`.
Captures are written under `data/traffic/.spool` and atomically moved into the watched directory only after tcpdump closes each rotation. This prevents the assembler from ingesting a partial file.
## Verify
```sh
docker compose --profile capture ps
docker compose --profile capture logs --tail=50 timescale api assembler frontend capture
docker compose exec -T frontend node -e "require('http').get('http://127.0.0.1:3000/api/',r=>{process.stdout.write(String(r.statusCode)+'\\n');process.exit(r.statusCode===200?0:1)}).on('error',e=>{console.error(e);process.exit(1)})"
docker compose --profile capture exec -T capture sh -c 'test -e "/sys/class/net/$CAPTURE_INTERFACE"'
find data/traffic -maxdepth 1 -type f -name '*.pcap' -printf '%TY-%Tm-%Td %TH:%TM:%TS %s %p\n' | tail
```
With the default bind, open `http://127.0.0.1:3000` on the VPS or tunnel it:
```sh
ssh -N -L 3000:127.0.0.1:3000 user@vps
```
Health checks cover PostgreSQL readiness, the API, the frontend-to-API proxy, and capture-interface presence. The assembler has no upstream readiness endpoint; Docker restarts it if its process exits, and successful PCAP ingestion is the practical readiness check.
## Stop and rollback
Stop containers while preserving captures, the database volume, checkout, and images:
```sh
docker compose --profile capture down --remove-orphans
```
Remove the database volume as an explicit destructive rollback, while preserving PCAPs:
```sh
docker compose --profile capture down --volumes --remove-orphans
```
After confirming no event data is needed, remove local runtime inputs separately:
```sh
rm -rf -- data/traffic upstream
rm -f -- .env
```