apex-twin 1.68.0: gitconfig, npmrc and pip.conf audits, Harbor probe

gitconfig_audit (blue): http.sslVerify=false, a url.*.insteadOf rewrite to
http://, credential.helper=store and a world-writable /etc/gitconfig.

npmrc_audit (blue): strict-ssl=false, a plain-HTTP registry, a cleartext
_authToken and world-writable npmrc files.

pip_conf_audit (blue): a plain-HTTP index-url, a trusted-host override and
world-writable pip.conf files.

harbor_probe (red): GET /api/v2.0/health and /api/v2.0/projects without
credentials; a 2xx project list is an open Harbor API and is saved as
evidence.

Verified: make test 1278/1278, make test-asan 1278/1278, make analyze 0
warnings, make coverage 84.6%, make version-check 1.68.0 in 5 places,
make gate-audit 310 tools, make release-check builds and passes from the
tarball.
This commit is contained in:
lotherk committed 2026-11-22 18:43:00 +00:00
1 parent 7b853ad392
commit 98c7ae7023
9 files changed
+622 -15

No files matched your search

+15 -1
View File
@@ -8,7 +8,21 @@ 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.67.0 — 2026-11-23 — this change
## 1.68.0 — 2026-11-23 — this change
- **git config** (`gitconfig_audit`): `/etc/gitconfig`: `http.sslVerify=false`,
a URL rewrite to `http://`, `credential.helper=store` and a world-writable
file.
- **npm config** (`npmrc_audit`): npmrc files: `strict-ssl=false`, an HTTP
registry, a cleartext `_authToken` and world-writable files.
- **pip config** (`pip_conf_audit`): pip.conf files: an HTTP index, a
`trusted-host` override and world-writable files.
- **Harbor** (`harbor_probe`): `/api/v2.0/health` and `/api/v2.0/projects`
without credentials; a 2xx project list is an open API, saved as evidence.
- Tests with git/npm/pip config trees and two Harbor fixtures (open and 401).
1278 checks. Coverage 84.6%.
## 1.67.0 — 2026-11-23 — 7b853ad
- **passwd** (`passwd_audit`): `/etc/passwd` and `/etc/shadow`: duplicate
UID 0, empty shadow hashes, system accounts with a login shell and
+12 -6
View File
@@ -5,11 +5,11 @@ no Python in the serving path. It gives an agent real reconnaissance and real we
testing behind a scope gate that refuses everything until a rules-of-engagement
file says otherwise.
**306 tools · 1266 end-to-end checks · 340 fuzz cases · 84.5% line coverage · ~1029 KiB**
**310 tools · 1278 end-to-end checks · 340 fuzz cases · 84.6% line coverage · ~1041 KiB**
```
$ ./apex-twin --check
{"version":"1.67.0","tools":306,...,"scope":{"loaded":true,...}}
{"version":"1.68.0","tools":310,...,"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 (306)
## Tools (310)
### Scope and bookkeeping
@@ -226,6 +226,7 @@ uploads and secret-file reads. It does not execute anything.
| `jenkins_api_probe` | `/api/json` and `/whoAmI` without auth; job list as evidence |
| `nexus_probe` | `/service/rest/v1/repositories` without auth; list as evidence |
| `gitea_api_probe` | `/api/v1/admin/users` without auth; admin list as evidence |
| `harbor_probe` | `/api/v2.0/projects` without auth; 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 |
@@ -503,6 +504,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
| `passwd_audit` | duplicate UID 0, empty shadow hash, system login shells |
| `authorized_keys_audit` | writable keys/dirs, `command=` download pipes |
| `ld_preload_audit` | non-empty preload list, writable library |
| `gitconfig_audit` | gitconfig: sslVerify off, HTTP rewrite, store helper |
| `npmrc_audit` | npmrc: strict-ssl off, HTTP registry, cleartext token |
| `pip_conf_audit` | pip.conf: HTTP index, trusted-host override |
### ESP32
@@ -825,6 +829,8 @@ The full threat model, trust boundaries and a hardening checklist are in
| Nexus API | two unauthenticated GETs, repository list as evidence |
| passwd/authorized_keys/ld_preload | config reads only; optional root prefix |
| Gitea API | two unauthenticated GETs, admin list as evidence |
| git/npm/pip configs | config reads only; optional root prefix |
| Harbor API | two unauthenticated GETs, project list as evidence |
| USB audit | 200 devices, sysfs reads only |
---
@@ -836,7 +842,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
```sh
make # apex-twin
make test # version check + gate audit + 1266 end-to-end checks
make test # version check + gate audit + 1278 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
@@ -968,7 +974,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
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
gitea_api_probe, harbor_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,
@@ -1011,7 +1017,7 @@ examples/ scope.json
## Status
1.67.0. Built and run: 306 tools, 1266 checks, 340 fuzz cases and 84.5% line
1.68.0. Built and run: 310 tools, 1278 checks, 340 fuzz cases and 84.6% line
coverage. The loop closes: a probe captures the exchange as a pair, a finding
points at it, `finding_update` gives it a state, an asset records the host it
came from, `cors_check`/`cookie_audit`/`http_options` turn a web answer into a
+3 -1
View File
@@ -9,7 +9,7 @@ problem.
The supported line is the one printed by `apex-twin --version` for the tree you
built; this document ships with that same tree. At the time of writing the line
is **1.67.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
is **1.68.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.
- **git/npm/pip config audits read local files.** The Harbor probe sends two
unauthenticated GETs and saves the project list.
- **passwd/authorized_keys/ld.so.preload audits read local files.** The
Gitea probe sends two unauthenticated GETs and saves the admin list.
- **Bluetooth/NetworkManager/D-Bus audits read local files.** The Nexus
+4 -3
View File
@@ -1,5 +1,5 @@
.\" apex-twin.1 - manual page for APEX TWIN
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.67.0" "User Commands"
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.68.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),
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),
defensive
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
@@ -81,7 +81,8 @@ 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, bluetooth_audit, networkmanager_audit, dbus_audit, passwd_audit,
authorized_keys_audit, ld_preload_audit)
authorized_keys_audit, ld_preload_audit, gitconfig_audit, npmrc_audit,
pip_conf_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.67.0"
#define APEX_VERSION "1.68.0"
#define APEX_MAX_OUT (1u << 20)
#define APEX_PATH_MAX 512
#define APEX_PATH_FULL 1024
+319
View File
@@ -20436,6 +20436,306 @@ static void t_ld_preload_audit(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&findings);
}
/* ------------------------------------------------------------- gitconfig_audit */
static void t_gitconfig_audit(mcp_conn *c, const mcp_json *args, void *user)
{
const char *root = mcp_arg_string(args, "root");
char path[1024];
static char text[131072];
struct stat st;
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int no_verify = 0;
int http_rewrite = 0;
int store_helper = 0;
int url_http = 0;
char section[64];
char *copy;
char *save = NULL;
char *line;
(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/gitconfig", root);
if (read_text(path, text, sizeof(text)) <= 0) {
mcp_reply_error(c, "cannot read /etc/gitconfig");
return;
}
section[0] = '\0';
mcp_buf_init(&findings);
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"/etc/gitconfig is writable by anyone");
count++;
}
copy = strdup(text);
if (copy == NULL) {
mcp_buf_free(&findings);
mcp_reply_error(c, "out of memory");
return;
}
line = strtok_r(copy, "\n", &save);
while (line != NULL) {
char *s = line;
while (*s == ' ' || *s == '\t')
s++;
if (*s == '[') {
char *close = strchr(s, ']');
if (close != NULL) {
size_t cl = (size_t)(close - s - 1);
if (cl >= sizeof(section))
cl = sizeof(section) - 1;
memcpy(section, s + 1, cl);
section[cl] = '\0';
{
char *sp = strchr(section, ' ');
if (sp != NULL)
*sp = '\0';
}
url_http = strncasecmp(section, "url", 3) == 0 &&
strstr(s, "http://") != NULL;
}
} else if (*s != '#' && *s != ';' && *s != '\0') {
if (strstr(s, "insteadOf") != NULL && url_http)
http_rewrite = 1;
if (strncasecmp(section, "credential", 10) == 0 &&
strncasecmp(s, "helper", 6) == 0 &&
strstr(s, "store") != NULL)
store_helper = 1;
if (strncasecmp(section, "http", 4) == 0 &&
strncasecmp(s, "sslVerify", 9) == 0 &&
strcasestr(s, "false") != NULL)
no_verify = 1;
}
line = strtok_r(NULL, "\n", &save);
}
free(copy);
if (no_verify) {
add_finding(&findings, &first, "no-verify", "high",
"git disables TLS verification");
count++;
}
if (http_rewrite) {
add_finding(&findings, &first, "plain-http-rewrite", "medium",
"a URL rewrite downgrades to plain HTTP");
count++;
}
if (store_helper) {
add_finding(&findings, &first, "credential-store", "medium",
"git stores credentials in plain files");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"ssl_verify\":%s,\"http_rewrite\":%s,"
"\"credential_store\":%s,\"findings_count\":%d,"
"\"findings\":[",
no_verify ? "false" : "true",
http_rewrite ? "true" : "false",
store_helper ? "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);
}
/* ---------------------------------------------------------------- npmrc_audit */
static void npmrc_scan_file(mcp_buf *findings, int *first, int *count,
const char *path, int *files, int *no_ssl,
int *plain_http, int *token)
{
static char text[65536];
struct stat st;
char value[512];
if (read_text(path, text, sizeof(text)) < 0)
return;
(*files)++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(findings, first, "world-writable", "high",
"%s is writable by anyone", path);
(*count)++;
}
if (conf_value(text, "strict-ssl", value, sizeof(value)) &&
strcasecmp(value, "false") == 0)
*no_ssl = 1;
if (conf_value(text, "registry", value, sizeof(value)) &&
strncmp(value, "http://", 7) == 0)
*plain_http = 1;
if (strstr(text, "_authToken=") != NULL &&
strstr(text, "_authToken=\n") == NULL)
*token = 1;
}
static void t_npmrc_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *files[] = { "/etc/npmrc", "/usr/etc/npmrc", 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 no_ssl = 0;
int plain_http = 0;
int token = 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]);
npmrc_scan_file(&findings, &first, &count, path, &files_read,
&no_ssl, &plain_http, &token);
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read an npmrc");
return;
}
if (no_ssl) {
add_finding(&findings, &first, "no-verify", "high",
"npm disables TLS verification");
count++;
}
if (plain_http) {
add_finding(&findings, &first, "plain-http", "medium",
"the npm registry uses plain HTTP");
count++;
}
if (token) {
add_finding(&findings, &first, "cleartext-token", "medium",
"an npm auth token is stored in the file");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"strict_ssl\":%s,"
"\"plain_http\":%s,\"token_in_file\":%s,"
"\"findings_count\":%d,\"findings\":[",
files_read, no_ssl ? "false" : "true",
plain_http ? "true" : "false",
token ? "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);
}
/* ------------------------------------------------------------- pip_conf_audit */
static void pip_scan_file(mcp_buf *findings, int *first, int *count,
const char *path, int *files, int *plain_http,
int *trusted)
{
static char text[65536];
struct stat st;
char value[512];
if (read_text(path, text, sizeof(text)) < 0)
return;
(*files)++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(findings, first, "world-writable", "high",
"%s is writable by anyone", path);
(*count)++;
}
if (ini_value(text, "global", "index-url", value, sizeof(value)) &&
strncmp(value, "http://", 7) == 0)
*plain_http = 1;
if (ini_value(text, "global", "extra-index-url", value,
sizeof(value)) &&
strstr(value, "http://") != NULL)
*plain_http = 1;
if (strstr(text, "trusted-host") != NULL)
*trusted = 1;
}
static void t_pip_conf_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *files[] = { "/etc/pip.conf",
"/etc/xdg/pip/pip.conf", 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 plain_http = 0;
int trusted = 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]);
pip_scan_file(&findings, &first, &count, path, &files_read,
&plain_http, &trusted);
}
if (files_read == 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read a pip configuration");
return;
}
if (plain_http) {
add_finding(&findings, &first, "plain-http", "medium",
"a pip index uses plain HTTP");
count++;
}
if (trusted) {
add_finding(&findings, &first, "trusted-host", "high",
"pip trusts a host without certificate checks");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"plain_http\":%s,"
"\"trusted_host\":%s,\"findings_count\":%d,"
"\"findings\":[",
files_read, plain_http ? "true" : "false",
trusted ? "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, "
@@ -21613,6 +21913,25 @@ const mcp_tool TOOLS_BLUE[] = {
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_ld_preload_audit },
{ "gitconfig_audit",
"Parse /etc/gitconfig (root prefix): http.sslVerify=false, a URL "
"rewrite to http://, credential.helper=store and a world-writable "
"file. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_gitconfig_audit },
{ "npmrc_audit",
"Parse npmrc files (root prefix): strict-ssl=false, an HTTP registry, "
"a cleartext auth token and world-writable files. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_npmrc_audit },
{ "pip_conf_audit",
"Parse pip.conf files (root prefix): an HTTP index, a trusted-host "
"override and world-writable files. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_pip_conf_audit },
};
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
+94
View File
@@ -8118,6 +8118,90 @@ static void t_gitea_api_probe(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&b);
}
/* --------------------------------------------------------------- harbor_probe */
static void t_harbor_probe(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *paths[] = { "/api/v2.0/health",
"/api/v2.0/projects", NULL };
const char *target = mcp_arg_string(args, "target");
int port = mcp_arg_int(args, "port", 80);
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, "harbor_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) {
projects_open = 1;
if (evidence == NULL)
evidence = apex_evidence_save("harbor-projects",
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,"
"\"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("harbor_probe", target, port, !projects_open,
projects_open
? "the Harbor project API answers without authentication"
: "the Harbor project 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: "
@@ -8810,6 +8894,16 @@ const mcp_tool TOOLS_RED[] = {
"\"tls\":{\"type\":\"boolean\"}},"
"\"required\":[\"target\"]}",
t_gitea_api_probe },
{ "harbor_probe",
"Query Harbor without credentials: /api/v2.0/health and "
"/api/v2.0/projects. A 2xx project 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 80\"},"
"\"tls\":{\"type\":\"boolean\"}},"
"\"required\":[\"target\"]}",
t_harbor_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 = 306
EXPECTED_TOOLS = 310
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.
+173 -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("306 tools registered", len(tools) == 306, len(tools))
check("310 tools registered", len(tools) == 310, 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"]) == 306)
check("http tools/list", len(listing["result"]["tools"]) == 310)
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
@@ -13936,6 +13936,176 @@ shutil.rmtree(lp_root, ignore_errors=True)
shutil.rmtree(lp_good_root, ignore_errors=True)
shutil.rmtree(cfg39_home, ignore_errors=True)
print("\n== git, npm, pip configs and Harbor ==\n")
gc_root = tempfile.mkdtemp(prefix="apex-gc-")
os.makedirs(os.path.join(gc_root, "etc"))
gc_bad = os.path.join(gc_root, "etc", "gitconfig")
with open(gc_bad, "w") as f:
f.write("[http]\n sslVerify = false\n")
f.write('[url "http://mirror.example.test/"]\n')
f.write(" insteadOf = https://github.com/\n")
f.write("[credential]\n helper = store\n")
os.chmod(gc_bad, 0o666)
gc_good_root = tempfile.mkdtemp(prefix="apex-gcg-")
os.makedirs(os.path.join(gc_good_root, "etc"))
with open(os.path.join(gc_good_root, "etc", "gitconfig"), "w") as f:
f.write("[http]\n sslVerify = true\n")
f.write("[credential]\n helper = cache\n")
np_root = tempfile.mkdtemp(prefix="apex-np-")
os.makedirs(os.path.join(np_root, "etc"))
np_bad = os.path.join(np_root, "etc", "npmrc")
with open(np_bad, "w") as f:
f.write("strict-ssl=false\n")
f.write("registry=http://registry.example.test/\n")
f.write("//registry.example.test/:_authToken=secret\n")
os.chmod(np_bad, 0o666)
np_good_root = tempfile.mkdtemp(prefix="apex-npg-")
os.makedirs(os.path.join(np_good_root, "etc"))
with open(os.path.join(np_good_root, "etc", "npmrc"), "w") as f:
f.write("strict-ssl=true\n")
f.write("registry=https://registry.example.test/\n")
pp_root = tempfile.mkdtemp(prefix="apex-pp-")
os.makedirs(os.path.join(pp_root, "etc"))
pp_bad = os.path.join(pp_root, "etc", "pip.conf")
with open(pp_bad, "w") as f:
f.write("[global]\n")
f.write("index-url = http://pypi.example.test/simple\n")
f.write("trusted-host = pypi.example.test\n")
os.chmod(pp_bad, 0o666)
pp_good_root = tempfile.mkdtemp(prefix="apex-ppg-")
os.makedirs(os.path.join(pp_good_root, "etc"))
with open(os.path.join(pp_good_root, "etc", "pip.conf"), "w") as f:
f.write("[global]\n")
f.write("index-url = https://pypi.example.test/simple\n")
class _HarborHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
path = urllib.parse.urlsplit(self.path).path
if path == "/api/v2.0/health":
body = b'{"status":"healthy"}'
self.send_response(200)
elif path == "/api/v2.0/projects":
body = b'[{"name":"library","project_id":1}]'
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 _HarborAuthHandler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
path = urllib.parse.urlsplit(self.path).path
if path == "/api/v2.0/health":
body = b'{"status":"healthy"}'
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
hb_srv = http.server.HTTPServer(("127.0.0.1", 0), _HarborHandler)
hb_port = hb_srv.server_address[1]
threading.Thread(target=hb_srv.serve_forever, daemon=True).start()
hb_auth_srv = http.server.HTTPServer(("127.0.0.1", 0),
_HarborAuthHandler)
hb_auth_port = hb_auth_srv.server_address[1]
threading.Thread(target=hb_auth_srv.serve_forever, daemon=True).start()
cfg40_home = tempfile.mkdtemp(prefix="apex-cfg40-home-")
write_scope(cfg40_home, {"label": "cfg40", "expires": "2099-12-31T23:59:59Z",
"allow_private": True, "allow_ip": ["127.0.0.1"],
"allow_port": [str(hb_port), str(hb_auth_port)]})
res, _ = run([
call(1, "gitconfig_audit", root=gc_root),
call(2, "gitconfig_audit", root=gc_good_root),
call(3, "npmrc_audit", root=np_root),
call(4, "npmrc_audit", root=np_good_root),
call(5, "pip_conf_audit", root=pp_root),
call(6, "pip_conf_audit", root=pp_good_root),
call(7, "harbor_probe", target="127.0.0.1", port=hb_port, tls=False),
call(8, "harbor_probe", target="127.0.0.1", port=hb_auth_port,
tls=False),
call(9, "harbor_probe", target="198.51.100.9", port=80),
call(10, "gitconfig_audit", root="/nonexistent-gc"),
call(11, "npmrc_audit", root="/nonexistent-np"),
call(12, "pip_conf_audit", root="/nonexistent-pp"),
], home=cfg40_home)
by_id = {r.get("id"): r for r in res}
gc = json.loads(text(by_id[1]))
gc_kinds = {f["id"] for f in gc["findings"]}
check("gitconfig_audit flags no verify, HTTP rewrite and store",
{"world-writable", "no-verify", "plain-http-rewrite",
"credential-store"} <= gc_kinds and gc["ssl_verify"] is False and
gc["credential_store"] is True, gc)
gc_good = json.loads(text(by_id[2]))
check("gitconfig_audit accepts verification and a cache helper",
gc_good["findings_count"] == 0 and gc_good["ssl_verify"] is True and
gc_good["credential_store"] is False, gc_good)
np = json.loads(text(by_id[3]))
np_kinds = {f["id"] for f in np["findings"]}
check("npmrc_audit flags no SSL, HTTP registry and a token",
{"world-writable", "no-verify", "plain-http",
"cleartext-token"} <= np_kinds and np["strict_ssl"] is False and
np["token_in_file"] is True, np)
np_good = json.loads(text(by_id[4]))
check("npmrc_audit accepts strict SSL over HTTPS",
np_good["findings_count"] == 0 and np_good["strict_ssl"] is True and
np_good["token_in_file"] is False, np_good)
pp = json.loads(text(by_id[5]))
pp_kinds = {f["id"] for f in pp["findings"]}
check("pip_conf_audit flags an HTTP index and trusted-host",
{"world-writable", "plain-http", "trusted-host"} <= pp_kinds and
pp["plain_http"] is True and pp["trusted_host"] is True, pp)
pp_good = json.loads(text(by_id[6]))
check("pip_conf_audit accepts an HTTPS index",
pp_good["findings_count"] == 0 and pp_good["plain_http"] is False and
pp_good["trusted_host"] is False, pp_good)
hb = json.loads(text(by_id[7]))
check("harbor_probe finds the open project API",
hb["projects_open"] is True and hb["evidence"] and
os.path.isfile(hb["evidence"]), hb)
hb_auth = json.loads(text(by_id[8]))
check("harbor_probe reports a protected API",
hb_auth["projects_open"] is False and
all(e["status"] == 401 for e in hb_auth["endpoints"]
if "projects" in e["path"]), hb_auth)
check("harbor_probe refuses an out-of-scope target", err(by_id[9]),
text(by_id[9]))
check("gitconfig_audit reports a missing config", err(by_id[10]),
text(by_id[10]))
check("npmrc_audit reports a missing config", err(by_id[11]),
text(by_id[11]))
check("pip_conf_audit reports a missing config", err(by_id[12]),
text(by_id[12]))
hb_srv.shutdown()
hb_srv.server_close()
hb_auth_srv.shutdown()
hb_auth_srv.server_close()
shutil.rmtree(gc_root, ignore_errors=True)
shutil.rmtree(gc_good_root, ignore_errors=True)
shutil.rmtree(np_root, ignore_errors=True)
shutil.rmtree(np_good_root, ignore_errors=True)
shutil.rmtree(pp_root, ignore_errors=True)
shutil.rmtree(pp_good_root, ignore_errors=True)
shutil.rmtree(cfg40_home, ignore_errors=True)
print("\n== esp32 tools ==")
@@ -13963,6 +14133,7 @@ print("\n== esp32 tools ==")
esp_home = tempfile.mkdtemp(prefix="apex-esp-")