Three new tools (406 total): - opendkim_audit (blue): opendkim.conf and /etc/opendkim - inet: milter socket reachable from the network, RequireSafeKeys no, Mode without "s" (verifies but never signs), Syslog debug leaking content and key paths. An empty tree reports no-config instead of missing Socket/Mode lines. - rspamd_audit (blue): UCL config and local.d fragments - bind_socket on *, 0.0.0.0 or :: with a port, clear-text password/enable_password and secure_ip 0.0.0.0/0 or ::/0 (password check skipped for every client). Fragments matched by .conf, .inc and .local; "*:port" counts as wildcard. - confluence_probe (red): /status plus /rest/api/space?limit=5 on 8090 without a token; the space list is saved as evidence, 401/403 is closed. Evidence: make test 1501/1501, test-asan 1501/1501, analyze 0 warnings, 240 fuzz cases clean, gate-audit 406 tools from 14 tables, distcheck 1.94.0 builds and passes from the tarball, release-check exit 0 (371 s). Red proof: with the Mode sign check disabled the opendkim check fails (1500 passed, 1 failed), then rolled back.
20 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.94.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_domainmust resolve entirely insideallow_ip, and a listed name may not resolve private whileallow_privateis 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_txin 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_testmakes 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_probeinjects URLs that point at its own loopback listener (orcallback_baseyou supply). It never injects cloud metadata addresses and never reads what the target fetches. - Firmware writing needs an explicit confirmation.
esp_flashrefuses withoutconfirm=true, validates an absolute image path and audits the attempt; it exists to provision the operator's own board. - git/npm/pip config audits read local files. The Harbor probe sends two unauthenticated GETs and saves the project list.
- passwd/authorized_keys/ld.so.preload audits read local files. The Gitea probe sends two unauthenticated GETs and saves the admin list.
- Bluetooth/NetworkManager/D-Bus audits read local files. The Nexus probe sends two unauthenticated GETs and saves the repository list.
- USBGuard/certbot/WPA audits read local files. The Jenkins API probe sends two unauthenticated GETs and saves the job list.
- resolved/udev/issue audits read local files. The SMTP AUTH probe reads the banner and EHLO features; no login is attempted.
- OpenSSL/curl/wget configuration audits read local files. The TLS chain probe performs one handshake and reads the presented certificates.
- Compose, manifest and Dockerfile audits read one local file each. The AMQP probe reads Connection.Start and never sends credentials.
- atd, securetty and tmpfiles audits read local files. The Logstash node probe sends two unauthenticated GETs and saves the stats answer.
- sshd_config, hosts_access and profile audits read local files. The Kibana probe sends two unauthenticated GETs and saves the saved-objects answer.
- Telegraf, Graylog and Netdata audits read local files. The ClickHouse probe sends two unauthenticated GETs and saves the query answer.
- Logstash, Filebeat and Fluentd audits read local files. The InfluxDB probe sends two unauthenticated GETs and saves the query answer.
- Kibana, Nagios and Synapse audits read local files. The NATS monitoring probe sends two unauthenticated GETs and saves the varz answer.
- Webmin, Cockpit and phpMyAdmin audits read local files. The MinIO probe sends two unauthenticated GETs and saves the admin answer.
- GitLab, Vaultwarden and keepalived audits read local files. The Grafana probe sends three unauthenticated GETs and saves the datasource list.
- Zabbix, NRPE and unattended-upgrades audits read local files. The RabbitMQ probe sends two unauthenticated GETs and saves the overview.
- Gitea, MinIO and Nextcloud audits read local files. The Prometheus probe sends two unauthenticated GETs and saves the query answer as evidence.
- Caddy, Traefik and autofs audits read local files. The CouchDB probe sends two unauthenticated GETs and saves the database list as evidence.
- FreeRADIUS, containerd and NATS audits read local files. The Consul probe sends two unauthenticated GETs and saves the first answer as evidence.
- Kafka, PowerDNS and Varnish audits read local files. The registry probe sends two unauthenticated GETs and saves the catalog as evidence.
- iSCSI, rpcbind and kdump audits read local files. The etcd probe sends three unauthenticated GETs and saves the first answers as evidence.
- Avahi, logind and tftpd-hpa audits read local files. The ZooKeeper probe sends only the stat and mntr four-letter commands, no data.
- pgbouncer, xinetd and SSSD audits read local files. The FTP TLS probe reads the banner and sends AUTH TLS without logging in.
- dnsmasq, nsswitch and Jenkins audits read local files. The TLS hostname check is one handshake with the name as SNI.
- journald, coredump and nftables audits read local files. The HSTS check makes one TLS GET.
- Certificate, timesyncd and resolv.conf audits read local files. The
certificate audit parses each file with
openssl x509; no network is used. - pg_hba, polkit and LDAP client audits read local configuration. The FCrDNS check performs a PTR lookup and then forward A/AAAA lookups.
- Chrony, APT and login.defs audits read local configuration. The WebSocket origin check performs two upgrade handshakes and opens no data frames.
- Cron and fail2ban audits read local configuration; the redirect check
makes GETs.
http_redirect_auditfollows up to five redirects and re-checks the scope of every hop before following it. - WireGuard, IPsec and OpenLDAP audits read local configuration. They
never touch a tunnel, a key exchange or a directory. The dangling-CNAME check
follows a chain with
dig. - Kubernetes and NS checks are unauthenticated reads.
kubernetes_api_probesends four GETs without a token;dns_ns_consistencyqueries NS/A records. Grafana and Prometheus audits read configuration files. - mTLS detection is one handshake.
tls_client_auth_probereads the CertificateRequest froms_client -msgand presents no certificate. Consul, Vault and ZooKeeper audits read configuration files. - SNI checks are TLS handshakes only.
sni_vhost_checkconnects once per in-scope name and reads the certificate; Kubernetes, etcd and RabbitMQ audits read configuration files. - CAA is one DNS query.
dns_caa_checkreads the CAA records of an in-scope domain; it does not request a certificate. BIND, Tomcat and ProFTPD audits read configuration files. - Wildcard DNS is one query.
dns_wildcard_checkresolves a random label under an in-scope domain and reads the answer. The MongoDB, memcached and NTPD audits read configuration files. - WebDAV is one OPTIONS and one PROPFIND.
webdav_probesends a read-onlyDepth: 0property request and never writes a resource; rsync/dhcpd/krb5 audits read configuration files. - ALPN is one handshake per protocol.
alpn_probenever sends application data; squid/unbound/CUPS audits read configuration files. - OCSP is read from one handshake.
tls_ocsp_probeopens one TLS connection withopenssl s_client -statusand reads the stapled response; it does not contact the OCSP responder itself. - STARTTLS is a handshake, not a login.
smtp_starttls_probesends EHLO, STARTTLS and reads the TLS handshake; it never authenticates and never sends mail. PHP, Dovecot and OpenVPN audits read configuration files. - DNSSEC checks are two DNS queries.
dnssec_checkasks for DNSKEY and DS records of an in-scope domain and decodes the public key size; it never validates a chain or contacts a registrar. - Daemon configs are audited read-only.
postfix_audit,nginx_auditandredis_config_auditparse their configuration files and never signal, reload or talk to the daemon. Redis passwords are reported as present or absent, never echoed. - Config audits are local reads.
snmpd_auditandrsyslog_auditparse configuration files;winrm_probeissues one unauthenticated GET to /wsman. - Exports and Samba checks are local reads.
nfs_exports_auditandsamba_auditparse configuration files;kerberos_discoveryonly queries DNS SRV records for an in-scope domain. - Protocol and key checks stay read-only.
http2_probeperforms one ALPN handshake or one h2c preface;ssh_hostkey_fingerprintruns ssh-keyscan or parses a saved output;logrotate_auditreads config files. - Metadata fetches are plain GETs.
oidc_discoveryandsecurity_txtrequest their well-known paths without credentials;ssh_known_hosts_auditreads local key files. - NTP and DNS version checks are single queries.
ntp_monlist_probesends one mode-7 GETLIST and reports the reply size;dns_version_bindsends two CHAOS TXT queries;usb_auditreads sysfs. - Header-injection probes do not persist anything.
crlf_probesends one encoded CRLF in a parameter and reads the response;esp_image_verifyandaudit_rulesare offline file reads. - Relay checks never send mail.
smtp_open_relaystops after RCPT and never issues DATA;dns_open_resolversends one recursive query;apparmor_auditandselinux_auditread kernel/config state only. - SMB share probing stops at TREE_CONNECT.
smb_sharestries a fixed list of share names over the anonymous session and reports status codes; it never lists a directory or reads a file.email_security_auditonly queries DNS TXT/MX records for an in-scope domain. - SMB stays at the session and IPC$.
smb_null_sessionnegotiates SMB 2.1, tries an anonymous session setup and only connects to IPC$; it does not enumerate shares or read files.tls_cipher_matrixperforms one handshake per cipher;docker_auditreads files and never calls the daemon. - API and cache probes are unauthenticated GETs.
api_auth_auditrequests a caller-supplied endpoint list without credentials,cache_auditfetches a path twice, andlog_timelinemerges two local logs (restricted paths). - RPC and NTP are single queries.
rpc_probesends one portmapper DUMP andntp_probeone client packet; neither mounts an export, changes a clock or requests a monlist.ssh_config_auditandpam_auditread config files. - Form and local audits are reads.
csrf_auditfetches one page and parses its forms;kernel_hardening,sudoers_auditandauditd_auditread local files, with the audit log restricted to /var/log and the state directory. - Directory and walk probes are bounded reads.
snmp_walkissues at most 30 GETNEXT requests for the system group;ldap_searchbinds anonymously and stops after 20 entries;openapi_discoveryfetches six documents;systemd_auditreads unit files. None writes or authenticates with a credential. - Method and protocol probes stay read-only.
http_methodssends OPTIONS and TRACE but never PUT/DELETE;websocket_probeperforms the handshake and sends no frame;ike_probesends one SA_INIT with no credentials or PSK;firewall_auditreads the local ruleset. - Firmware analysis reads local files only.
esp_partition_table,esp_nvs_parseandfirmware_scanopen a dump the operator supplies, cap it at 8/16/32 MiB and never touch a device.mount_auditreads a mount table (the live one or a saved copy). - Mail and telephony probes stop at the greeting.
pop3_probereads the banner and CAPA and quits;sip_probesends one OPTIONS and reads the answer;telnet_probesends nothing at all.package_integrityverifies installed files locally with the package manager and never uses the network. - Container, search and IMAP probes issue reads only.
docker_api_probeasks/versionand/containers/json;elasticsearch_probeasks/, cluster health and the index list;imap_probereads CAPABILITY and logs out. None authenticates, starts a container, runs a query against user data or logs into a mailbox. - VNC and MQTT stop at the handshake.
vnc_probereads the offered security types and never authenticates;mqtt_probesends one CONNECT with no credentials, reads CONNACK and disconnects.graphql_probesends only an introspection query, andcap_baselineonly reads the capability xattr. - RDP and SMB speak only the negotiation.
rdp_probesends one X.224 request and reads the selected protocol;smb_probesends one SMB2 NEGOTIATE and reads the dialect and signing flags. Neither creates a session, authenticates or touches a share. - SSTI and XXE probes prove evaluation, then stop.
ssti_probesends arithmetic expressions and only looks for their result;xxe_probepoints the external entity at its own loopback listener and never at a file or a third party.ldap_probesends an anonymous bind and a rootDSE read, not credentials.ssh_key_auditonly reads key files the operator can read. - Web input probes send markers, not exploits.
param_fuzzinjects a unique marker, a single quote and{{1337*7}}, then looks for reflection and error signatures;open_redirectsends a URL on example.com;host_header_- injectionsends a.invalidcanary. None extracts data or executes code. - Database probes read one greeting, never a password.
mysql_probereads the initial handshake,postgres_probesends one StartupMessage with no password and reports the auth method,mongo_probesendsisMasterandmemcached_probesendsstats. None of them writes, guesses or replays a credential; a trust/SCRAM offer is reported, not logged into. - TLS, Redis, SNMP and AXFR stay read-only.
tls_auditperforms TLS handshakes and reads the certificate;redis_probesends PING, INFO and DBSIZE only;snmp_probesends a GET for sysDescr.0;dns_zone_transferasks one nameserver for one in-scope zone. No writes, no password guessing, no payloads. - Service probes are handshakes, not attacks.
ftp_probetries only the literal anonymous FTP pair,smtp_probesends EHLO and at most 8 VRFY commands, andssh_auditreads 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_auditandhash_idparse a value the operator supplies; the JWT signature check is local HMAC-SHA256 and no hash is cracked.process_snapshotonly reads/proc. - Local reads.
hardening_auditandioc_scanread files the operator can already read;log_auditonly 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.logonly 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.
CONNECTis 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_CHILDRENandAPEX_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_saveis capped byAPEX_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_HOMEat 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
expiresdate andallow_private: falseunless the engagement is inside a private net. - Leave
serial_tx: falseunless the rules of engagement authorise transmission. - Set
APEX_WEBHOOK_MIN_SEVERITYwhere you want the wake-up; the default iscritical. - Put secrets in
~/.config/apex-twin/envor the service environment, not in the unit file or in the repository. - Back up
audit.logandevidence/before deleting a state directory; both may contain sensitive engagement data. Encrypt the backup. - Rebuild and re-run
make testafter every upgrade;make analyzeandmake fuzzare 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.