Files
apex-twin/SECURITY.md
T
lotherk 539b552c3d apex-twin 1.6.0: TLS, Redis, SNMP and DNS zone-transfer checks
Red, deep service checks (tools_proto.c):
- tls_audit: four openssl s_client probes (TLS 1.0/1.1/1.2/1.3) plus a
  -showcerts run, then openssl x509 for subject, issuer, validity and DNS SANs.
  Flags TLS 1.0/1.1 and RC4/3DES/NULL/EXPORT/MD5 ciphers. A failed handshake
  also prints a session block, so success is keyed on 'New, ..., Cipher is ...'
  and (NONE) counts as failure.
- redis_probe: PING on one connection; when it answers without AUTH, INFO and
  DBSIZE follow. Reports open access (audited), version, role, connected
  clients, OS and database size. No password guessing.
- snmp_probe: hand-built SNMPv1/v2c GET sysDescr.0 over UDP, two attempts per
  community (default public/private, max 4), raw answer saved as evidence. No
  net-snmp dependency.
- dns_zone_transfer: dig AXFR against one in-scope server for one in-scope
  zone; record counts per type, up to 200 raw records, full output as evidence,
  and explicit refused/unreachable reasons.

Shared gated_run(): gate, audit and run with the output returned to the caller,
so multi-command tools keep the gate invariant.

Tests: TLS server with a generated certificate, open and AUTH-required Redis
servers, a UDP SNMP agent answering only 'public', an AXFR server with
SOA/NS/A records plus a refusing variant, and the out-of-scope paths. 522
checks, ASan suite green, analyze clean (an analyzer uninitialised-field report
was removed by initialising the token array), release-check green including
distcheck 1.6.0.
2026-11-21 12:23:56 +00:00

7.9 KiB

Security policy and threat model

APEX TWIN is a scope-gated offensive-security MCP server. It is built to be runnable by one operator on one machine, with the gate as the product. This page states what that means, what it does not protect against, and how to report a problem.

Supported versions

The supported line is the one printed by apex-twin --version for the tree you built; this document ships with that same tree. At the time of writing the line is 1.6.x (src/apex.h, APEX_VERSION). Security fixes land on the current line. The 1.0 line promises that the on-disk JSON formats for findings, assets and traffic only gain fields, so state stays readable; older builds are still rebuilt rather than patched in place.

Reporting a vulnerability

Report privately to the owner of the copy you run (the repository owner), not in a public issue, and do not attach live credentials, tokens, customer data or engagement evidence. The state directory contains all of those. Include the version (apex-twin --version), the scope shape that reproduces it (redact targets), the exact tool call or proxy request, and the audit lines around it.

Expect an acknowledgement, a reproduction check against the current tree, and a fix plus a test that fails without it. Reports that show a missing gate are treated as the highest severity: the gate is the reason this program exists.

Trust boundaries

Boundary Inside Outside
Operator scope file, environment, webhook URL, rewrite rules —
Target whatever the scope names everything else
Listener loopback (127.0.0.1) HTTP and proxy LAN/WAN
State $APEX_HOME, mode 0700, files 0600 other users

The scope file is trusted input: whoever can write it can widen the engagement. Protect it like the rest of the state. The webhook URL is trusted configuration; it is never taken from a target. Rewrite rules are trusted configuration and can only narrow what the proxy does (the scope gate still runs first).

