apex-twin 1.60.0: sshd_config, hosts_access and profile audits, Kibana probe
Blue: - sshd_config_audit: sshd_config and sshd_config.d/*.conf with OpenSSH's first-value-wins order (drop-ins read before the main file): root login, password auth, empty passwords, X11, MaxAuthTries above 3, no AllowUsers/AllowGroups, world-writable files. - hosts_access_audit: hosts.allow with ALL: ALL, a missing hosts.deny, world-writable files. - profile_audit: /etc/profile, bash.bashrc and profile.d/*.sh: world-writable scripts, a umask that leaves group/other write, a PATH with . or an empty entry. Red: - kibana_api_probe: /api/status and /api/saved_objects/_find?type=dashboard without credentials; the saved-objects answer is evidence. Tests with sshd/hosts.allow/profile trees (including a drop-in overriding the main sshd_config) and two Kibana fixtures. 1181 checks, ASan suite green, analyze clean, release-check green including distcheck 1.60.0.
This commit is contained in:
1 parent
f1fbf9d8fe
commit
ddb99c0609
9 files changed
+773
-15
No files matched your search
+20
-1
@@ -8,7 +8,26 @@ 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.59.0 — 2026-11-23 — this change
|
||||
## 1.60.0 — 2026-11-23 — this change
|
||||
|
||||
- **sshd_config** (`sshd_config_audit`): `sshd_config` and
|
||||
`sshd_config.d/*.conf` with OpenSSH's first-value-wins order (drop-ins
|
||||
before the main file): `PermitRootLogin yes`, password authentication,
|
||||
empty passwords, X11 forwarding, `MaxAuthTries` above 3, no
|
||||
`AllowUsers`/`AllowGroups` and world-writable files.
|
||||
- **hosts_access** (`hosts_access_audit`): `hosts.allow` with `ALL: ALL`,
|
||||
missing `hosts.deny` rules and world-writable files.
|
||||
- **profiles** (`profile_audit`): `/etc/profile`, `bash.bashrc` and
|
||||
`profile.d/*.sh`: world-writable scripts, a umask that leaves group or
|
||||
other write allowed and a `PATH` with `.` or an empty entry.
|
||||
- **Kibana** (`kibana_api_probe`): `/api/status` and
|
||||
`/api/saved_objects/_find?type=dashboard` without credentials; a 2xx with
|
||||
saved objects is an open API and is saved as evidence.
|
||||
- Tests with sshd/hosts.allow/profile trees (including a drop-in that
|
||||
overrides the main config) and two Kibana fixtures. 1181 checks.
|
||||
Coverage 84.1%.
|
||||
|
||||
## 1.59.0 — 2026-11-23 — f1fbf9d
|
||||
|
||||
- **Telegraf** (`telegraf_audit`): `telegraf.conf`: an HTTP output URL,
|
||||
`insecure_skip_verify = true`, credentials in the file and a
|
||||
|
||||
@@ -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.
|
||||
|
||||
**274 tools · 1168 end-to-end checks · 340 fuzz cases · 84.1% line coverage · ~954 KiB**
|
||||
**278 tools · 1181 end-to-end checks · 340 fuzz cases · 84.1% line coverage · ~966 KiB**
|
||||
|
||||
```
|
||||
$ ./apex-twin --check
|
||||
{"version":"1.59.0","tools":274,...,"scope":{"loaded":true,...}}
|
||||
{"version":"1.60.0","tools":278,...,"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 (274)
|
||||
## Tools (278)
|
||||
|
||||
### Scope and bookkeeping
|
||||
|
||||
@@ -218,6 +218,7 @@ uploads and secret-file reads. It does not execute anything.
|
||||
| `nats_monitoring_probe` | `/varz` and `/connz` without auth; varz answer as evidence |
|
||||
| `influxdb_probe` | `/ping` and `/query?q=SHOW DATABASES` without auth; answer as evidence |
|
||||
| `clickhouse_probe` | `/ping` and `SELECT version()` without auth; version as evidence |
|
||||
| `kibana_api_probe` | `/api/saved_objects/_find` without auth; answer 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 |
|
||||
@@ -471,6 +472,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `telegraf_audit` | HTTP output, insecure_skip_verify, credentials in file |
|
||||
| `graylog_audit` | REST on 0.0.0.0, short password_secret, empty root hash |
|
||||
| `netdata_audit` | bind 0.0.0.0, allow list `*`, missing allow list |
|
||||
| `sshd_config_audit` | sshd_config(.d): root login, password auth, empty passwords |
|
||||
| `hosts_access_audit` | hosts.allow/deny: `ALL: ALL`, missing deny rules |
|
||||
| `profile_audit` | profile scripts: world-writable, loose umask, `.` in PATH |
|
||||
|
||||
### ESP32
|
||||
|
||||
@@ -777,6 +781,8 @@ The full threat model, trust boundaries and a hardening checklist are in
|
||||
| InfluxDB | two unauthenticated GETs, query answer as evidence |
|
||||
| telegraf/graylog/netdata | config reads only; optional root prefix |
|
||||
| ClickHouse | two unauthenticated GETs, version as evidence |
|
||||
| sshd_config/hosts_access/profile | config reads only; optional root prefix |
|
||||
| Kibana API | two unauthenticated GETs, saved objects as evidence |
|
||||
| USB audit | 200 devices, sysfs reads only |
|
||||
|
||||
---
|
||||
@@ -788,7 +794,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
|
||||
|
||||
```sh
|
||||
make # apex-twin
|
||||
make test # version check + gate audit + 1168 end-to-end checks
|
||||
make test # version check + gate audit + 1181 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
|
||||
@@ -917,7 +923,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
|
||||
couchdb_probe, prometheus_api_probe,
|
||||
rabbitmq_management_probe, grafana_api_probe,
|
||||
minio_admin_probe, nats_monitoring_probe,
|
||||
influxdb_probe, clickhouse_probe
|
||||
influxdb_probe, clickhouse_probe, kibana_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,
|
||||
@@ -960,7 +966,7 @@ examples/ scope.json
|
||||
|
||||
## Status
|
||||
|
||||
1.59.0. Built and run: 274 tools, 1168 checks, 340 fuzz cases and 84.1% line
|
||||
1.60.0. Built and run: 278 tools, 1181 checks, 340 fuzz cases and 84.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
|
||||
|
||||
+4
-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.59.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
|
||||
is **1.60.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,9 @@ 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.
|
||||
- **sshd_config, hosts_access and profile audits read local files.** The
|
||||
Kibana probe sends two unauthenticated GETs and saves the saved-objects
|
||||
answer.
|
||||
- **Telegraf, Graylog and Netdata audits read local files.** The ClickHouse
|
||||
probe sends two unauthenticated GETs and saves the query answer.
|
||||
- **Logstash, Filebeat and Fluentd audits read local files.** The InfluxDB
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
.\" apex-twin.1 - manual page for APEX TWIN
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.59.0" "User Commands"
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.60.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),
|
||||
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),
|
||||
defensive
|
||||
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
|
||||
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
|
||||
@@ -75,7 +75,8 @@ autofs_audit, gitea_audit, minio_audit, nextcloud_audit, zabbix_audit, nrpe_audi
|
||||
unattended_upgrades_audit, gitlab_audit, vaultwarden_audit,
|
||||
keepalived_audit, webmin_audit, cockpit_audit, phpmyadmin_audit, kibana_audit,
|
||||
nagios_audit, synapse_audit, logstash_audit, filebeat_audit,
|
||||
fluentd_audit, telegraf_audit, graylog_audit, netdata_audit)
|
||||
fluentd_audit, telegraf_audit, graylog_audit, netdata_audit, sshd_config_audit,
|
||||
hosts_access_audit, profile_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.59.0"
|
||||
#define APEX_VERSION "1.60.0"
|
||||
#define APEX_MAX_OUT (1u << 20)
|
||||
#define APEX_PATH_MAX 512
|
||||
#define APEX_PATH_FULL 1024
|
||||
|
||||
@@ -17839,6 +17839,427 @@ static void t_netdata_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- sshd_config_audit */
|
||||
|
||||
typedef struct {
|
||||
char root_login[64];
|
||||
char password_auth[64];
|
||||
char empty_passwords[64];
|
||||
char x11[64];
|
||||
char max_tries[64];
|
||||
char allow_users[64];
|
||||
char allow_groups[64];
|
||||
} sshd_values;
|
||||
|
||||
static void sshd_capture(const char *text, sshd_values *v)
|
||||
{
|
||||
if (v->root_login[0] == '\0')
|
||||
line_value(text, "PermitRootLogin", v->root_login,
|
||||
sizeof(v->root_login));
|
||||
if (v->password_auth[0] == '\0')
|
||||
line_value(text, "PasswordAuthentication", v->password_auth,
|
||||
sizeof(v->password_auth));
|
||||
if (v->empty_passwords[0] == '\0')
|
||||
line_value(text, "PermitEmptyPasswords", v->empty_passwords,
|
||||
sizeof(v->empty_passwords));
|
||||
if (v->x11[0] == '\0')
|
||||
line_value(text, "X11Forwarding", v->x11, sizeof(v->x11));
|
||||
if (v->max_tries[0] == '\0')
|
||||
line_value(text, "MaxAuthTries", v->max_tries,
|
||||
sizeof(v->max_tries));
|
||||
if (v->allow_users[0] == '\0')
|
||||
line_value(text, "AllowUsers", v->allow_users,
|
||||
sizeof(v->allow_users));
|
||||
if (v->allow_groups[0] == '\0')
|
||||
line_value(text, "AllowGroups", v->allow_groups,
|
||||
sizeof(v->allow_groups));
|
||||
}
|
||||
|
||||
static void sshd_scan_dir(mcp_buf *findings, int *first, int *count,
|
||||
const char *dirpath, sshd_values *v, int *files)
|
||||
{
|
||||
DIR *d = opendir(dirpath);
|
||||
struct dirent *ent;
|
||||
|
||||
if (d == NULL)
|
||||
return;
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
static char text[65536];
|
||||
char full[1200];
|
||||
struct stat st;
|
||||
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);
|
||||
if (stat(full, &st) != 0 || !S_ISREG(st.st_mode))
|
||||
continue;
|
||||
if ((st.st_mode & 0002) != 0) {
|
||||
add_finding(findings, first, "world-writable", "high",
|
||||
"%s is writable by anyone", full);
|
||||
(*count)++;
|
||||
}
|
||||
if (read_text(full, text, sizeof(text)) > 0) {
|
||||
(*files)++;
|
||||
sshd_capture(text, v);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
static void t_sshd_config_audit(mcp_conn *c, const mcp_json *args,
|
||||
void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char path[1024];
|
||||
char dropin[1024];
|
||||
static char text[65536];
|
||||
struct stat st;
|
||||
sshd_values v;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files = 0;
|
||||
int root_login = 0;
|
||||
int password_auth = 0;
|
||||
int empty_passwords = 0;
|
||||
int x11 = 0;
|
||||
int no_allow_list = 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/ssh/sshd_config", root);
|
||||
snprintf(dropin, sizeof(dropin), "%s/etc/ssh/sshd_config.d", root);
|
||||
memset(&v, 0, sizeof(v));
|
||||
mcp_buf_init(&findings);
|
||||
/* OpenSSH keeps the first value it reads, so drop-ins first. */
|
||||
sshd_scan_dir(&findings, &first, &count, dropin, &v, &files);
|
||||
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++;
|
||||
}
|
||||
sshd_capture(text, &v);
|
||||
}
|
||||
if (files == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "cannot read a sshd_config");
|
||||
return;
|
||||
}
|
||||
if (strcasecmp(v.root_login, "yes") == 0) {
|
||||
root_login = 1;
|
||||
add_finding(&findings, &first, "root-login", "high",
|
||||
"root may log in over SSH");
|
||||
count++;
|
||||
}
|
||||
if (strcasecmp(v.password_auth, "yes") == 0) {
|
||||
password_auth = 1;
|
||||
add_finding(&findings, &first, "password-auth", "medium",
|
||||
"password authentication is enabled");
|
||||
count++;
|
||||
}
|
||||
if (strcasecmp(v.empty_passwords, "yes") == 0) {
|
||||
empty_passwords = 1;
|
||||
add_finding(&findings, &first, "empty-passwords", "high",
|
||||
"accounts with empty passwords may log in");
|
||||
count++;
|
||||
}
|
||||
if (strcasecmp(v.x11, "yes") == 0) {
|
||||
x11 = 1;
|
||||
add_finding(&findings, &first, "x11", "low",
|
||||
"X11 forwarding is enabled");
|
||||
count++;
|
||||
}
|
||||
if (v.max_tries[0] != '\0' && atoi(v.max_tries) > 3) {
|
||||
add_finding(&findings, &first, "max-auth-tries", "low",
|
||||
"MaxAuthTries is %s", v.max_tries);
|
||||
count++;
|
||||
}
|
||||
if (v.allow_users[0] == '\0' && v.allow_groups[0] == '\0') {
|
||||
no_allow_list = 1;
|
||||
add_finding(&findings, &first, "no-allow-list", "low",
|
||||
"no AllowUsers or AllowGroups restricts logins");
|
||||
count++;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"root_login\":%s,"
|
||||
"\"password_auth\":%s,\"empty_passwords\":%s,"
|
||||
"\"x11\":%s,\"max_auth_tries\":", files,
|
||||
root_login ? "true" : "false",
|
||||
password_auth ? "true" : "false",
|
||||
empty_passwords ? "true" : "false",
|
||||
x11 ? "true" : "false");
|
||||
if (v.max_tries[0] != '\0')
|
||||
mcp_buf_printf(&b, "%d", atoi(v.max_tries));
|
||||
else
|
||||
mcp_buf_puts(&b, "null");
|
||||
mcp_buf_printf(&b, ",\"allow_list\":%s,\"findings_count\":%d,"
|
||||
"\"findings\":[",
|
||||
no_allow_list ? "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);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- hosts_access_audit */
|
||||
|
||||
static void t_hosts_access_audit(mcp_conn *c, const mcp_json *args,
|
||||
void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char allow_path[1024];
|
||||
char deny_path[1024];
|
||||
static char allow_text[65536];
|
||||
static char deny_text[65536];
|
||||
struct stat st;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int allow_all = 0;
|
||||
int no_deny = 0;
|
||||
int allow_read;
|
||||
int deny_read;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
snprintf(allow_path, sizeof(allow_path), "%s/etc/hosts.allow", root);
|
||||
snprintf(deny_path, sizeof(deny_path), "%s/etc/hosts.deny", root);
|
||||
allow_read = read_text(allow_path, allow_text, sizeof(allow_text)) > 0;
|
||||
deny_read = read_text(deny_path, deny_text, sizeof(deny_text)) > 0;
|
||||
if (!allow_read && !deny_read) {
|
||||
mcp_reply_error(c, "cannot read hosts.allow or hosts.deny");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
if (allow_read) {
|
||||
if (stat(allow_path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(&findings, &first, "world-writable", "high",
|
||||
"hosts.allow is writable by anyone");
|
||||
count++;
|
||||
}
|
||||
if (text_has_line(allow_text, "ALL:", "ALL") ||
|
||||
text_has_line(allow_text, "ALL:", "0.0.0.0/0"))
|
||||
allow_all = 1;
|
||||
}
|
||||
if (deny_read) {
|
||||
if (stat(deny_path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(&findings, &first, "world-writable", "high",
|
||||
"hosts.deny is writable by anyone");
|
||||
count++;
|
||||
}
|
||||
if (deny_text[0] == '\0')
|
||||
no_deny = 1;
|
||||
} else {
|
||||
no_deny = 1;
|
||||
}
|
||||
if (allow_all) {
|
||||
add_finding(&findings, &first, "allow-all", "high",
|
||||
"hosts.allow grants every service to every host");
|
||||
count++;
|
||||
}
|
||||
if (no_deny) {
|
||||
add_finding(&findings, &first, "no-deny", "low",
|
||||
"no hosts.deny rules exist");
|
||||
count++;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"allow_all\":%s,\"deny_rules\":%s,"
|
||||
"\"findings_count\":%d,\"findings\":[",
|
||||
allow_all ? "true" : "false",
|
||||
no_deny ? "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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- profile_audit */
|
||||
|
||||
static int profile_path_dot(const char *text)
|
||||
{
|
||||
char *copy = strdup(text);
|
||||
char *save = NULL;
|
||||
char *line;
|
||||
int found = 0;
|
||||
|
||||
if (copy == NULL)
|
||||
return 0;
|
||||
line = strtok_r(copy, "\n", &save);
|
||||
while (line != NULL) {
|
||||
char *s = line;
|
||||
|
||||
while (*s == ' ' || *s == '\t')
|
||||
s++;
|
||||
if (*s != '#' && strncmp(s, "PATH=", 5) == 0 &&
|
||||
(strstr(s, ".:") != NULL || strstr(s, ":.") != NULL ||
|
||||
strstr(s, "::") != NULL || strstr(s, "PATH=:") != NULL)) {
|
||||
size_t pl = strlen(s);
|
||||
|
||||
found = 1;
|
||||
if (pl > 0 && s[pl - 1] == ':')
|
||||
found = 1;
|
||||
}
|
||||
line = strtok_r(NULL, "\n", &save);
|
||||
}
|
||||
free(copy);
|
||||
return found;
|
||||
}
|
||||
|
||||
static void profile_scan_file(mcp_buf *findings, int *first, int *count,
|
||||
const char *path, int *files, int *loose_umask,
|
||||
int *path_dot)
|
||||
{
|
||||
static char text[65536];
|
||||
struct stat st;
|
||||
char *copy;
|
||||
char *save = NULL;
|
||||
char *line;
|
||||
|
||||
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 (profile_path_dot(text))
|
||||
*path_dot = 1;
|
||||
copy = strdup(text);
|
||||
if (copy == NULL)
|
||||
return;
|
||||
line = strtok_r(copy, "\n", &save);
|
||||
while (line != NULL) {
|
||||
char *s = line;
|
||||
|
||||
while (*s == ' ' || *s == '\t')
|
||||
s++;
|
||||
if (*s != '#' && strncmp(s, "umask", 5) == 0) {
|
||||
char *v = s + 5;
|
||||
unsigned long u;
|
||||
|
||||
while (*v == ' ' || *v == '\t')
|
||||
v++;
|
||||
u = strtoul(v, NULL, 8);
|
||||
if ((u & 0022) != 0022)
|
||||
*loose_umask = (u == 0) ? 2 : 1;
|
||||
}
|
||||
line = strtok_r(NULL, "\n", &save);
|
||||
}
|
||||
free(copy);
|
||||
}
|
||||
|
||||
static void t_profile_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
static const char *files[] = { "/etc/profile", "/etc/bash.bashrc", NULL };
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char path[1024];
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files_read = 0;
|
||||
int loose_umask = 0;
|
||||
int path_dot = 0;
|
||||
DIR *d;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; files[i] != NULL; i++) {
|
||||
snprintf(path, sizeof(path), "%.400s%s", root,
|
||||
files[i]);
|
||||
profile_scan_file(&findings, &first, &count, path,
|
||||
&files_read, &loose_umask,
|
||||
&path_dot);
|
||||
}
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s/etc/profile.d", root);
|
||||
d = opendir(path);
|
||||
if (d != NULL) {
|
||||
struct dirent *ent;
|
||||
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
char full[1200];
|
||||
size_t nl = strlen(ent->d_name);
|
||||
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
if (nl < 4 || strcmp(ent->d_name + nl - 3, ".sh") != 0)
|
||||
continue;
|
||||
snprintf(full, sizeof(full), "%.900s/%.200s", path,
|
||||
ent->d_name);
|
||||
profile_scan_file(&findings, &first, &count, full,
|
||||
&files_read, &loose_umask,
|
||||
&path_dot);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
if (files_read == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "cannot read a shell profile");
|
||||
return;
|
||||
}
|
||||
if (loose_umask) {
|
||||
add_finding(&findings, &first, "loose-umask",
|
||||
loose_umask == 2 ? "high" : "medium",
|
||||
"a profile leaves group or other write allowed");
|
||||
count++;
|
||||
}
|
||||
if (path_dot) {
|
||||
add_finding(&findings, &first, "path-dot", "high",
|
||||
"a profile puts the current or an empty entry in PATH");
|
||||
count++;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"loose_umask\":%s,"
|
||||
"\"path_dot\":%s,\"findings_count\":%d,\"findings\":[",
|
||||
files_read, loose_umask ? "true" : "false",
|
||||
path_dot ? "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, "
|
||||
@@ -18851,6 +19272,27 @@ const mcp_tool TOOLS_BLUE[] = {
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_netdata_audit },
|
||||
{ "sshd_config_audit",
|
||||
"Parse sshd_config and sshd_config.d/*.conf (root prefix, first value "
|
||||
"wins): root login, password authentication, empty passwords, X11, "
|
||||
"MaxAuthTries above 3, no AllowUsers/AllowGroups, world-writable files. "
|
||||
"Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_sshd_config_audit },
|
||||
{ "hosts_access_audit",
|
||||
"Parse hosts.allow and hosts.deny (root prefix): ALL: ALL in the allow "
|
||||
"file, missing deny rules and world-writable files. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_hosts_access_audit },
|
||||
{ "profile_audit",
|
||||
"Parse /etc/profile, bash.bashrc and profile.d/*.sh (root prefix): "
|
||||
"world-writable scripts, a umask that leaves group or other write and "
|
||||
"a PATH with a dot or empty entry. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_profile_audit },
|
||||
};
|
||||
|
||||
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
|
||||
@@ -7464,6 +7464,93 @@ static void t_clickhouse_probe(mcp_conn *c, const mcp_json *args,
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------- kibana_api_probe */
|
||||
|
||||
static void t_kibana_api_probe(mcp_conn *c, const mcp_json *args,
|
||||
void *user)
|
||||
{
|
||||
static const char *paths[] = { "/api/status",
|
||||
"/api/saved_objects/_find?type=dashboard",
|
||||
NULL };
|
||||
const char *target = mcp_arg_string(args, "target");
|
||||
int port = mcp_arg_int(args, "port", 5601);
|
||||
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 saved_objects_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, "kibana_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 saved = strncmp(paths[i], "/api/saved_objects", 18) == 0;
|
||||
|
||||
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 && saved) {
|
||||
saved_objects_open = 1;
|
||||
if (evidence == NULL)
|
||||
evidence = apex_evidence_save("kibana-saved-objects",
|
||||
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,"
|
||||
"\"saved_objects_open\":%s,\"evidence\":",
|
||||
tested, open_count,
|
||||
saved_objects_open ? "true" : "false");
|
||||
if (evidence != NULL)
|
||||
apex_json_str(&b, evidence);
|
||||
else
|
||||
mcp_buf_puts(&b, "null");
|
||||
mcp_buf_puts(&b, "}");
|
||||
apex_audit("kibana_api_probe", target, port, !saved_objects_open,
|
||||
saved_objects_open
|
||||
? "Kibana returns dashboards without authentication"
|
||||
: "Kibana 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: "
|
||||
@@ -8097,6 +8184,16 @@ const mcp_tool TOOLS_RED[] = {
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_clickhouse_probe },
|
||||
{ "kibana_api_probe",
|
||||
"Query Kibana without credentials: /api/status and "
|
||||
"/api/saved_objects/_find?type=dashboard. A 2xx with saved objects is "
|
||||
"an open API; the answer is saved as evidence. Gate: the target.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"target\":{\"type\":\"string\"},"
|
||||
"\"port\":{\"type\":\"integer\",\"description\":\"default 5601\"},"
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_kibana_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
@@ -21,7 +21,7 @@ import re
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
EXPECTED_TOOLS = 274
|
||||
EXPECTED_TOOLS = 278
|
||||
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.
|
||||
|
||||
+192
-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("274 tools registered", len(tools) == 274, len(tools))
|
||||
check("278 tools registered", len(tools) == 278, 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"]) == 274)
|
||||
check("http tools/list", len(listing["result"]["tools"]) == 278)
|
||||
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
|
||||
@@ -12560,6 +12560,195 @@ shutil.rmtree(nd_root, ignore_errors=True)
|
||||
shutil.rmtree(nd_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg31_home, ignore_errors=True)
|
||||
|
||||
print("\n== sshd_config, hosts_access, profiles and Kibana ==\n")
|
||||
|
||||
ss_root = tempfile.mkdtemp(prefix="apex-ss-")
|
||||
os.makedirs(os.path.join(ss_root, "etc", "ssh"))
|
||||
ss_bad = os.path.join(ss_root, "etc", "ssh", "sshd_config")
|
||||
with open(ss_bad, "w") as f:
|
||||
f.write("PermitRootLogin yes\n")
|
||||
f.write("PasswordAuthentication yes\n")
|
||||
f.write("PermitEmptyPasswords yes\n")
|
||||
f.write("X11Forwarding yes\n")
|
||||
f.write("MaxAuthTries 10\n")
|
||||
os.chmod(ss_bad, 0o666)
|
||||
ss_good_root = tempfile.mkdtemp(prefix="apex-ssg-")
|
||||
os.makedirs(os.path.join(ss_good_root, "etc", "ssh"))
|
||||
with open(os.path.join(ss_good_root, "etc", "ssh", "sshd_config"),
|
||||
"w") as f:
|
||||
f.write("PermitRootLogin no\n")
|
||||
f.write("PasswordAuthentication no\n")
|
||||
f.write("PermitEmptyPasswords no\n")
|
||||
f.write("X11Forwarding no\n")
|
||||
f.write("MaxAuthTries 3\n")
|
||||
f.write("AllowUsers deploy\n")
|
||||
ss_drop_root = tempfile.mkdtemp(prefix="apex-ssd-")
|
||||
os.makedirs(os.path.join(ss_drop_root, "etc", "ssh", "sshd_config.d"))
|
||||
with open(os.path.join(ss_drop_root, "etc", "ssh", "sshd_config"),
|
||||
"w") as f:
|
||||
f.write("PermitRootLogin no\n")
|
||||
with open(os.path.join(ss_drop_root, "etc", "ssh", "sshd_config.d",
|
||||
"50-root.conf"), "w") as f:
|
||||
f.write("PermitRootLogin yes\n")
|
||||
|
||||
ha_root = tempfile.mkdtemp(prefix="apex-ha-")
|
||||
os.makedirs(os.path.join(ha_root, "etc"))
|
||||
ha_allow = os.path.join(ha_root, "etc", "hosts.allow")
|
||||
with open(ha_allow, "w") as f:
|
||||
f.write("ALL: ALL\n")
|
||||
os.chmod(ha_allow, 0o666)
|
||||
ha_good_root = tempfile.mkdtemp(prefix="apex-hag-")
|
||||
os.makedirs(os.path.join(ha_good_root, "etc"))
|
||||
with open(os.path.join(ha_good_root, "etc", "hosts.allow"), "w") as f:
|
||||
f.write("sshd: 10.0.0.0/8\n")
|
||||
with open(os.path.join(ha_good_root, "etc", "hosts.deny"), "w") as f:
|
||||
f.write("ALL: ALL\n")
|
||||
|
||||
pr_root = tempfile.mkdtemp(prefix="apex-pr-")
|
||||
os.makedirs(os.path.join(pr_root, "etc"))
|
||||
pr_bad = os.path.join(pr_root, "etc", "profile")
|
||||
with open(pr_bad, "w") as f:
|
||||
f.write("umask 000\n")
|
||||
f.write("PATH=.:/usr/bin\n")
|
||||
os.chmod(pr_bad, 0o666)
|
||||
pr_good_root = tempfile.mkdtemp(prefix="apex-prg-")
|
||||
os.makedirs(os.path.join(pr_good_root, "etc"))
|
||||
with open(os.path.join(pr_good_root, "etc", "profile"), "w") as f:
|
||||
f.write("umask 027\n")
|
||||
f.write("PATH=/usr/local/bin:/usr/bin\n")
|
||||
|
||||
|
||||
class _KibanaHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/api/status":
|
||||
body = b'{"status":{"overall":{"level":"available"}}}'
|
||||
self.send_response(200)
|
||||
elif path == "/api/saved_objects/_find":
|
||||
body = b'{"saved_objects":[],"total":0}'
|
||||
self.send_response(200)
|
||||
else:
|
||||
body = b'{"statusCode":404}'
|
||||
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 _KibanaAuthHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/api/status":
|
||||
body = b'{"status":{"overall":{"level":"available"}}}'
|
||||
self.send_response(200)
|
||||
else:
|
||||
body = b'{"statusCode":401,"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
|
||||
|
||||
|
||||
kb_srv = http.server.HTTPServer(("127.0.0.1", 0), _KibanaHandler)
|
||||
kb_port = kb_srv.server_address[1]
|
||||
threading.Thread(target=kb_srv.serve_forever, daemon=True).start()
|
||||
kb_auth_srv = http.server.HTTPServer(("127.0.0.1", 0),
|
||||
_KibanaAuthHandler)
|
||||
kb_auth_port = kb_auth_srv.server_address[1]
|
||||
threading.Thread(target=kb_auth_srv.serve_forever, daemon=True).start()
|
||||
|
||||
cfg32_home = tempfile.mkdtemp(prefix="apex-cfg32-home-")
|
||||
write_scope(cfg32_home, {"label": "cfg32", "expires": "2099-12-31T23:59:59Z",
|
||||
"allow_private": True, "allow_ip": ["127.0.0.1"],
|
||||
"allow_port": [str(kb_port), str(kb_auth_port)]})
|
||||
res, _ = run([
|
||||
call(1, "sshd_config_audit", root=ss_root),
|
||||
call(2, "sshd_config_audit", root=ss_good_root),
|
||||
call(3, "sshd_config_audit", root=ss_drop_root),
|
||||
call(4, "hosts_access_audit", root=ha_root),
|
||||
call(5, "hosts_access_audit", root=ha_good_root),
|
||||
call(6, "profile_audit", root=pr_root),
|
||||
call(7, "profile_audit", root=pr_good_root),
|
||||
call(8, "kibana_api_probe", target="127.0.0.1", port=kb_port,
|
||||
tls=False),
|
||||
call(9, "kibana_api_probe", target="127.0.0.1", port=kb_auth_port,
|
||||
tls=False),
|
||||
call(10, "kibana_api_probe", target="198.51.100.9", port=5601),
|
||||
call(11, "sshd_config_audit", root="/nonexistent-ss"),
|
||||
call(12, "hosts_access_audit", root="/nonexistent-ha"),
|
||||
call(13, "profile_audit", root="/nonexistent-pr"),
|
||||
], home=cfg32_home)
|
||||
by_id = {r.get("id"): r for r in res}
|
||||
ss = json.loads(text(by_id[1]))
|
||||
ss_kinds = {f["id"] for f in ss["findings"]}
|
||||
check("sshd_config_audit flags root login, passwords and X11",
|
||||
{"world-writable", "root-login", "password-auth",
|
||||
"empty-passwords", "x11", "max-auth-tries",
|
||||
"no-allow-list"} <= ss_kinds and ss["root_login"] is True and
|
||||
ss["max_auth_tries"] == 10, ss)
|
||||
ss_good = json.loads(text(by_id[2]))
|
||||
check("sshd_config_audit accepts a hardened config",
|
||||
ss_good["findings_count"] == 0 and ss_good["root_login"] is False and
|
||||
ss_good["allow_list"] is True, ss_good)
|
||||
ss_drop = json.loads(text(by_id[3]))
|
||||
check("sshd_config_audit lets a drop-in override the main file",
|
||||
"root-login" in {f["id"] for f in ss_drop["findings"]}, ss_drop)
|
||||
ha = json.loads(text(by_id[4]))
|
||||
ha_kinds = {f["id"] for f in ha["findings"]}
|
||||
check("hosts_access_audit flags ALL: ALL and a missing deny",
|
||||
{"world-writable", "allow-all", "no-deny"} <= ha_kinds and
|
||||
ha["allow_all"] is True, ha)
|
||||
ha_good = json.loads(text(by_id[5]))
|
||||
check("hosts_access_audit accepts scoped allow and deny rules",
|
||||
ha_good["findings_count"] == 0 and ha_good["allow_all"] is False and
|
||||
ha_good["deny_rules"] is True, ha_good)
|
||||
pr = json.loads(text(by_id[6]))
|
||||
pr_kinds = {f["id"] for f in pr["findings"]}
|
||||
check("profile_audit flags a world-writable profile, umask and PATH dot",
|
||||
{"world-writable", "loose-umask", "path-dot"} <= pr_kinds and
|
||||
pr["loose_umask"] is True and pr["path_dot"] is True, pr)
|
||||
pr_good = json.loads(text(by_id[7]))
|
||||
check("profile_audit accepts a tight umask and clean PATH",
|
||||
pr_good["findings_count"] == 0 and
|
||||
pr_good["loose_umask"] is False and pr_good["path_dot"] is False,
|
||||
pr_good)
|
||||
kb = json.loads(text(by_id[8]))
|
||||
check("kibana_api_probe finds open saved objects",
|
||||
kb["saved_objects_open"] is True and kb["evidence"] and
|
||||
os.path.isfile(kb["evidence"]), kb)
|
||||
kb_auth = json.loads(text(by_id[9]))
|
||||
check("kibana_api_probe reports a protected API",
|
||||
kb_auth["saved_objects_open"] is False and
|
||||
all(e["status"] == 401 for e in kb_auth["endpoints"]
|
||||
if "saved_objects" in e["path"]), kb_auth)
|
||||
check("kibana_api_probe refuses an out-of-scope target", err(by_id[10]),
|
||||
text(by_id[10]))
|
||||
check("sshd_config_audit reports a missing config", err(by_id[11]),
|
||||
text(by_id[11]))
|
||||
check("hosts_access_audit reports missing files", err(by_id[12]),
|
||||
text(by_id[12]))
|
||||
check("profile_audit reports missing files", err(by_id[13]),
|
||||
text(by_id[13]))
|
||||
kb_srv.shutdown()
|
||||
kb_srv.server_close()
|
||||
kb_auth_srv.shutdown()
|
||||
kb_auth_srv.server_close()
|
||||
shutil.rmtree(ss_root, ignore_errors=True)
|
||||
shutil.rmtree(ss_good_root, ignore_errors=True)
|
||||
shutil.rmtree(ss_drop_root, ignore_errors=True)
|
||||
shutil.rmtree(ha_root, ignore_errors=True)
|
||||
shutil.rmtree(ha_good_root, ignore_errors=True)
|
||||
shutil.rmtree(pr_root, ignore_errors=True)
|
||||
shutil.rmtree(pr_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg32_home, ignore_errors=True)
|
||||
|
||||
print("\n== esp32 tools ==")
|
||||
|
||||
|
||||
@@ -12580,6 +12769,7 @@ print("\n== esp32 tools ==")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
esp_home = tempfile.mkdtemp(prefix="apex-esp-")
|
||||
write_scope(esp_home, {"label": "esp", "expires": "2099-12-31T23:59:59Z"})
|
||||
|
||||
Reference in new issue
Block a user