apex-twin 1.74.0: syslog-ng and ntpd audits, Rundeck probe

Three new tools:
- syslog_ng_audit (blue): syslog-ng.conf and conf.d fragments; a network()
  source without ip() listens on every address, one without tls() takes
  logs in clear, and a writable config is flagged.
- ntpd_audit (blue): ntp.conf; missing "restrict default", a non-local
  restrict without all of nomodify notrap nopeer noquery, missing
  "disable monitor" (mode-6 monlist amplifier), world-writable config.
- rundeck_probe (red): /api/14/projects and /api/1/projects without a
  token; the project list is saved as evidence.

332 tools, 1334 end-to-end checks.

Test evidence: make test 1334/1334, test-asan 1334/1334, analyze 0
warnings, coverage 84.9%, release-check exit 0 in 318 s including
distcheck from the tarball.
This commit is contained in:
lotherk committed 2026-11-22 23:02:08 +00:00
1 parent defe13f3df
commit 4159d5305c
9 files changed
+597 -13

No files matched your search

+13
View File
@@ -1,5 +1,18 @@
# Changelog
## 1.74.0 - 2026-11-23 - this change
- **syslog-ng** (`syslog_ng_audit`): a `network()` source without `ip()`
listens on every address, a source without `tls()` takes logs in clear,
and a writable `syslog-ng.conf` or `conf.d` fragment is read-only in name.
- **ntpd** (`ntpd_audit`): a missing `restrict default`, a non-local
`restrict` line without all of `nomodify notrap nopeer noquery`, a
missing `disable monitor` (mode-6 monlist as an amplifier) and a writable
`ntp.conf`.
- **Rundeck** (`rundeck_probe`): `/api/14/projects` and `/api/1/projects`
without a token; the project list is saved as evidence.
- 332 tools, 1334 end-to-end checks.
APEX TWIN is a C99/POSIX scope-gated offensive-security MCP server. This file
records what changed in each version. The project is pre-1.0: minor versions may
change behaviour, but the finding/asset/traffic JSON formats only ever gained
+9 -5
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.
**329 tools · 1328 end-to-end checks · 240 fuzz cases · 84.8% line coverage · ~1041 KiB**
**332 tools · 1334 end-to-end checks · 240 fuzz cases · 84.9% line coverage · ~1041 KiB**
```
$ ./apex-twin --check
{"version":"1.73.0","tools":329,...,"scope":{"loaded":true,...}}
{"version":"1.74.0","tools":332,...,"scope":{"loaded":true,...}}
```
APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/artex) (scope
@@ -232,6 +232,7 @@ uploads and secret-file reads. It does not execute anything.
| `kafka_connect_probe` | `/connectors` on 8083 without auth; connector list as evidence |
| `sonarqube_probe` | `/api/projects/search` on 9000 without auth; project list as evidence |
| `keycloak_probe` | `/realms/master` on 8080: open self-registration; realm JSON as evidence |
| `rundeck_probe` | `/api/14/projects` without a token; project list as evidence |
| `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 |
@@ -517,6 +518,8 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
| `dnf_repo_audit` | dnf/yum repos: gpgcheck off, sslverify off, plain http |
| `anacrontab_audit` | anacrontab and cron.d: root job out of /tmp, download piped to a shell |
| `motd_audit` | update-motd.d: writable script, missing shebang, URL fetch at login |
| `syslog_ng_audit` | syslog-ng: network source on all addresses, plaintext |
| `ntpd_audit` | ntp.conf: no default restrict, open restricts, monitor on |
| `podman_audit` | registries.conf: insecure or http registry, unsigned policy |
| `buildkitd_audit` | buildkitd.toml: insecure registry, tcp without CA, no rootless |
| `supervisor_audit` | supervisord.conf: exposed web UI, no username, root programs |
@@ -994,7 +997,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
logstash_api_probe, amqp_probe, tls_chain_probe,
smtp_auth_probe, jenkins_api_probe, nexus_probe,
gitea_api_probe, harbor_probe, portainer_probe, sonarqube_probe,
keycloak_probe,
keycloak_probe, rundeck_probe,
argocd_probe, kafka_connect_probe
src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
detect_rules, integrity_baseline, mitre_map,
@@ -1006,7 +1009,8 @@ src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
fstab_audit, modprobe_audit, grub_audit,
limits_audit, access_conf_audit, pwquality_audit,
pam_env_audit, hosts_audit, dnf_repo_audit,
anacrontab_audit, motd_audit)
anacrontab_audit, motd_audit,
syslog_ng_audit, ntpd_audit)
src/tools_esp.c esp_info, esp_monitor, esp_read_flash, esp_flash,
esp_partition_table, esp_nvs_parse, firmware_scan,
esp_app_info, esp_image_verify
@@ -1043,7 +1047,7 @@ examples/ scope.json
## Status
1.73.0. Built and run: 329 tools, 1328 checks, 240 fuzz cases and 84.8% line
1.74.0. Built and run: 332 tools, 1334 checks, 240 fuzz cases and 84.9% 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
+1 -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.73.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
is **1.74.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.
+3 -3
View File
@@ -1,5 +1,5 @@
.\" apex-twin.1 - manual page for APEX TWIN
.TH APEX-TWIN 1 "2026-11-23" "apex-twin 1.73.0" "User Commands"
.TH APEX-TWIN 1 "2026-11-23" "apex-twin 1.74.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, etcd_api_probe, docker_registry_probe, consul_api_probe, couchdb_probe, prometheus_api_probe, rabbitmq_management_probe, grafana_api_probe, minio_admin_probe, nats_monitoring_probe, influxdb_probe, clickhouse_probe, kibana_api_probe, logstash_api_probe, amqp_probe, tls_chain_probe, smtp_auth_probe, jenkins_api_probe, nexus_probe, gitea_api_probe, harbor_probe, portainer_probe, argocd_probe, kafka_connect_probe, sonarqube_probe, keycloak_probe),
websocket_origin_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe, etcd_api_probe, docker_registry_probe, consul_api_probe, couchdb_probe, prometheus_api_probe, rabbitmq_management_probe, grafana_api_probe, minio_admin_probe, nats_monitoring_probe, influxdb_probe, clickhouse_probe, kibana_api_probe, logstash_api_probe, amqp_probe, tls_chain_probe, smtp_auth_probe, jenkins_api_probe, nexus_probe, gitea_api_probe, harbor_probe, portainer_probe, argocd_probe, kafka_connect_probe, sonarqube_probe, keycloak_probe, rundeck_probe),
defensive
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
@@ -87,7 +87,7 @@ supervisor_audit,
fstab_audit, modprobe_audit, grub_audit,
limits_audit, access_conf_audit, pwquality_audit,
pam_env_audit, hosts_audit, dnf_repo_audit,
anacrontab_audit, motd_audit)
anacrontab_audit, motd_audit, syslog_ng_audit, ntpd_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.73.0"
#define APEX_VERSION "1.74.0"
#define APEX_MAX_OUT (1u << 20)
#define APEX_PATH_MAX 512
#define APEX_PATH_FULL 1024
+330
View File
@@ -22839,6 +22839,318 @@ static void t_motd_audit(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&findings);
}
/* -------------------------------------------------------------- syslog_ng_audit */
/* A syslog-ng network() source listens for log data on the wire. Two things
* make it a finding: it binds every address (no 127.0.0.1, ::1 or localhost
* inside the statement) and it has no tls() block, so the logs travel in the
* clear. The statement runs to the next semicolon because tls() is nested. */
static void syslog_ng_scan_net(const char *text, int *nets, int *all_addr,
int *plain)
{
const char *p = text;
while ((p = strstr(p, "network(")) != NULL) {
const char *end = strchr(p, ';');
size_t len = end != NULL ? (size_t)(end - p) : strlen(p);
char seg[4097];
int local = 0;
int tls = 0;
if (len >= sizeof(seg))
len = sizeof(seg) - 1;
memcpy(seg, p, len);
seg[len] = '\0';
(*nets)++;
if (strstr(seg, "127.0.0.1") != NULL ||
strstr(seg, "::1") != NULL ||
strstr(seg, "localhost") != NULL)
local = 1;
if (strstr(seg, "tls(") != NULL)
tls = 1;
if (!local)
*all_addr = 1;
if (!tls)
*plain = 1;
p += 8;
}
}
static void syslog_ng_scan_file(mcp_buf *findings, int *first, int *count,
const char *path, int *files, int *nets,
int *all_addr, int *plain)
{
static char text[65536];
struct stat st;
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)++;
}
syslog_ng_scan_net(text, nets, all_addr, plain);
}
static void t_syslog_ng_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *files[] = { "/etc/syslog-ng/syslog-ng.conf",
"/etc/syslog-ng.conf", NULL };
const char *root = mcp_arg_string(args, "root");
char path[1024];
DIR *d;
struct dirent *ent;
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int files_read = 0;
int nets = 0;
int all_addr = 0;
int plain = 0;
int i;
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
mcp_buf_init(&findings);
for (i = 0; files[i] != NULL; i++) {
snprintf(path, sizeof(path), "%.400s%s", root, files[i]);
syslog_ng_scan_file(&findings, &first, &count, path, &files_read,
&nets, &all_addr, &plain);
}
snprintf(path, sizeof(path), "%.400s/etc/syslog-ng/conf.d", root);
d = opendir(path);
if (d != NULL) {
while ((ent = readdir(d)) != NULL) {
char file[1200];
size_t nl = strlen(ent->d_name);
if (ent->d_name[0] == '.')
continue;
if (nl < 5 || strcmp(ent->d_name + nl - 5, ".conf") != 0)
continue;
snprintf(file, sizeof(file), "%.900s/%.200s", path,
ent->d_name);
syslog_ng_scan_file(&findings, &first, &count, file,
&files_read, &nets, &all_addr,
&plain);
}
closedir(d);
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read a syslog-ng configuration");
return;
}
if (all_addr) {
add_finding(&findings, &first, "network-all-address", "high",
"a network() source accepts log data on every "
"interface");
count++;
}
if (plain) {
add_finding(&findings, &first, "network-plaintext", "medium",
"a network() source has no tls() block, so logs "
"cross the wire in the clear");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"network_sources\":%d,"
"\"all_address\":%s,\"plaintext\":%s,"
"\"findings_count\":%d,\"findings\":[",
files_read, nets, all_addr ? "true" : "false",
plain ? "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);
}
/* ---------------------------------------------------------------- ntpd_audit */
/* ntp.conf grammar: "restrict <address> [mask <m>] <flags...>". A restrict
* line that is not bound to localhost and does not carry all four of
* nomodify, notrap, nopeer and noquery leaves the query and control surface
* open. A missing "restrict default" leaves it open for everyone, and without
* "disable monitor" the mode-6 monlist query can be used as an amplifier.
* The first token after "restrict" may be "-4" or "-6", not the address. */
struct ntpd_state {
int default_line;
int open_lines;
};
static void ntpd_scan_text(const char *text, struct ntpd_state *st,
int *servers, int *monitor_off)
{
const char *p = text;
while (p != NULL && *p != '\0') {
const char *eol = strchr(p, '\n');
size_t len = eol != NULL ? (size_t)(eol - p) : strlen(p);
char line[1024];
char *tok[64];
char *save = NULL;
char *word;
char *hash;
int n = 0;
if (len >= sizeof(line))
len = sizeof(line) - 1;
memcpy(line, p, len);
line[len] = '\0';
p = eol != NULL ? eol + 1 : NULL;
hash = strchr(line, '#');
if (hash != NULL)
*hash = '\0';
word = strtok_r(line, " \t", &save);
while (word != NULL && n < 64) {
tok[n++] = word;
word = strtok_r(NULL, " \t", &save);
}
if (n == 0)
continue;
if (strcmp(tok[0], "server") == 0 ||
strcmp(tok[0], "pool") == 0) {
if (n > 1)
(*servers)++;
} else if (strcmp(tok[0], "disable") == 0) {
if (n > 1 && strcmp(tok[1], "monitor") == 0)
*monitor_off = 1;
} else if (strcmp(tok[0], "restrict") == 0 && n > 1) {
const char *addr;
int i = 1;
int nomodify = 0;
int notrap = 0;
int nopeer = 0;
int noquery = 0;
int is_default;
int is_local;
if (strcmp(tok[i], "-4") == 0 ||
strcmp(tok[i], "-6") == 0)
i++;
if (i >= n)
continue;
addr = tok[i];
is_default = strcmp(addr, "default") == 0;
is_local = strcmp(addr, "127.0.0.1") == 0 ||
strcmp(addr, "::1") == 0 ||
strcmp(addr, "localhost") == 0;
if (is_default)
st->default_line = 1;
for (; i < n; i++) {
if (strcmp(tok[i], "nomodify") == 0)
nomodify = 1;
else if (strcmp(tok[i], "notrap") == 0)
notrap = 1;
else if (strcmp(tok[i], "nopeer") == 0)
nopeer = 1;
else if (strcmp(tok[i], "noquery") == 0)
noquery = 1;
}
/* The "restrict default" line may stay wide open; it
* is reported separately as missing. Only an explicit
* non-local rule is a finding here. */
if (!is_default && !is_local &&
!(nomodify && notrap && nopeer && noquery))
st->open_lines++;
}
}
}
static void t_ntpd_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *files[] = { "/etc/ntp.conf", "/etc/ntp/ntp.conf",
NULL };
const char *root = mcp_arg_string(args, "root");
char path[1024];
mcp_buf b;
mcp_buf findings;
struct ntpd_state st;
int first = 1;
int count = 0;
int files_read = 0;
int servers = 0;
int monitor_off = 0;
int i;
(void)user;
st.default_line = 0;
st.open_lines = 0;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
mcp_buf_init(&findings);
for (i = 0; files[i] != NULL; i++) {
static char text[65536];
struct stat fs;
snprintf(path, sizeof(path), "%.400s%s", root, files[i]);
if (read_text(path, text, sizeof(text)) <= 0)
continue;
files_read++;
if (stat(path, &fs) == 0 && (fs.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"%s is writable by anyone", path);
count++;
}
ntpd_scan_text(text, &st, &servers, &monitor_off);
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read an ntp configuration");
return;
}
if (!st.default_line) {
add_finding(&findings, &first, "no-default-restrict", "medium",
"no 'restrict default' line: any host may query "
"and control this server");
count++;
}
if (st.open_lines > 0) {
add_finding(&findings, &first, "restrict-open", "medium",
"%d restrict line(s) for non-local addresses lack "
"nomodify/notrap/nopeer/noquery", st.open_lines);
count++;
}
if (!monitor_off) {
add_finding(&findings, &first, "monitor-open", "low",
"no 'disable monitor': the mode-6 monlist query "
"can be used to amplify");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"servers\":%d,"
"\"default_restrict\":%s,\"open_restricts\":%d,"
"\"monitor_disabled\":%s,\"findings_count\":%d,"
"\"findings\":[",
files_read, servers,
st.default_line ? "true" : "false", st.open_lines,
monitor_off ? "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, "
@@ -24140,6 +24452,24 @@ const mcp_tool TOOLS_BLUE[] = {
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_motd_audit },
{ "syslog_ng_audit",
"Parse a syslog-ng configuration (root prefix): syslog-ng.conf, the "
"alternative /etc/syslog-ng.conf and conf.d/*.conf. A network() "
"source that binds every interface (no 127.0.0.1, ::1 or localhost "
"in the statement) and one without a tls() block, plus a "
"world-writable configuration file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_syslog_ng_audit },
{ "ntpd_audit",
"Parse ntpd's configuration (root prefix): /etc/ntp.conf and "
"/etc/ntp/ntp.conf. Flags a missing 'restrict default', a "
"non-local restrict line without nomodify/notrap/nopeer/noquery, "
"a missing 'disable monitor' (mode-6 monlist amplification) and a "
"world-writable file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_ntpd_audit },
};
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
+97
View File
@@ -8467,6 +8467,92 @@ static void t_keycloak_probe(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&b);
}
/* -------------------------------------------------------------- rundeck_probe */
/* Rundeck on 4440. /api/1/system/info answers on many installs and is not
* exposure by itself; what matters is /api/14/projects (older builds use
* /api/1/projects) coming back 2xx with a project list, which means the API
* is readable without a token. The list is saved as evidence. */
static void t_rundeck_probe(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *paths[] = { "/api/1/system/info",
"/api/14/projects",
"/api/1/projects", NULL };
const char *target = mcp_arg_string(args, "target");
int port = mcp_arg_int(args, "port", 4440);
int tls = mcp_arg_bool(args, "tls", apex_looks_tls(port));
mcp_buf b;
int first = 1;
int tested = 0;
int open_count = 0;
int projects_open = 0;
char *evidence = NULL;
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, "rundeck_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 projects = strstr(paths[i], "projects") != 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 (open)
open_count++;
if (open && projects && evidence == NULL && len > 2)
evidence = apex_evidence_save("rundeck-projects", resp, len);
if (open && projects)
projects_open = 1;
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}",
code, (unsigned long)len, open ? "true" : "false");
free(resp);
}
mcp_buf_printf(&b, "],\"tested\":%d,\"open_count\":%d,"
"\"projects_open\":%s,\"evidence\":",
tested, open_count, projects_open ? "true" : "false");
if (evidence != NULL)
apex_json_str(&b, evidence);
else
mcp_buf_puts(&b, "null");
mcp_buf_puts(&b, "}");
apex_audit("rundeck_probe", target, port, !projects_open,
projects_open
? "the Rundeck project API answers without a token"
: "the Rundeck project API requires a token", "list");
mcp_reply_json(c, b.p);
free(evidence);
mcp_buf_free(&b);
}
/* ------------------------------------------------------------- portainer_probe */
static void t_portainer_probe(mcp_conn *c, const mcp_json *args, void *user)
@@ -9407,6 +9493,17 @@ const mcp_tool TOOLS_RED[] = {
"\"port\":{\"type\":\"integer\",\"description\":\"default 8080\"}},"
"\"required\":[\"target\"]}",
t_keycloak_probe },
{ "rundeck_probe",
"Query Rundeck on 4440 without a token: /api/1/system/info, "
"/api/14/projects and /api/1/projects. The system info answers on "
"many installs and is not counted as exposure; a 2xx project list "
"is, and its body is saved as evidence. Gate: the target and port "
"must be in scope.",
"{\"type\":\"object\",\"properties\":{"
"\"target\":{\"type\":\"string\"},\"tls\":{\"type\":\"boolean\"},"
"\"port\":{\"type\":\"integer\",\"description\":\"default 4440\"}},"
"\"required\":[\"target\"]}",
t_rundeck_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 = 329
EXPECTED_TOOLS = 332
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.
+142 -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("329 tools registered", len(tools) == 329, len(tools))
check("332 tools registered", len(tools) == 332, 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"]) == 329)
check("http tools/list", len(listing["result"]["tools"]) == 332)
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
@@ -15091,6 +15091,146 @@ kc_closed_srv.shutdown()
for d in (ac_root, ac_good_root, mt_root, mt_good_root, cfg45_home):
shutil.rmtree(d, ignore_errors=True)
print("\n== syslog-ng, ntpd and Rundeck ==")
sn_root = tempfile.mkdtemp(prefix="apex-sng-")
os.makedirs(os.path.join(sn_root, "etc", "syslog-ng", "conf.d"))
sn_conf = os.path.join(sn_root, "etc", "syslog-ng", "syslog-ng.conf")
with open(sn_conf, "w") as f:
f.write("@version: 4.0\n")
f.write("source s_local { system(); };\n")
f.write('source s_net { network(port(514) flags(no-parse)); };\n')
os.chmod(sn_conf, 0o666)
with open(os.path.join(sn_root, "etc", "syslog-ng", "conf.d", "tls.conf"),
"w") as f:
f.write('source s_tls { network(ip(10.0.0.5) port(6514) '
'tls(key_file("/k") cert_file("/c"))); };\n')
sn_good_root = tempfile.mkdtemp(prefix="apex-sngg-")
os.makedirs(os.path.join(sn_good_root, "etc", "syslog-ng"))
with open(os.path.join(sn_good_root, "etc", "syslog-ng", "syslog-ng.conf"),
"w") as f:
f.write("@version: 4.0\n")
f.write("source s_local { system(); };\n")
f.write('source s_net { network(ip(127.0.0.1) port(514) '
'tls(peer-verify(required))); };\n')
nt_root = tempfile.mkdtemp(prefix="apex-ntp-")
os.makedirs(os.path.join(nt_root, "etc"))
nt_conf = os.path.join(nt_root, "etc", "ntp.conf")
with open(nt_conf, "w") as f:
f.write("driftfile /var/lib/ntp/ntp.drift\n")
f.write("server 0.pool.example.test iburst\n")
f.write("server 1.pool.example.test iburst\n")
f.write("restrict 10.0.0.0 mask 255.0.0.0\n")
f.write("restrict -4 192.168.1.0 mask 255.255.255.0 nomodify\n")
os.chmod(nt_conf, 0o666)
nt_good_root = tempfile.mkdtemp(prefix="apex-ntpg-")
os.makedirs(os.path.join(nt_good_root, "etc"))
with open(os.path.join(nt_good_root, "etc", "ntp.conf"), "w") as f:
f.write("driftfile /var/lib/ntp/ntp.drift\n")
f.write("restrict default kod nomodify notrap nopeer noquery\n")
f.write("restrict 127.0.0.1\n")
f.write("restrict -6 ::1\n")
f.write("restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery\n")
f.write("disable monitor\n")
f.write("server 0.pool.example.test iburst\n")
class _RundeckHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
path = urllib.parse.urlsplit(self.path).path
if path == "/api/1/system/info":
body = b'{"system":{"rundeck":{"version":"4.17.2"}}}'
self.send_response(200)
elif self.server.open_projects and path in ("/api/14/projects",
"/api/1/projects"):
body = b'[{"name":"deploy"},{"name":"ops"}]'
self.send_response(200)
else:
body = b'{"error":"unauthorized"}'
self.send_response(401)
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
rd_srv = http.server.HTTPServer(("127.0.0.1", 0), _RundeckHandler)
rd_srv.open_projects = True
rd_port = rd_srv.server_address[1]
threading.Thread(target=rd_srv.serve_forever, daemon=True).start()
rd_closed_srv = http.server.HTTPServer(("127.0.0.1", 0), _RundeckHandler)
rd_closed_srv.open_projects = False
rd_closed_port = rd_closed_srv.server_address[1]
threading.Thread(target=rd_closed_srv.serve_forever, daemon=True).start()
cfg46_home = tempfile.mkdtemp(prefix="apex-cfg46-home-")
write_scope(cfg46_home,
{"label": "cfg46", "expires": "2099-01-01T00:00:00Z",
"allow_ip": ["127.0.0.1/32"], "allow_private": True,
"allow_port": ["1-65535"]})
res, _ = run([
call(1, "syslog_ng_audit", root=sn_root),
call(2, "syslog_ng_audit", root=sn_good_root),
call(3, "ntpd_audit", root=nt_root),
call(4, "ntpd_audit", root=nt_good_root),
call(5, "rundeck_probe", target="127.0.0.1", port=rd_port, tls=False),
call(6, "rundeck_probe", target="127.0.0.1", port=rd_closed_port,
tls=False),
], home=cfg46_home)
by_id = {r["id"]: text(r) for r in res}
sn = json.loads(by_id[1])
sn_kinds = {f["id"] for f in sn["findings"]}
check("syslog_ng_audit flags a network source on all addresses, plaintext "
"and a writable config",
{"network-all-address", "network-plaintext",
"world-writable"} <= sn_kinds and
sn["files"] == 2 and sn["network_sources"] == 2 and
sn["all_address"] is True and sn["plaintext"] is True, sn)
sn_good = json.loads(by_id[2])
check("syslog_ng_audit accepts a loopback source with peer verification",
sn_good["findings_count"] == 0 and sn_good["all_address"] is False and
sn_good["network_sources"] == 1, sn_good)
nt = json.loads(by_id[3])
nt_kinds = {f["id"] for f in nt["findings"]}
check("ntpd_audit flags a missing default restrict, open restricts and a "
"writable config",
{"no-default-restrict", "restrict-open", "world-writable"} <= nt_kinds
and nt["files"] == 1 and nt["servers"] == 2 and
nt["default_restrict"] is False and nt["open_restricts"] == 2 and
nt["monitor_disabled"] is False, nt)
nt_good = json.loads(by_id[4])
check("ntpd_audit accepts a hardened restrict set and a disabled monitor",
nt_good["findings_count"] == 0 and nt_good["default_restrict"] is True
and nt_good["open_restricts"] == 0 and
nt_good["monitor_disabled"] is True, nt_good)
rd = json.loads(by_id[5])
check("rundeck_probe finds an open project API and saves the list",
{"target": "127.0.0.1", "port": rd_port, "tls": False} ==
{k: rd[k] for k in ("target", "port", "tls")} and
rd["projects_open"] is True and rd["open_count"] == 3 and
os.path.isfile(rd["evidence"]), rd)
rd_closed = json.loads(by_id[6])
check("rundeck_probe reports a closed project API as not open",
rd_closed["projects_open"] is False and
rd_closed["open_count"] <= 1, rd_closed)
rd_srv.shutdown()
rd_closed_srv.shutdown()
for d in (sn_root, sn_good_root, nt_root, nt_good_root, cfg46_home):
shutil.rmtree(d, ignore_errors=True)
print("%d passed, %d failed" % (passes, len(fails)))
if fails:
print("failed: " + ", ".join(fails))