What the design defends against

  • Acting outside the engagement. Every tool that names a target calls one gate function; there is no second path that opens a socket or spawns a process. A missing scope refuses everything. A name outside allow_domain must resolve entirely inside allow_ip, and a listed name may not resolve private while allow_private is false — DNS rebinding without a scope change.
  • Ambiguous actions. Deny rules run before the scope in guard_check; a destructive command is refused for what it is, not for a URL that happens to sit in the same line.
  • Radio transmission. serial_tx in the scope and the command allowlist must both pass. A receiver is a scanner; a transmitter is an attack.
  • Silent actions. The audit line is written before the action, so a crash mid-scan still leaves the intent on disk.
  • Accidental exposure. Both listeners bind loopback only; the HTTP face and the proxy do not authenticate.
  • Credential guessing. cred_test makes authentication attempts, but only against an in-scope HTTP Basic endpoint, at most 20 of them, with a 200 ms pause, stopping on 429, and it refuses a path that needs no authentication (nothing to test). Keep the scope and the rules of engagement explicit.
  • SSRF probing only calls your collector. ssrf_probe injects URLs that point at its own loopback listener (or callback_base you supply). It never injects cloud metadata addresses and never reads what the target fetches.
  • Firmware writing needs an explicit confirmation. esp_flash refuses without confirm=true, validates an absolute image path and audits the attempt; it exists to provision the operator's own board.
  • TLS, Redis, SNMP and AXFR stay read-only. tls_audit performs TLS handshakes and reads the certificate; redis_probe sends PING, INFO and DBSIZE only; snmp_probe sends a GET for sysDescr.0; dns_zone_transfer asks one nameserver for one in-scope zone. No writes, no password guessing, no payloads.
  • Service probes are handshakes, not attacks. ftp_probe tries only the literal anonymous FTP pair, smtp_probe sends EHLO and at most 8 VRFY commands, and ssh_audit reads one KEXINIT and never authenticates. Each opens one connection to an in-scope host; nothing is brute-forced and nothing is written on the service.
  • Offline analysis stays offline. jwt_audit and hash_id parse a value the operator supplies; the JWT signature check is local HMAC-SHA256 and no hash is cracked. process_snapshot only reads /proc.
  • Local reads. hardening_audit and ioc_scan read files the operator can already read; log_audit only accepts paths under /var/log/ or the state directory. None of them change anything.
  • Memory-unsafe parsing. Scope, rewrite, HTTP and proxy parsers are fuzzed under ASan/UBSan and gcc -fanalyzer; a sanitizer report is a test failure.

What it does not defend against

  • Local users on the same host. Loopback listeners have no authentication. Any local user who can reach the port can use the MCP server or the proxy within the loaded scope, and can read audit.log only if file permissions let them. Run it as a dedicated user on a host you control, or reach it through a tunnel that terminates on the same account.
  • A malicious scope or rewrite file. These are operator-owned. Writing them is equivalent to being the operator.
  • A malicious target. Responses are data, not instructions; evidence is stored as bytes. The program does not execute target content.
  • TLS interception. CONNECT is a blind tunnel; nothing inside TLS is inspected, logged or rewritten. That is deliberate (no TLS stack is linked).
  • Denial of service from a local client. The proxy and the HTTP face fork a child per connection and cap them (APEX_PROXY_MAX_CHILDREN and APEX_HTTP_MAX_CHILDREN, default 64 each, max 1024); beyond that they answer 503 and audit. The HTTP face also enforces a head/body deadline (APEX_HTTP_HEAD_TIMEOUT_MS, default 20 s) so half a request cannot hold a child forever. evidence_save is capped by APEX_EVIDENCE_MAX_BYTES (default 16 MiB) so one call cannot fill the disk; the cap is audited when it refuses. Per-stage timeouts bound each request, but there is no authentication, so a local client can still consume the allowed slots.
  • Compromised operator credentials. A stolen shell or SSH key can run the binary against the scope. The audit records what was asked, not who asked.
  • Webhook confidentiality. Evidence titles and targets are POSTed to the configured URL. Use an endpoint you trust and TLS where the transport matters.

Hardening checklist

  • Run as a dedicated, unprivileged user; keep $APEX_HOME at 0700 and never on a shared filesystem.
  • Keep both listeners on loopback. Tunnel in; do not expose them.
  • Write the narrowest scope that answers the question, with an expires date and allow_private: false unless the engagement is inside a private net.
  • Leave serial_tx: false unless the rules of engagement authorise transmission.
  • Set APEX_WEBHOOK_MIN_SEVERITY where you want the wake-up; the default is critical.
  • Put secrets in ~/.config/apex-twin/env or the service environment, not in the unit file or in the repository.
  • Back up audit.log and evidence/ before deleting a state directory; both may contain sensitive engagement data. Encrypt the backup.
  • Rebuild and re-run make test after every upgrade; make analyze and make fuzz are the cheap regression checks for parser changes.

Non-goals

APEX TWIN is not an exploit framework, a post-exploitation toolkit, a database reader, a TLS interceptor, a multi-user service, or an agent loop. A feature that adds a shell, reads target data it was not asked to prove, or widens the scope without an operator edit is out of scope by design.

Licence: CNCL 1.1 - Could Not Care Less License; see LICENSE.