apex-twin 1.66.0: Bluetooth, NetworkManager and D-Bus audits, Nexus probe
Blue: - bluetooth_audit: main.conf: AutoEnable, Privacy=off, JustWorksRepairing always, a missing LE controller mode, world-writable. - networkmanager_audit: NetworkManager.conf and system-connections: WEP, a PSK file readable beyond its owner, 802.1X without a CA, world-writable. - dbus_audit: system policy: allow own=* and send_destination=* wildcards, world-writable. Red: - nexus_probe: /service/rest/v1/status and /service/rest/v1/repositories without credentials; a 2xx repository list is an open API with evidence. Tests with Bluetooth/NetworkManager/D-Bus trees and two Nexus fixtures (open and 401). 1254 checks, ASan suite green, analyze clean, release-check green including distcheck 1.66.0.
This commit is contained in:
1 parent
8a81fb1e4e
commit
03c8a63a0f
9 files changed
+652
-15
No files matched your search
+17
-1
@@ -8,7 +8,23 @@ 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.65.0 — 2026-11-23 — this change
|
||||
## 1.66.0 — 2026-11-23 — this change
|
||||
|
||||
- **Bluetooth** (`bluetooth_audit`): `main.conf`: `AutoEnable=true`,
|
||||
`Privacy=off`, `JustWorksRepairing=always`, a missing LE controller mode
|
||||
and a world-writable file.
|
||||
- **NetworkManager** (`networkmanager_audit`): `NetworkManager.conf` and
|
||||
`system-connections`: WEP, a PSK file readable beyond its owner, 802.1X
|
||||
without a CA and world-writable files.
|
||||
- **D-Bus** (`dbus_audit`): system policy files: `allow own="*"` and
|
||||
`send_destination="*"` wildcards plus world-writable files.
|
||||
- **Nexus** (`nexus_probe`): `/service/rest/v1/status` and
|
||||
`/service/rest/v1/repositories` without credentials; a 2xx repository list
|
||||
is an open API, saved as evidence.
|
||||
- Tests with Bluetooth/NetworkManager/D-Bus trees and two Nexus fixtures
|
||||
(open and 401). 1254 checks. Coverage 84.4%.
|
||||
|
||||
## 1.65.0 — 2026-11-23 — 8a81fb1
|
||||
|
||||
- **USBGuard** (`usbguard_audit`): rules and daemon config: an `allow` rule
|
||||
without `with-interface`, `ImplicitPolicyTarget=allow`,
|
||||
|
||||
@@ -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.
|
||||
|
||||
**298 tools · 1242 end-to-end checks · 340 fuzz cases · 84.4% line coverage · ~1008 KiB**
|
||||
**302 tools · 1254 end-to-end checks · 340 fuzz cases · 84.4% line coverage · ~1025 KiB**
|
||||
|
||||
```
|
||||
$ ./apex-twin --check
|
||||
{"version":"1.65.0","tools":298,...,"scope":{"loaded":true,...}}
|
||||
{"version":"1.66.0","tools":302,...,"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 (298)
|
||||
## Tools (302)
|
||||
|
||||
### Scope and bookkeeping
|
||||
|
||||
@@ -224,6 +224,7 @@ uploads and secret-file reads. It does not execute anything.
|
||||
| `tls_chain_probe` | Counts presented certs; a lone non-self-signed leaf means a missing intermediate |
|
||||
| `smtp_auth_probe` | EHLO AUTH mechanisms; PLAIN/LOGIN without STARTTLS is a clear-text risk |
|
||||
| `jenkins_api_probe` | `/api/json` and `/whoAmI` without auth; job list as evidence |
|
||||
| `nexus_probe` | `/service/rest/v1/repositories` without auth; 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 |
|
||||
@@ -495,6 +496,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `usbguard_audit` | allow without with-interface, implicit allow policy |
|
||||
| `certbot_audit` | renewal: manual authenticator, curl-pipe hook |
|
||||
| `wpa_supplicant_audit` | key_mgmt=NONE, WEP, readable PSK |
|
||||
| `bluetooth_audit` | main.conf: auto enable, privacy off, JustWorks always |
|
||||
| `networkmanager_audit` | connections: WEP, readable PSK, 802.1X without CA |
|
||||
| `dbus_audit` | policy: `own="*"` and `send_destination="*"` |
|
||||
|
||||
### ESP32
|
||||
|
||||
@@ -813,6 +817,8 @@ The full threat model, trust boundaries and a hardening checklist are in
|
||||
| SMTP AUTH | banner + EHLO, no login |
|
||||
| usbguard/certbot/wpa | config reads only; optional root prefix |
|
||||
| Jenkins API | two unauthenticated GETs, job list as evidence |
|
||||
| bluetooth/networkmanager/dbus | config reads only; optional root prefix |
|
||||
| Nexus API | two unauthenticated GETs, repository list as evidence |
|
||||
| USB audit | 200 devices, sysfs reads only |
|
||||
|
||||
---
|
||||
@@ -824,7 +830,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
|
||||
|
||||
```sh
|
||||
make # apex-twin
|
||||
make test # version check + gate audit + 1242 end-to-end checks
|
||||
make test # version check + gate audit + 1254 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
|
||||
@@ -955,7 +961,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
|
||||
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
|
||||
smtp_auth_probe, jenkins_api_probe, nexus_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,
|
||||
@@ -998,7 +1004,7 @@ examples/ scope.json
|
||||
|
||||
## Status
|
||||
|
||||
1.65.0. Built and run: 298 tools, 1242 checks, 340 fuzz cases and 84.4% line
|
||||
1.66.0. Built and run: 302 tools, 1254 checks, 340 fuzz cases and 84.4% 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
@@ -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.65.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
|
||||
is **1.66.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.
|
||||
- **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
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
.\" apex-twin.1 - manual page for APEX TWIN
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.65.0" "User Commands"
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.66.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),
|
||||
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),
|
||||
defensive
|
||||
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
|
||||
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
|
||||
@@ -80,7 +80,7 @@ hosts_access_audit, profile_audit, atd_audit, securetty_audit,
|
||||
tmpfiles_audit, compose_audit, k8s_manifest_audit, dockerfile_audit,
|
||||
openssl_cnf_audit, curlrc_audit, wgetrc_audit, resolved_audit,
|
||||
udev_audit, issue_audit, usbguard_audit, certbot_audit,
|
||||
wpa_supplicant_audit)
|
||||
wpa_supplicant_audit, bluetooth_audit, networkmanager_audit, dbus_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
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "mcp.h"
|
||||
|
||||
#define APEX_VERSION "1.65.0"
|
||||
#define APEX_VERSION "1.66.0"
|
||||
#define APEX_MAX_OUT (1u << 20)
|
||||
#define APEX_PATH_MAX 512
|
||||
#define APEX_PATH_FULL 1024
|
||||
|
||||
@@ -19791,6 +19791,313 @@ static void t_wpa_supplicant_audit(mcp_conn *c, const mcp_json *args,
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ bluetooth_audit */
|
||||
|
||||
static void t_bluetooth_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[64];
|
||||
struct stat st;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int auto_enable = 0;
|
||||
int privacy_off = 0;
|
||||
int justworks = 0;
|
||||
int no_le = 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/bluetooth/main.conf", root);
|
||||
if (read_text(path, text, sizeof(text)) <= 0) {
|
||||
mcp_reply_error(c, "cannot read bluetooth main.conf");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(&findings, &first, "world-writable", "high",
|
||||
"main.conf is writable by anyone");
|
||||
count++;
|
||||
}
|
||||
if (ini_value(text, "Policy", "AutoEnable", value, sizeof(value)) &&
|
||||
strcasecmp(value, "true") == 0)
|
||||
auto_enable = 1;
|
||||
if (ini_value(text, "General", "Privacy", value, sizeof(value)) &&
|
||||
strcasecmp(value, "off") == 0)
|
||||
privacy_off = 1;
|
||||
if (ini_value(text, "General", "JustWorksRepairing", value,
|
||||
sizeof(value)) &&
|
||||
strcasecmp(value, "always") == 0)
|
||||
justworks = 1;
|
||||
if (!ini_value(text, "General", "ControllerMode", value,
|
||||
sizeof(value)) ||
|
||||
strcasecmp(value, "bredr") == 0)
|
||||
no_le = 1;
|
||||
if (auto_enable) {
|
||||
add_finding(&findings, &first, "auto-enable", "low",
|
||||
"the Bluetooth radio is enabled at boot");
|
||||
count++;
|
||||
}
|
||||
if (privacy_off) {
|
||||
add_finding(&findings, &first, "privacy-off", "medium",
|
||||
"Bluetooth privacy mode is disabled");
|
||||
count++;
|
||||
}
|
||||
if (justworks) {
|
||||
add_finding(&findings, &first, "justworks-always", "medium",
|
||||
"JustWorks pairing never requires confirmation");
|
||||
count++;
|
||||
}
|
||||
if (no_le) {
|
||||
add_finding(&findings, &first, "no-le", "low",
|
||||
"the controller is not restricted to LE mode");
|
||||
count++;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"auto_enable\":%s,\"privacy\":%s,"
|
||||
"\"justworks\":%s,\"le_only\":%s,"
|
||||
"\"findings_count\":%d,\"findings\":[",
|
||||
auto_enable ? "true" : "false",
|
||||
privacy_off ? "false" : "true",
|
||||
justworks ? "true" : "false",
|
||||
no_le ? "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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- networkmanager_audit */
|
||||
|
||||
static void nm_scan_connection(mcp_buf *findings, int *first, int *count,
|
||||
const char *path, int *files, int *wep,
|
||||
int *readable_psk, int *no_cert)
|
||||
{
|
||||
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)++;
|
||||
}
|
||||
{
|
||||
char value[64];
|
||||
|
||||
if (ini_value(text, "wifi-security", "key-mgmt", value,
|
||||
sizeof(value)) &&
|
||||
strcasecmp(value, "wep") == 0) {
|
||||
add_finding(findings, first, "wep", "high",
|
||||
"%s uses WEP", path);
|
||||
(*count)++;
|
||||
(*wep)++;
|
||||
}
|
||||
if (ini_value(text, "wifi-security", "psk", value,
|
||||
sizeof(value)) && value[0] != '\0' &&
|
||||
stat(path, &st) == 0 && (st.st_mode & 0044) != 0) {
|
||||
add_finding(findings, first, "readable-psk", "high",
|
||||
"%s holds a PSK and is readable beyond its "
|
||||
"owner", path);
|
||||
(*count)++;
|
||||
(*readable_psk)++;
|
||||
}
|
||||
if (strstr(text, "[802-1x]") != NULL &&
|
||||
strstr(text, "ca-cert") == NULL) {
|
||||
add_finding(findings, first, "no-ca-cert", "medium",
|
||||
"%s uses 802.1X without a CA certificate",
|
||||
path);
|
||||
(*count)++;
|
||||
(*no_cert)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void t_networkmanager_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];
|
||||
struct stat st;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files = 0;
|
||||
int wep = 0;
|
||||
int readable_psk = 0;
|
||||
int no_cert = 0;
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
|
||||
(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), "%s/etc/NetworkManager/NetworkManager.conf",
|
||||
root);
|
||||
if (read_text(path, text, sizeof(text)) > 0) {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
snprintf(path, sizeof(path),
|
||||
"%s/etc/NetworkManager/system-connections", root);
|
||||
d = opendir(path);
|
||||
if (d != NULL) {
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
char full[1200];
|
||||
struct stat fst;
|
||||
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
snprintf(full, sizeof(full), "%.900s/%.200s", path,
|
||||
ent->d_name);
|
||||
if (stat(full, &fst) != 0 || !S_ISREG(fst.st_mode))
|
||||
continue;
|
||||
nm_scan_connection(&findings, &first, &count, full,
|
||||
&files, &wep, &readable_psk,
|
||||
&no_cert);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
if (files == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "cannot read a NetworkManager configuration");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"wep\":%d,\"readable_psk\":%d,"
|
||||
"\"eap_without_ca\":%d,\"findings_count\":%d,"
|
||||
"\"findings\":[",
|
||||
files, wep, readable_psk, no_cert, 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);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- dbus_audit */
|
||||
|
||||
static void dbus_scan_file(mcp_buf *findings, int *first, int *count,
|
||||
const char *path, int *files, int *own_wild,
|
||||
int *send_wild)
|
||||
{
|
||||
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)++;
|
||||
}
|
||||
if (strstr(text, "own=\"*\"") != NULL ||
|
||||
strstr(text, "own='*'") != NULL) {
|
||||
add_finding(findings, first, "own-wildcard", "high",
|
||||
"%s lets a policy own every bus name", path);
|
||||
(*count)++;
|
||||
(*own_wild)++;
|
||||
}
|
||||
if (strstr(text, "send_destination=\"*\"") != NULL ||
|
||||
strstr(text, "send_destination='*'") != NULL) {
|
||||
add_finding(findings, first, "send-wildcard", "high",
|
||||
"%s lets a policy send to every destination", path);
|
||||
(*count)++;
|
||||
(*send_wild)++;
|
||||
}
|
||||
}
|
||||
|
||||
static void t_dbus_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char dirpath[1024];
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files = 0;
|
||||
int own_wild = 0;
|
||||
int send_wild = 0;
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
snprintf(dirpath, sizeof(dirpath), "%s/etc/dbus-1/system.d", root);
|
||||
d = opendir(dirpath);
|
||||
if (d == NULL) {
|
||||
mcp_reply_error(c, "cannot read /etc/dbus-1/system.d");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
char full[1200];
|
||||
size_t nl = strlen(ent->d_name);
|
||||
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
if (nl < 6 || strcmp(ent->d_name + nl - 5, ".conf") != 0)
|
||||
continue;
|
||||
snprintf(full, sizeof(full), "%.900s/%.200s", dirpath,
|
||||
ent->d_name);
|
||||
dbus_scan_file(&findings, &first, &count, full, &files,
|
||||
&own_wild, &send_wild);
|
||||
}
|
||||
closedir(d);
|
||||
if (files == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "no D-Bus policy file found");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"own_wildcards\":%d,"
|
||||
"\"send_wildcards\":%d,\"findings_count\":%d,"
|
||||
"\"findings\":[",
|
||||
files, own_wild, send_wild, 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, "
|
||||
@@ -20928,6 +21235,26 @@ const mcp_tool TOOLS_BLUE[] = {
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_wpa_supplicant_audit },
|
||||
{ "bluetooth_audit",
|
||||
"Parse bluetooth main.conf (root prefix): AutoEnable, Privacy=off, "
|
||||
"JustWorksRepairing=always, a missing LE controller mode and a "
|
||||
"world-writable file. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_bluetooth_audit },
|
||||
{ "networkmanager_audit",
|
||||
"Parse NetworkManager.conf and system-connections (root prefix): WEP, a "
|
||||
"PSK file readable beyond its owner, 802.1X without a CA and "
|
||||
"world-writable files. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_networkmanager_audit },
|
||||
{ "dbus_audit",
|
||||
"Parse D-Bus system policy files (root prefix): allow own=* and "
|
||||
"send_destination=* wildcards plus world-writable files. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_dbus_audit },
|
||||
};
|
||||
|
||||
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
|
||||
@@ -7927,6 +7927,91 @@ static void t_jenkins_api_probe(mcp_conn *c, const mcp_json *args,
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- nexus_probe */
|
||||
|
||||
static void t_nexus_probe(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
static const char *paths[] = { "/service/rest/v1/status",
|
||||
"/service/rest/v1/repositories", NULL };
|
||||
const char *target = mcp_arg_string(args, "target");
|
||||
int port = mcp_arg_int(args, "port", 8081);
|
||||
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 repositories_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, "nexus_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 repos = strstr(paths[i], "repositories") != 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 && repos) {
|
||||
repositories_open = 1;
|
||||
if (evidence == NULL)
|
||||
evidence = apex_evidence_save("nexus-repositories",
|
||||
resp, len);
|
||||
}
|
||||
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,"
|
||||
"\"repositories_open\":%s,\"evidence\":",
|
||||
tested, open_count,
|
||||
repositories_open ? "true" : "false");
|
||||
if (evidence != NULL)
|
||||
apex_json_str(&b, evidence);
|
||||
else
|
||||
mcp_buf_puts(&b, "null");
|
||||
mcp_buf_puts(&b, "}");
|
||||
apex_audit("nexus_probe", target, port, !repositories_open,
|
||||
repositories_open
|
||||
? "the Nexus repository API answers without authentication"
|
||||
: "the Nexus repository API requires authentication", "list");
|
||||
mcp_reply_json(c, b.p);
|
||||
free(evidence);
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
const mcp_tool TOOLS_RED[] = {
|
||||
{ "vuln_check",
|
||||
"Non-destructive verification of exposed artifacts on one web target: "
|
||||
@@ -8599,6 +8684,16 @@ const mcp_tool TOOLS_RED[] = {
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_jenkins_api_probe },
|
||||
{ "nexus_probe",
|
||||
"Query Nexus without credentials: /service/rest/v1/status and "
|
||||
"/service/rest/v1/repositories. A 2xx repository list is an open API; "
|
||||
"the answer is saved as evidence. Gate: the target.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"target\":{\"type\":\"string\"},"
|
||||
"\"port\":{\"type\":\"integer\",\"description\":\"default 8081\"},"
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_nexus_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
@@ -21,7 +21,7 @@ import re
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
EXPECTED_TOOLS = 298
|
||||
EXPECTED_TOOLS = 302
|
||||
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.
|
||||
|
||||
+193
-2
@@ -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("298 tools registered", len(tools) == 298, len(tools))
|
||||
check("302 tools registered", len(tools) == 302, 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"]) == 298)
|
||||
check("http tools/list", len(listing["result"]["tools"]) == 302)
|
||||
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
|
||||
@@ -13562,6 +13562,196 @@ shutil.rmtree(wp_root, ignore_errors=True)
|
||||
shutil.rmtree(wp_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg37_home, ignore_errors=True)
|
||||
|
||||
print("\n== Bluetooth, NetworkManager, D-Bus and Nexus ==\n")
|
||||
|
||||
bt_root = tempfile.mkdtemp(prefix="apex-bt-")
|
||||
os.makedirs(os.path.join(bt_root, "etc", "bluetooth"))
|
||||
bt_bad = os.path.join(bt_root, "etc", "bluetooth", "main.conf")
|
||||
with open(bt_bad, "w") as f:
|
||||
f.write("[General]\n")
|
||||
f.write("Privacy = off\n")
|
||||
f.write("JustWorksRepairing = always\n")
|
||||
f.write("[Policy]\n")
|
||||
f.write("AutoEnable = true\n")
|
||||
os.chmod(bt_bad, 0o666)
|
||||
bt_good_root = tempfile.mkdtemp(prefix="apex-btg-")
|
||||
os.makedirs(os.path.join(bt_good_root, "etc", "bluetooth"))
|
||||
with open(os.path.join(bt_good_root, "etc", "bluetooth", "main.conf"),
|
||||
"w") as f:
|
||||
f.write("[General]\n")
|
||||
f.write("Privacy = device\n")
|
||||
f.write("JustWorksRepairing = never\n")
|
||||
f.write("ControllerMode = le\n")
|
||||
f.write("[Policy]\n")
|
||||
f.write("AutoEnable = false\n")
|
||||
|
||||
nm_root = tempfile.mkdtemp(prefix="apex-nm-")
|
||||
os.makedirs(os.path.join(nm_root, "etc", "NetworkManager",
|
||||
"system-connections"))
|
||||
with open(os.path.join(nm_root, "etc", "NetworkManager",
|
||||
"NetworkManager.conf"), "w") as f:
|
||||
f.write("[main]\nplugins=keyfile\n")
|
||||
nm_bad = os.path.join(nm_root, "etc", "NetworkManager",
|
||||
"system-connections", "old.nmconnection")
|
||||
with open(nm_bad, "w") as f:
|
||||
f.write("[connection]\nid=old\ntype=wifi\n[wifi]\nssid=old\n")
|
||||
f.write("[wifi-security]\nkey-mgmt=wep\npsk=secret\n")
|
||||
os.chmod(nm_bad, 0o666)
|
||||
nm_good_root = tempfile.mkdtemp(prefix="apex-nmg-")
|
||||
os.makedirs(os.path.join(nm_good_root, "etc", "NetworkManager",
|
||||
"system-connections"))
|
||||
with open(os.path.join(nm_good_root, "etc", "NetworkManager",
|
||||
"NetworkManager.conf"), "w") as f:
|
||||
f.write("[main]\nplugins=keyfile\n")
|
||||
nm_good = os.path.join(nm_good_root, "etc", "NetworkManager",
|
||||
"system-connections", "home.nmconnection")
|
||||
with open(nm_good, "w") as f:
|
||||
f.write("[connection]\nid=home\ntype=wifi\n[wifi]\nssid=home\n")
|
||||
f.write("[wifi-security]\nkey-mgmt=wpa-psk\n"
|
||||
"psk=a-very-long-random-passphrase\n")
|
||||
os.chmod(nm_good, 0o600)
|
||||
|
||||
db_root = tempfile.mkdtemp(prefix="apex-db-")
|
||||
os.makedirs(os.path.join(db_root, "etc", "dbus-1", "system.d"))
|
||||
db_bad = os.path.join(db_root, "etc", "dbus-1", "system.d", "evil.conf")
|
||||
with open(db_bad, "w") as f:
|
||||
f.write("<busconfig>\n <policy context=\"default\">\n")
|
||||
f.write(' <allow own="*"/>\n')
|
||||
f.write(' <allow send_destination="*"/>\n')
|
||||
f.write(" </policy>\n</busconfig>\n")
|
||||
os.chmod(db_bad, 0o666)
|
||||
db_good_root = tempfile.mkdtemp(prefix="apex-dbg-")
|
||||
os.makedirs(os.path.join(db_good_root, "etc", "dbus-1", "system.d"))
|
||||
with open(os.path.join(db_good_root, "etc", "dbus-1", "system.d",
|
||||
"app.conf"), "w") as f:
|
||||
f.write("<busconfig>\n <policy context=\"default\">\n")
|
||||
f.write(' <allow own="org.example.Service"/>\n')
|
||||
f.write(" </policy>\n</busconfig>\n")
|
||||
|
||||
|
||||
class _NexusHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/service/rest/v1/status":
|
||||
body = b'{"version":"3.60.0","edition":"community"}'
|
||||
self.send_response(200)
|
||||
elif path == "/service/rest/v1/repositories":
|
||||
body = b'[{"name":"maven-central","format":"maven2"}]'
|
||||
self.send_response(200)
|
||||
else:
|
||||
body = b'{"error":"not found"}'
|
||||
self.send_response(404)
|
||||
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 _NexusAuthHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/service/rest/v1/status":
|
||||
body = b'{"version":"3.60.0"}'
|
||||
self.send_response(200)
|
||||
else:
|
||||
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
|
||||
|
||||
|
||||
nx_srv = http.server.HTTPServer(("127.0.0.1", 0), _NexusHandler)
|
||||
nx_port = nx_srv.server_address[1]
|
||||
threading.Thread(target=nx_srv.serve_forever, daemon=True).start()
|
||||
nx_auth_srv = http.server.HTTPServer(("127.0.0.1", 0),
|
||||
_NexusAuthHandler)
|
||||
nx_auth_port = nx_auth_srv.server_address[1]
|
||||
threading.Thread(target=nx_auth_srv.serve_forever, daemon=True).start()
|
||||
|
||||
cfg38_home = tempfile.mkdtemp(prefix="apex-cfg38-home-")
|
||||
write_scope(cfg38_home, {"label": "cfg38", "expires": "2099-12-31T23:59:59Z",
|
||||
"allow_private": True, "allow_ip": ["127.0.0.1"],
|
||||
"allow_port": [str(nx_port), str(nx_auth_port)]})
|
||||
res, _ = run([
|
||||
call(1, "bluetooth_audit", root=bt_root),
|
||||
call(2, "bluetooth_audit", root=bt_good_root),
|
||||
call(3, "networkmanager_audit", root=nm_root),
|
||||
call(4, "networkmanager_audit", root=nm_good_root),
|
||||
call(5, "dbus_audit", root=db_root),
|
||||
call(6, "dbus_audit", root=db_good_root),
|
||||
call(7, "nexus_probe", target="127.0.0.1", port=nx_port, tls=False),
|
||||
call(8, "nexus_probe", target="127.0.0.1", port=nx_auth_port,
|
||||
tls=False),
|
||||
call(9, "nexus_probe", target="198.51.100.9", port=8081),
|
||||
call(10, "bluetooth_audit", root="/nonexistent-bt"),
|
||||
call(11, "networkmanager_audit", root="/nonexistent-nm"),
|
||||
call(12, "dbus_audit", root="/nonexistent-db"),
|
||||
], home=cfg38_home)
|
||||
by_id = {r.get("id"): r for r in res}
|
||||
bt = json.loads(text(by_id[1]))
|
||||
bt_kinds = {f["id"] for f in bt["findings"]}
|
||||
check("bluetooth_audit flags auto-enable, privacy and JustWorks",
|
||||
{"world-writable", "auto-enable", "privacy-off",
|
||||
"justworks-always", "no-le"} <= bt_kinds and
|
||||
bt["auto_enable"] is True and bt["privacy"] is False, bt)
|
||||
bt_good = json.loads(text(by_id[2]))
|
||||
check("bluetooth_audit accepts a private LE controller",
|
||||
bt_good["findings_count"] == 0 and bt_good["auto_enable"] is False and
|
||||
bt_good["le_only"] is True, bt_good)
|
||||
nm = json.loads(text(by_id[3]))
|
||||
nm_kinds = {f["id"] for f in nm["findings"]}
|
||||
check("networkmanager_audit flags WEP and a readable PSK",
|
||||
{"world-writable", "wep", "readable-psk"} <= nm_kinds and
|
||||
nm["wep"] == 1 and nm["readable_psk"] == 1, nm)
|
||||
nm_good = json.loads(text(by_id[4]))
|
||||
check("networkmanager_audit accepts WPA in a private keyfile",
|
||||
nm_good["findings_count"] == 0 and nm_good["wep"] == 0 and
|
||||
nm_good["readable_psk"] == 0, nm_good)
|
||||
db = json.loads(text(by_id[5]))
|
||||
db_kinds = {f["id"] for f in db["findings"]}
|
||||
check("dbus_audit flags own and send wildcards",
|
||||
{"world-writable", "own-wildcard", "send-wildcard"} <= db_kinds and
|
||||
db["own_wildcards"] == 1 and db["send_wildcards"] == 1, db)
|
||||
db_good = json.loads(text(by_id[6]))
|
||||
check("dbus_audit accepts a specific bus name",
|
||||
db_good["findings_count"] == 0 and
|
||||
db_good["own_wildcards"] == 0, db_good)
|
||||
nx = json.loads(text(by_id[7]))
|
||||
check("nexus_probe finds the open repository API",
|
||||
nx["repositories_open"] is True and nx["evidence"] and
|
||||
os.path.isfile(nx["evidence"]), nx)
|
||||
nx_auth = json.loads(text(by_id[8]))
|
||||
check("nexus_probe reports a protected API",
|
||||
nx_auth["repositories_open"] is False and
|
||||
all(e["status"] == 401 for e in nx_auth["endpoints"]
|
||||
if "repositories" in e["path"]), nx_auth)
|
||||
check("nexus_probe refuses an out-of-scope target", err(by_id[9]),
|
||||
text(by_id[9]))
|
||||
check("bluetooth_audit reports a missing config", err(by_id[10]),
|
||||
text(by_id[10]))
|
||||
check("networkmanager_audit reports a missing config", err(by_id[11]),
|
||||
text(by_id[11]))
|
||||
check("dbus_audit reports missing policies", err(by_id[12]),
|
||||
text(by_id[12]))
|
||||
nx_srv.shutdown()
|
||||
nx_srv.server_close()
|
||||
nx_auth_srv.shutdown()
|
||||
nx_auth_srv.server_close()
|
||||
shutil.rmtree(bt_root, ignore_errors=True)
|
||||
shutil.rmtree(bt_good_root, ignore_errors=True)
|
||||
shutil.rmtree(nm_root, ignore_errors=True)
|
||||
shutil.rmtree(nm_good_root, ignore_errors=True)
|
||||
shutil.rmtree(db_root, ignore_errors=True)
|
||||
shutil.rmtree(db_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg38_home, ignore_errors=True)
|
||||
|
||||
print("\n== esp32 tools ==")
|
||||
|
||||
|
||||
@@ -13587,6 +13777,7 @@ print("\n== esp32 tools ==")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
esp_home = tempfile.mkdtemp(prefix="apex-esp-")
|
||||
|
||||
Reference in new issue
Block a user