apex-twin 1.49.0: iSCSI, rpcbind and kdump audits, etcd API probe

Blue:
- iscsi_audit: iscsid.conf: node.startup=automatic, a session or discovery
  auth method of None (or missing) and a world-writable file.
- rpcbind_audit: /etc/default/rpcbind and /etc/sysconfig/rpcbind: -w warm
  start, -i insecure, a missing -l bind address and a world-writable file.
- kdump_audit: kdump.conf and /etc/default/kdump-tools: a remote dump target,
  core_collector without -c, a shell or dump_to_rootfs action and a
  world-writable file.

Red:
- etcd_api_probe: GET /version, /health and /v2/keys/?recursive=true without a
  token; a 2xx answer is unauthenticated access, audited, with the first two
  answers saved as evidence.

Tests with iSCSI/rpcbind/kdump trees and two etcd HTTP fixtures (open and
401). 1048 checks, ASan suite green, analyze clean, release-check green
including distcheck 1.49.0.
This commit is contained in:
lotherk committed 2026-11-22 11:08:46 +00:00
1 parent f1ef790709
commit 185aa07b7e
9 files changed
+624 -15

No files matched your search

+18 -1
View File
@@ -8,7 +8,24 @@ fields, and state from an older version is read by a newer one.
There are no git tags. The hash next to a version is the commit that introduced
it; the current entry is the commit that adds this section.
## 1.48.0 — 2026-11-23 — this change
## 1.49.0 — 2026-11-23 — this change
- **iSCSI** (`iscsi_audit`): `iscsid.conf`: `node.startup=automatic`, a
session or discovery authentication method of `None` (or missing) and a
world-writable file.
- **rpcbind** (`rpcbind_audit`): `/etc/default/rpcbind` and
`/etc/sysconfig/rpcbind`: `-w` warm start, `-i` insecure, a missing `-l`
bind address and a world-writable file.
- **kdump** (`kdump_audit`): `kdump.conf` and `/etc/default/kdump-tools`: a
remote dump target, `core_collector` without `-c`, a `shell` or
`dump_to_rootfs` default action and a world-writable file.
- **etcd** (`etcd_api_probe`): GET `/version`, `/health` and
`/v2/keys/?recursive=true` without a token; a 2xx answer is unauthenticated
access, audited, with the first two answers saved as evidence.
- Tests with iSCSI/rpcbind/kdump trees and two etcd HTTP fixtures (open and
401). 1048 checks. Coverage 83.1%.
## 1.48.0 — 2026-11-23 — f1ef790
- **Avahi** (`avahi_audit`): `avahi-daemon.conf`: `publish-workstation`,
`publish-addresses`, a missing or wildcard `allow-interfaces` and a
+12 -6
View File
@@ -5,11 +5,11 @@ no Python in the serving path. It gives an agent real reconnaissance and real we
testing behind a scope gate that refuses everything until a rules-of-engagement
file says otherwise.
**230 tools · 1035 end-to-end checks · 340 fuzz cases · 83.0% line coverage · ~842 KiB**
**234 tools · 1048 end-to-end checks · 340 fuzz cases · 83.1% line coverage · ~854 KiB**
```
$ ./apex-twin --check
{"version":"1.48.0","tools":230,...,"scope":{"loaded":true,...}}
{"version":"1.49.0","tools":234,...,"scope":{"loaded":true,...}}
```
APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/artex) (scope
@@ -149,7 +149,7 @@ closes a request whose head or body does not arrive within
---
## Tools (230)
## Tools (234)
### Scope and bookkeeping
@@ -207,6 +207,7 @@ uploads and secret-file reads. It does not execute anything.
| `tls_hostname_check` | SAN/CN wildcard match for the requested SNI name |
| `ftp_tls_probe` | `AUTH TLS` -> 234 means explicit FTPS; otherwise cleartext |
| `zookeeper_4lw_probe` | `stat`/`mntr` answered without auth leaks version and state |
| `etcd_api_probe` | `/version`, `/health`, `/v2/keys` without a token; 2xx is open access |
| `cookie_audit` | Secure/HttpOnly/SameSite per cookie, incl. `SameSite=None` without Secure |
| `http_options` | `Allow`/`Public`; flags TRACE, PUT, DELETE |
| `sqli_probe` | Quote and boolean payloads; differing answers are a **lead**, not proof |
@@ -427,6 +428,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
| `avahi_audit` | avahi-daemon.conf: workstation/address publication, no interface limit |
| `logind_audit` | logind.conf: idle ignore, lid ignore, IdleActionSec=0 |
| `tftpd_hpa_audit` | tftpd-hpa: `--create`, missing `--secure`, root directory |
| `iscsi_audit` | iscsid.conf: auto startup, no session/discovery CHAP |
| `rpcbind_audit` | rpcbind: `-w`, `-i`, no `-l` bind address |
| `kdump_audit` | kdump: remote target, no `-c`, shell/dump_to_rootfs action |
### ESP32
@@ -711,6 +715,8 @@ The full threat model, trust boundaries and a hardening checklist are in
| FTP TLS | banner plus one AUTH TLS command, no login |
| avahi/logind/tftpd-hpa | config reads only; optional root prefix |
| ZooKeeper 4lw | two four-byte commands, no auth, no data |
| iscsi/rpcbind/kdump | config reads only; optional root prefix |
| etcd API | three unauthenticated GETs, first answers as evidence |
| USB audit | 200 devices, sysfs reads only |
---
@@ -722,7 +728,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
```sh
make # apex-twin
make test # version check + gate audit + 1035 end-to-end checks
make test # version check + gate audit + 1048 end-to-end checks
make version-check # the five places that carry a version must agree
make gate-audit # static: every target-taking tool calls the gate
make asan # apex-twin-asan with ASan + UBSan
@@ -846,7 +852,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
websocket_origin_check, dns_fcrdns_check,
dns_soa_mname_check, hsts_audit,
tls_hostname_check, ftp_tls_probe,
zookeeper_4lw_probe
zookeeper_4lw_probe, etcd_api_probe
src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
detect_rules, integrity_baseline, mitre_map,
process_snapshot, persistence_audit, net_baseline,
@@ -889,7 +895,7 @@ examples/ scope.json
## Status
1.48.0. Built and run: 230 tools, 1035 checks, 340 fuzz cases and 83.0% line
1.49.0. Built and run: 234 tools, 1048 checks, 340 fuzz cases and 83.1% line
coverage. The loop closes: a probe captures the exchange as a pair, a finding
points at it, `finding_update` gives it a state, an asset records the host it
came from, `cors_check`/`cookie_audit`/`http_options` turn a web answer into a
+3 -1
View File
@@ -9,7 +9,7 @@ problem.
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.48.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
is **1.49.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.
@@ -66,6 +66,8 @@ only narrow what the proxy does (the scope gate still runs first).
- **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.
- **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
+3 -3
View File
@@ -1,5 +1,5 @@
.\" apex-twin.1 - manual page for APEX TWIN
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.48.0" "User Commands"
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.49.0" "User Commands"
.SH NAME
apex-twin \- scope\-gated offensive\-security MCP server
.SH SYNOPSIS
@@ -46,7 +46,7 @@ sip_probe, telnet_probe, http_methods, websocket_probe, ike_probe, snmp_walk,
ldap_search, openapi_discovery, csrf_audit, rpc_probe, ntp_probe, dnssec_check, smtp_starttls_probe, tls_ocsp_probe, alpn_probe, webdav_probe, dns_wildcard_check, dns_caa_check, sni_vhost_check, tls_client_auth_probe, kubernetes_api_probe,
dns_ns_consistency, dns_dangling_cname, http_redirect_audit,
websocket_origin_check, dns_fcrdns_check, dns_soa_mname_check, http_redirect_audit,
websocket_origin_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe),
websocket_origin_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe, etcd_api_probe),
defensive
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
@@ -69,7 +69,7 @@ apt_config_audit, login_defs_audit, pg_hba_audit, polkit_audit,
ldap_client_audit, ssl_cert_audit, timesyncd_audit, resolv_conf_audit, journald_audit,
coredump_audit, nftables_audit, dnsmasq_audit, nsswitch_audit,
jenkins_audit, pgbouncer_audit, xinetd_audit, sssd_audit, avahi_audit, logind_audit,
tftpd_hpa_audit)
tftpd_hpa_audit, iscsi_audit, rpcbind_audit, kdump_audit)
and ESP32 board tools (esp_info, esp_monitor,
esp_read_flash, esp_flash, esp_partition_table, esp_nvs_parse, firmware_scan,
esp_app_info, esp_image_verify).
+1 -1
View File
@@ -15,7 +15,7 @@
#include "mcp.h"
#define APEX_VERSION "1.48.0"
#define APEX_VERSION "1.49.0"
#define APEX_MAX_OUT (1u << 20)
#define APEX_PATH_MAX 512
#define APEX_PATH_FULL 1024
+316
View File
@@ -14319,6 +14319,301 @@ static void t_tftpd_hpa_audit(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&findings);
}
/* ---------------------------------------------------------------- iscsi_audit */
static void t_iscsi_audit(mcp_conn *c, const mcp_json *args, void *user)
{
const char *root = mcp_arg_string(args, "root");
char path[1024];
static char text[65536];
char value[128];
struct stat st;
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int auto_startup = 0;
int no_chap = 0;
int no_discovery_chap = 0;
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
snprintf(path, sizeof(path), "%s/etc/iscsi/iscsid.conf", root);
if (read_text(path, text, sizeof(text)) <= 0) {
mcp_reply_error(c, "cannot read iscsid.conf");
return;
}
mcp_buf_init(&findings);
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"iscsid.conf is writable by anyone");
count++;
}
if (conf_value(text, "node.startup", value, sizeof(value)) &&
strcasecmp(value, "automatic") == 0) {
auto_startup = 1;
add_finding(&findings, &first, "auto-startup", "medium",
"every target logs in at boot");
count++;
}
if (!conf_value(text, "node.session.auth.authmethod", value,
sizeof(value)) ||
strcasecmp(value, "None") == 0) {
no_chap = 1;
add_finding(&findings, &first, "no-chap", "high",
"the iSCSI session has no CHAP authentication");
count++;
}
if (!conf_value(text, "discovery.sendtargets.auth.authmethod", value,
sizeof(value)) ||
strcasecmp(value, "None") == 0) {
no_discovery_chap = 1;
add_finding(&findings, &first, "no-discovery-chap", "medium",
"target discovery has no CHAP authentication");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"auto_startup\":%s,\"session_chap\":%s,"
"\"discovery_chap\":%s,\"findings_count\":%d,"
"\"findings\":[",
auto_startup ? "true" : "false",
no_chap ? "false" : "true",
no_discovery_chap ? "false" : "true", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
/* -------------------------------------------------------------- rpcbind_audit */
static int rpcbind_token(const char *options, const char *flag)
{
char copy[512];
char *save = NULL;
char *tok;
size_t fl = strlen(flag);
snprintf(copy, sizeof(copy), "%.500s", options);
tok = strtok_r(copy, " \t", &save);
while (tok != NULL) {
if (strncmp(tok, flag, fl) == 0)
return 1;
tok = strtok_r(NULL, " \t", &save);
}
return 0;
}
static void rpcbind_scan_file(mcp_buf *findings, int *first, int *count,
const char *path, int *files, char *options,
size_t on)
{
static char text[65536];
struct stat st;
char value[512];
if (read_text(path, text, sizeof(text)) <= 0)
return;
(*files)++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(findings, first, "world-writable", "high",
"%s is writable by anyone", path);
(*count)++;
}
if (conf_value(text, "OPTIONS", value, sizeof(value)) ||
conf_value(text, "RPCBIND_ARGS", value, sizeof(value)))
snprintf(options, on, "%.400s", value);
}
static void t_rpcbind_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *files[] = { "/etc/default/rpcbind",
"/etc/sysconfig/rpcbind", NULL };
const char *root = mcp_arg_string(args, "root");
char path[1024];
char options[512];
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int files_read = 0;
int warm = 0;
int insecure = 0;
int no_bind = 0;
int i;
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
options[0] = '\0';
mcp_buf_init(&findings);
for (i = 0; files[i] != NULL; i++) {
snprintf(path, sizeof(path), "%.400s%s", root, files[i]);
rpcbind_scan_file(&findings, &first, &count, path, &files_read,
options, sizeof(options));
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read an rpcbind configuration");
return;
}
warm = rpcbind_token(options, "-w");
insecure = rpcbind_token(options, "-i");
no_bind = !rpcbind_token(options, "-l");
if (warm) {
add_finding(&findings, &first, "warm-start", "medium",
"rpcbind accepts remote registration updates");
count++;
}
if (insecure) {
add_finding(&findings, &first, "insecure", "high",
"rpcbind runs with -i, bypassing TCP wrappers");
count++;
}
if (no_bind) {
add_finding(&findings, &first, "no-bind-address", "low",
"rpcbind is not bound to a specific address");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_puts(&b, ",\"options\":");
apex_json_str(&b, options);
mcp_buf_printf(&b, ",\"warm_start\":%s,\"insecure\":%s,"
"\"bound\":%s,\"findings_count\":%d,\"findings\":[",
warm ? "true" : "false",
insecure ? "true" : "false",
no_bind ? "false" : "true", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
/* ----------------------------------------------------------------- kdump_audit */
static void t_kdump_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *rhel = "/etc/kdump.conf";
static const char *deb = "/etc/default/kdump-tools";
const char *root = mcp_arg_string(args, "root");
char path[1024];
static char text[65536];
struct stat st;
char value[512];
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int files_read = 0;
int remote = 0;
int no_compression = 0;
int shell = 0;
int to_rootfs = 0;
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
mcp_buf_init(&findings);
snprintf(path, sizeof(path), "%.400s%s", root, rhel);
if (read_text(path, text, sizeof(text)) > 0) {
files_read++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"%s is writable by anyone", path);
count++;
}
if (text_has_line(text, "nfs ", "") ||
text_has_line(text, "ssh ", "") ||
text_has_line(text, "cifs ", ""))
remote = 1;
if (conf_value(text, "core_collector", value, sizeof(value)) &&
strstr(value, "-c") == NULL)
no_compression = 1;
if (conf_value(text, "default", value, sizeof(value))) {
if (strcasecmp(value, "shell") == 0)
shell = 1;
else if (strcasecmp(value, "dump_to_rootfs") == 0)
to_rootfs = 1;
}
}
snprintf(path, sizeof(path), "%.400s%s", root, deb);
if (read_text(path, text, sizeof(text)) > 0) {
files_read++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"%s is writable by anyone", path);
count++;
}
if (conf_value(text, "KDUMP_SAVEDIR", value, sizeof(value)) &&
(strncmp(value, "nfs://", 6) == 0 ||
strncmp(value, "ssh://", 6) == 0 ||
strncmp(value, "cifs://", 7) == 0))
remote = 1;
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read a kdump configuration");
return;
}
if (remote) {
add_finding(&findings, &first, "remote-dump", "medium",
"a crash dump leaves the machine over the network");
count++;
}
if (no_compression) {
add_finding(&findings, &first, "no-compression", "low",
"core_collector stores the dump uncompressed");
count++;
}
if (shell) {
add_finding(&findings, &first, "shell-action", "high",
"the default action is an interactive shell");
count++;
}
if (to_rootfs) {
add_finding(&findings, &first, "dump-to-rootfs", "medium",
"a failed dump is copied into the root filesystem");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"remote\":%s,\"compressed\":%s,"
"\"shell_action\":%s,\"to_rootfs\":%s,"
"\"findings_count\":%d,\"findings\":[",
files_read, remote ? "true" : "false",
no_compression ? "false" : "true",
shell ? "true" : "false",
to_rootfs ? "true" : "false", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
const mcp_tool TOOLS_BLUE[] = {
{ "hardening_audit",
"Read-only posture audit of the local host: sshd_config (root login, "
@@ -15105,6 +15400,27 @@ const mcp_tool TOOLS_BLUE[] = {
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_tftpd_hpa_audit },
{ "iscsi_audit",
"Parse iscsid.conf (root prefix): node.startup=automatic, a session or "
"discovery authentication method of None (or missing) and a "
"world-writable file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_iscsi_audit },
{ "rpcbind_audit",
"Parse /etc/default/rpcbind and /etc/sysconfig/rpcbind (root prefix): -w "
"warm start, -i insecure, a missing -l bind address and a world-writable "
"file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_rpcbind_audit },
{ "kdump_audit",
"Parse kdump.conf and /etc/default/kdump-tools (root prefix): a remote "
"dump target, core_collector without -c, a shell or dump_to_rootfs "
"default action and a world-writable file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_kdump_audit },
};
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
+101
View File
@@ -6441,6 +6441,96 @@ static void t_dns_soa_mname_check(mcp_conn *c, const mcp_json *args,
mcp_buf_free(&b);
}
/* ----------------------------------------------------------------- etcd_api_probe */
static void t_etcd_api_probe(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *paths[] = { "/version", "/health",
"/v2/keys/?recursive=true", NULL };
const char *target = mcp_arg_string(args, "target");
int port = mcp_arg_int(args, "port", 2379);
int tls = mcp_arg_bool(args, "tls",
port == 2379 || apex_looks_tls(port));
mcp_buf b;
int first = 1;
int tested = 0;
int open_count = 0;
int saved = 0;
int i;
(void)user;
if (target == NULL || *target == '\0') {
mcp_reply_error(c, "target is required");
return;
}
if (port <= 0 || port > 65535) {
mcp_reply_error(c, "port out of range");
return;
}
if (!gated(c, "etcd_api_probe", target, port))
return;
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"target\":");
apex_json_str(&b, target);
mcp_buf_printf(&b, ",\"port\":%d,\"tls\":%s,\"endpoints\":[", port,
tls ? "true" : "false");
for (i = 0; paths[i] != NULL; i++) {
char status[256];
char *resp = NULL;
size_t len = 0;
int code;
int open;
int json = 0;
char *evidence = NULL;
status[0] = '\0';
if (apex_http_once(target, port, tls, "GET", paths[i], NULL, NULL,
8000, &resp, &len, status,
sizeof(status)) != 0)
continue;
tested++;
code = apex_status_code(status);
open = code >= 200 && code < 300;
if (resp != NULL && find_bytes(resp, len, "{"))
json = 1;
if (open) {
open_count++;
if (saved < 2) {
char label[64];
snprintf(label, sizeof(label), "etcd-%.24s",
paths[i] + 1);
evidence = apex_evidence_save(label, resp, len);
saved++;
}
}
if (!first)
mcp_buf_puts(&b, ",");
first = 0;
mcp_buf_puts(&b, "{\"path\":");
apex_json_str(&b, paths[i]);
mcp_buf_printf(&b, ",\"status\":%d,\"bytes\":%lu,\"open\":%s,"
"\"json\":%s,\"evidence\":",
code, (unsigned long)len,
open ? "true" : "false", json ? "true" : "false");
if (evidence != NULL)
apex_json_str(&b, evidence);
else
mcp_buf_puts(&b, "null");
mcp_buf_puts(&b, "}");
free(evidence);
free(resp);
}
mcp_buf_printf(&b, "],\"tested\":%d,\"open_count\":%d}", tested,
open_count);
apex_audit("etcd_api_probe", target, port, open_count == 0,
open_count == 0
? "the etcd API requires authentication or is absent"
: "the etcd API answers without a token", "list");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
}
const mcp_tool TOOLS_RED[] = {
{ "vuln_check",
"Non-destructive verification of exposed artifacts on one web target: "
@@ -6963,6 +7053,17 @@ const mcp_tool TOOLS_RED[] = {
"\"tls\":{\"type\":\"boolean\"}},"
"\"required\":[\"target\"]}",
t_kubernetes_api_probe },
{ "etcd_api_probe",
"Query an etcd API without a token: /version, /health and "
"/v2/keys/?recursive=true. A 2xx answer is unauthenticated access, "
"audited, with the first two responses saved as evidence. TLS is "
"assumed on 2379. Gate: the target.",
"{\"type\":\"object\",\"properties\":{"
"\"target\":{\"type\":\"string\"},"
"\"port\":{\"type\":\"integer\",\"description\":\"default 2379\"},"
"\"tls\":{\"type\":\"boolean\"}},"
"\"required\":[\"target\"]}",
t_etcd_api_probe },
{ "dns_ns_consistency",
"Fetch NS records for a domain from the parent resolver and from its own "
"first nameserver (resolved to an address), then report names present on "
+1 -1
View File
@@ -21,7 +21,7 @@ import re
import sys
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
EXPECTED_TOOLS = 230
EXPECTED_TOOLS = 234
GATE = ("gated(", "gated_cmd(", "gated_run(", "apex_scope_check(")
NET = ("http_once(", "tcp_connect_host(", "tcp_probe(", "apex_run(")
# Tools whose "target" argument filters local records; they never touch it.
+169 -2
View File
@@ -134,7 +134,7 @@ res, _ = run([
], home=empty)
check("tools/list answers", any(r.get("id") == 1 for r in res))
tools = [r for r in res if r.get("id") == 1][0]["result"]["tools"]
check("230 tools registered", len(tools) == 230, len(tools))
check("234 tools registered", len(tools) == 234, len(tools))
names = {t["name"] for t in tools}
for need in ("portscan", "nmap", "http_request", "marauder_scan",
"method_playbook", "finding_add", "finding_update", "scope_check",
@@ -1560,7 +1560,7 @@ try:
check("http initialize", init["result"]["serverInfo"]["name"] == "apex-twin",
init)
listing = post({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
check("http tools/list", len(listing["result"]["tools"]) == 230)
check("http tools/list", len(listing["result"]["tools"]) == 234)
shown = post(call(3, "scope_show"))
check("http scope_show", '"loaded":true' in shown["result"]["content"][0]["text"])
# the id must be the request's id, not one found inside the arguments
@@ -10558,6 +10558,172 @@ shutil.rmtree(tf_root, ignore_errors=True)
shutil.rmtree(tf_good_root, ignore_errors=True)
shutil.rmtree(cfg20_home, ignore_errors=True)
print("\n== iSCSI, rpcbind, kdump and etcd ==\n")
isc_root = tempfile.mkdtemp(prefix="apex-isc-")
os.makedirs(os.path.join(isc_root, "etc", "iscsi"))
isc_bad = os.path.join(isc_root, "etc", "iscsi", "iscsid.conf")
with open(isc_bad, "w") as f:
f.write("node.startup = automatic\n")
f.write("node.session.auth.authmethod = None\n")
f.write("discovery.sendtargets.auth.authmethod = None\n")
os.chmod(isc_bad, 0o666)
isc_good_root = tempfile.mkdtemp(prefix="apex-iscg-")
os.makedirs(os.path.join(isc_good_root, "etc", "iscsi"))
with open(os.path.join(isc_good_root, "etc", "iscsi", "iscsid.conf"),
"w") as f:
f.write("node.startup = manual\n")
f.write("node.session.auth.authmethod = CHAP\n")
f.write("discovery.sendtargets.auth.authmethod = CHAP\n")
rb_root = tempfile.mkdtemp(prefix="apex-rb-")
os.makedirs(os.path.join(rb_root, "etc", "default"))
rb_bad = os.path.join(rb_root, "etc", "default", "rpcbind")
with open(rb_bad, "w") as f:
f.write('OPTIONS="-w -i"\n')
os.chmod(rb_bad, 0o666)
rb_good_root = tempfile.mkdtemp(prefix="apex-rbg-")
os.makedirs(os.path.join(rb_good_root, "etc", "default"))
with open(os.path.join(rb_good_root, "etc", "default", "rpcbind"),
"w") as f:
f.write('OPTIONS="-l 127.0.0.1"\n')
kd_root = tempfile.mkdtemp(prefix="apex-kd-")
os.makedirs(os.path.join(kd_root, "etc"))
kd_bad = os.path.join(kd_root, "etc", "kdump.conf")
with open(kd_bad, "w") as f:
f.write("nfs 10.0.0.5:/export/crash\n")
f.write("core_collector makedumpfile -l --message-level 1 -d 31\n")
f.write("default shell\n")
os.chmod(kd_bad, 0o666)
kd_good_root = tempfile.mkdtemp(prefix="apex-kdg-")
os.makedirs(os.path.join(kd_good_root, "etc"))
with open(os.path.join(kd_good_root, "etc", "kdump.conf"), "w") as f:
f.write("path /var/crash\n")
f.write("core_collector makedumpfile -c -l --message-level 1 -d 31\n")
f.write("default reboot\n")
class _EtcdHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
path = urllib.parse.urlsplit(self.path).path
docs = {
"/version": b'{"etcdserver":"3.5.0","etcdcluster":"3.5.0"}',
"/health": b'{"health":"true"}',
"/v2/keys/": b'{"action":"get","node":{"key":"/","dir":true}}',
}
body = docs.get(path, b'{"error":"not found"}')
code = 200 if path in docs else 404
self.send_response(code)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def log_message(self, *args):
pass
class _EtcdAuthHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
body = b'{"error":"Unauthorized"}'
self.send_response(401)
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def log_message(self, *args):
pass
etcd_srv = http.server.HTTPServer(("127.0.0.1", 0), _EtcdHandler)
etcd_port = etcd_srv.server_address[1]
threading.Thread(target=etcd_srv.serve_forever, daemon=True).start()
etcd_auth_srv = http.server.HTTPServer(("127.0.0.1", 0), _EtcdAuthHandler)
etcd_auth_port = etcd_auth_srv.server_address[1]
threading.Thread(target=etcd_auth_srv.serve_forever, daemon=True).start()
cfg21_home = tempfile.mkdtemp(prefix="apex-cfg21-home-")
write_scope(cfg21_home, {"label": "cfg21", "expires": "2099-12-31T23:59:59Z",
"allow_private": True, "allow_ip": ["127.0.0.1"],
"allow_port": [str(etcd_port),
str(etcd_auth_port)]})
res, _ = run([
call(1, "iscsi_audit", root=isc_root),
call(2, "iscsi_audit", root=isc_good_root),
call(3, "rpcbind_audit", root=rb_root),
call(4, "rpcbind_audit", root=rb_good_root),
call(5, "kdump_audit", root=kd_root),
call(6, "kdump_audit", root=kd_good_root),
call(7, "etcd_api_probe", target="127.0.0.1", port=etcd_port, tls=False),
call(8, "etcd_api_probe", target="127.0.0.1", port=etcd_auth_port,
tls=False),
call(9, "etcd_api_probe", target="198.51.100.9", port=2379),
call(10, "iscsi_audit", root="/nonexistent-isc"),
call(11, "rpcbind_audit", root="/nonexistent-rb"),
call(12, "kdump_audit", root="/nonexistent-kd"),
], home=cfg21_home)
by_id = {r.get("id"): r for r in res}
isc = json.loads(text(by_id[1]))
isc_kinds = {f["id"] for f in isc["findings"]}
check("iscsi_audit flags auto start and missing CHAP",
{"world-writable", "auto-startup", "no-chap",
"no-discovery-chap"} <= isc_kinds and
isc["session_chap"] is False, isc)
isc_good = json.loads(text(by_id[2]))
check("iscsi_audit accepts manual CHAP sessions",
isc_good["findings_count"] == 0 and
isc_good["session_chap"] is True and
isc_good["discovery_chap"] is True, isc_good)
rb = json.loads(text(by_id[3]))
rb_kinds = {f["id"] for f in rb["findings"]}
check("rpcbind_audit flags warm start, insecure and no bind",
{"world-writable", "warm-start", "insecure", "no-bind-address"} <=
rb_kinds and rb["warm_start"] is True and rb["insecure"] is True, rb)
rb_good = json.loads(text(by_id[4]))
check("rpcbind_audit accepts a bound loopback",
rb_good["findings_count"] == 0 and rb_good["bound"] is True, rb_good)
kd = json.loads(text(by_id[5]))
kd_kinds = {f["id"] for f in kd["findings"]}
check("kdump_audit flags remote dumps, no compression and shell",
{"world-writable", "remote-dump", "no-compression",
"shell-action"} <= kd_kinds and kd["remote"] is True and
kd["compressed"] is False, kd)
kd_good = json.loads(text(by_id[6]))
check("kdump_audit accepts a local compressed dump",
kd_good["findings_count"] == 0 and kd_good["remote"] is False and
kd_good["compressed"] is True, kd_good)
etcd = json.loads(text(by_id[7]))
check("etcd_api_probe finds the unauthenticated API",
etcd["open_count"] == 3 and etcd["tested"] == 3 and
all(e["open"] for e in etcd["endpoints"]), etcd)
check("etcd_api_probe saves evidence",
any(e["evidence"] and os.path.isfile(e["evidence"])
for e in etcd["endpoints"]), etcd["endpoints"])
etcd_auth = json.loads(text(by_id[8]))
check("etcd_api_probe reports a protected API",
etcd_auth["open_count"] == 0 and
all(e["status"] == 401 for e in etcd_auth["endpoints"]), etcd_auth)
check("etcd_api_probe refuses an out-of-scope target", err(by_id[9]),
text(by_id[9]))
check("iscsi_audit reports a missing config", err(by_id[10]),
text(by_id[10]))
check("rpcbind_audit reports a missing config", err(by_id[11]),
text(by_id[11]))
check("kdump_audit reports a missing config", err(by_id[12]),
text(by_id[12]))
etcd_srv.shutdown()
etcd_srv.server_close()
etcd_auth_srv.shutdown()
etcd_auth_srv.server_close()
shutil.rmtree(isc_root, ignore_errors=True)
shutil.rmtree(isc_good_root, ignore_errors=True)
shutil.rmtree(rb_root, ignore_errors=True)
shutil.rmtree(rb_good_root, ignore_errors=True)
shutil.rmtree(kd_root, ignore_errors=True)
shutil.rmtree(kd_good_root, ignore_errors=True)
shutil.rmtree(cfg21_home, ignore_errors=True)
print("\n== esp32 tools ==")
@@ -10568,6 +10734,7 @@ print("\n== esp32 tools ==")
esp_home = tempfile.mkdtemp(prefix="apex-esp-")
write_scope(esp_home, {"label": "esp", "expires": "2099-12-31T23:59:59Z"})
esp_m, esp_s = pty.openpty()