Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions cmd/scan.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"fmt"

"github.com/cerberauth/harnessx"
Expand Down Expand Up @@ -84,6 +85,8 @@ Use only against systems you own or have explicit written permission to test.`,
}

checks, defs := proxy.AllChecks()
var fetchErr error
recordFetchErr(checks, &fetchErr)

reportxReporter := harnessreport.New(ctx, harnessreport.Config{
ToolName: name,
Expand Down Expand Up @@ -120,7 +123,7 @@ Use only against systems you own or have explicit written permission to test.`,
// couldn't be reached at all — every dependent check then
// skips rather than erroring, which would otherwise look
// exactly like "reached the target, found nothing".
if fetchErr := sharedFetchErr(summary); fetchErr != nil {
if fetchErr != nil {
return &RuntimeError{err: fmt.Errorf("connecting to target: %w", fetchErr)}
}

Expand All @@ -139,21 +142,25 @@ Use only against systems you own or have explicit written permission to test.`,
return scanCmd
}

// sharedFetchErr returns probe.http_fetch's underlying error, if any, by
// scanning summary.Results — the shared fetch stores its error on Result.Data
// rather than Result.Err (so dependent checks can Skip cleanly instead of
// erroring), which would otherwise make total unreachability
// indistinguishable from "reached the target, found nothing".
func sharedFetchErr(summary harnessx.ScanSummary) error {
for _, r := range summary.Results {
if r.CheckID != probebase.HTTPFetchCheckID {
// recordFetchErr makes the internal shared fetch report its underlying error
// to dst: it stores it on Result.Data rather than Result.Err (so dependent
// checks can Skip cleanly instead of erroring), which would otherwise make
// total unreachability indistinguishable from "reached the target, found
// nothing".
func recordFetchErr(checks []harnessx.Check, dst *error) {
for i, c := range checks {
if c.ID != probebase.HTTPFetchCheckID {
continue
}
if fetched, ok := harnessx.DataAs[*probebase.FetchResult](r); ok && fetched.Err != nil {
return fetched.Err
run := c.Run
checks[i].Run = func(ctx context.Context, target harnessx.Target, store harnessx.ResultStore) (harnessx.Result, error) {
r, err := run(ctx, target, store)
if fetched, ok := harnessx.DataAs[*probebase.FetchResult](r); ok {
*dst = fetched.Err
}
return r, err
}
}
return nil
}

// RuntimeError marks an error as a runtime/connection failure (exit code 2)
Expand Down
12 changes: 6 additions & 6 deletions docs/checks/accesscontrol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ description: Access control bypassed via path normalization (case variation, dup

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `accesscontrol.path_bypass` | Access Control Bypassed via Path Normalization | 8.7 | [CWE-284](https://cwe.mitre.org/data/definitions/284.html) | API5:2023 |
| `accesscontrol.method_bypass` | Access Control Bypassed via HTTP Method | 8.7 | [CWE-650](https://cwe.mitre.org/data/definitions/650.html) | API5:2023 |
| `accesscontrol.nginx_alias_traversal` | Nginx Off-by-Slash Alias Traversal | 8.7 | [CWE-22](https://cwe.mitre.org/data/definitions/22.html) | API8:2023 |
| `proxy.accesscontrol.path_bypass` | Access Control Bypassed via Path Normalization | 8.7 | [CWE-284](https://cwe.mitre.org/data/definitions/284.html) | API5:2023 |
| `proxy.accesscontrol.method_bypass` | Access Control Bypassed via HTTP Method | 8.7 | [CWE-650](https://cwe.mitre.org/data/definitions/650.html) | API5:2023 |
| `proxy.accesscontrol.nginx_alias_traversal` | Nginx Off-by-Slash Alias Traversal | 8.7 | [CWE-22](https://cwe.mitre.org/data/definitions/22.html) | API8:2023 |

## `accesscontrol.path_bypass`
## `proxy.accesscontrol.path_bypass`

Probes a fixed list of common protected paths (`/admin`, `/internal`, `/private`). For any that deny a plain `GET`, it retries case/encoding/traversal variants of the same path — uppercase, a duplicate leading slash, a trailing slash or dot segment, a partially percent-encoded traversal back to itself, a double-encoded first byte, a trailing null byte, and a matrix (`;`) parameter — that a backend commonly normalizes away before routing. A variant that succeeds where the plain path was denied means the access control is matching on the raw, unnormalized path instead of the path the backend will actually resolve.

**Remediate:** decode and canonicalize the path (case-fold, resolve `.`/`..` segments, collapse duplicate slashes, strip matrix parameters) using the same logic the backend router uses, before making the access-control decision — ideally by enforcing the check at the same layer that does the routing, rather than in front of it.

## `accesscontrol.method_bypass`
## `proxy.accesscontrol.method_bypass`

Probes the same fixed list of common protected paths and, for any that deny a `GET`, retries the identical path with `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`. A verb that succeeds where `GET` was denied means the access control only gates the verb it expects instead of every verb the backend routes to that handler.

**Remediate:** apply the access-control check independent of the HTTP method, or deny by default and explicitly allow only the methods a path is meant to support.

## `accesscontrol.nginx_alias_traversal`
## `proxy.accesscontrol.nginx_alias_traversal`

Skipped for targets that don't fingerprint as nginx via the `Server` header. For a fixed list of common alias-style location prefixes (`/files`, `/static`, `/assets`, `/media`, `/public`, `/uploads`, `/download`), fetches `<prefix>/index.html` and, if that returns `200`, also fetches `<prefix>index.html` — the same filename appended directly onto the prefix with no `/` separator. Identical content on both means the `location` matching that prefix has no trailing slash, so nginx strips only the literal prefix and appends the remainder of the request path verbatim to the `alias` directory — from there, an attacker can substitute a `../` traversal for the filename to escape the aliased directory entirely (the classic [Gixy `alias_traversal`](https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md) finding).

Expand Down
18 changes: 9 additions & 9 deletions docs/checks/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ description: Authenticated-response caching, cache-key/Vary consistency, unkeyed

import { Aside } from '@/components/docs';

These checks build on the same RFC 9111 (HTTP Caching) semantics as [`cache-detective`](https://github.com/cerberauth/cache-detective) — `caching.authenticated_caching` and `caching.cache_deception` reuse its `cache/checks/cacheability` cacheability determination directly, and `caching.vary_consistency` reuses its `cache/cdn` cache-status detection.
These checks are [`cache-detective`](https://github.com/cerberauth/cache-detective)'s own checks, embedded with `harnessx/embed` and run against the scanned URL: `proxy.caching.authenticated_caching` runs `cache.authenticated_cacheable`, `proxy.caching.vary_consistency` runs `cache.vary_key`, `proxy.caching.cache_poisoning` runs `cache.unkeyed_header_injection` and `proxy.caching.cache_deception` runs `cache.cache_deception`.

<Aside type="tip">
Results here are inherently probabilistic (per-request/per-instance variance in front of a real CDN) — treat a lack of findings as "nothing observed in this pass", not a definitive pass.
</Aside>

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `caching.authenticated_caching` | Authenticated Response Marked Cacheable | 8.7 | [CWE-524](https://cwe.mitre.org/data/definitions/524.html) | API1:2023 |
| `caching.vary_consistency` | Undeclared Cache-Key Input | 5.3 | [CWE-444](https://cwe.mitre.org/data/definitions/444.html) | API8:2023 |
| `caching.cache_poisoning` | Cache Poisoning via Unkeyed Header | 9.3 | [CWE-444](https://cwe.mitre.org/data/definitions/444.html) | API8:2023 |
| `caching.cache_deception` | Web Cache Deception via Path Confusion | 8.1 | [CWE-524](https://cwe.mitre.org/data/definitions/524.html) | API1:2023 |
| `proxy.caching.authenticated_caching` | Authenticated Response Marked Cacheable | 8.7 | [CWE-524](https://cwe.mitre.org/data/definitions/524.html) | API1:2023 |
| `proxy.caching.vary_consistency` | Undeclared Cache-Key Input | 5.3 | [CWE-444](https://cwe.mitre.org/data/definitions/444.html) | API8:2023 |
| `proxy.caching.cache_poisoning` | Cache Poisoning via Unkeyed Header | 9.3 | [CWE-444](https://cwe.mitre.org/data/definitions/444.html) | API8:2023 |
| `proxy.caching.cache_deception` | Web Cache Deception via Path Confusion | 8.1 | [CWE-524](https://cwe.mitre.org/data/definitions/524.html) | API1:2023 |

## `caching.authenticated_caching`
## `proxy.caching.authenticated_caching`

Sends a request carrying credentials (a bearer token and a cookie) and checks whether the response is cacheable per RFC 9111 §3.5 without one of that section's opt-in directives (`must-revalidate`, `public`, `s-maxage`) — a shared cache/CDN in front of the origin isn't supposed to store a response to a request carrying `Authorization` otherwise. Severity is compounded in the finding description when the response body or `Set-Cookie` header carries PII, tokens, or session data (detected the same way as `cache-detective`'s equivalent check).

**Remediate:** send `Cache-Control: private, no-store` (or an explicit opt-in if the response is genuinely safe to share) on every authenticated response.

## `caching.vary_consistency`
## `proxy.caching.vary_consistency`

Probes whether `Accept-Encoding`, `Accept-Language`, and a custom header actually change the response, and compares that against the declared `Vary` header. An input that changes the response but isn't declared in `Vary` means a cache keyed only on the declared dimensions can serve one variant to a request that should have gotten another — a cache-poisoning surface whenever that input is attacker-controlled.

**Remediate:** declare every request header the response actually varies on in `Vary`, or stop varying on it.

## `caching.cache_poisoning`
## `proxy.caching.cache_poisoning`

<Aside type="caution">
Requires `--aggressive`: a positive result has planted content in a shared cache that other users may be served.
Expand All @@ -40,7 +40,7 @@ Injects a marker via a header commonly left out of the cache key (`X-Forwarded-H

**Remediate:** either strip these headers before they can influence the response, or include them in the cache key.

## `caching.cache_deception`
## `proxy.caching.cache_deception`

<Aside type="caution">
Requires `--aggressive`: a positive result has planted content in a shared cache under an attacker-chosen path.
Expand Down
16 changes: 8 additions & 8 deletions docs/checks/disclosure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ description: Verbose error pages, exposed proxy admin/status interfaces, directo

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `disclosure.verbose_errors` | Verbose Error Page Leaks Internal Details | 3.1 | [CWE-209](https://cwe.mitre.org/data/definitions/209.html) | API9:2023 |
| `disclosure.exposed_management` | Exposed Proxy Management or Admin Interface | 8.7 | [CWE-284](https://cwe.mitre.org/data/definitions/284.html) | API9:2023 |
| `disclosure.directory_listing` | Directory Listing Enabled | 4.3 | [CWE-548](https://cwe.mitre.org/data/definitions/548.html) | API9:2023 |
| `disclosure.config_exposure` | Config or Secrets File Exposed | 8.2 | [CWE-538](https://cwe.mitre.org/data/definitions/538.html) | API9:2023 |
| `proxy.disclosure.verbose_errors` | Verbose Error Page Leaks Internal Details | 3.1 | [CWE-209](https://cwe.mitre.org/data/definitions/209.html) | API9:2023 |
| `proxy.disclosure.exposed_management` | Exposed Proxy Management or Admin Interface | 8.7 | [CWE-284](https://cwe.mitre.org/data/definitions/284.html) | API9:2023 |
| `proxy.disclosure.directory_listing` | Directory Listing Enabled | 4.3 | [CWE-548](https://cwe.mitre.org/data/definitions/548.html) | API9:2023 |
| `proxy.disclosure.config_exposure` | Config or Secrets File Exposed | 8.2 | [CWE-538](https://cwe.mitre.org/data/definitions/538.html) | API9:2023 |

## `disclosure.verbose_errors`
## `proxy.disclosure.verbose_errors`

Triggers error responses via a nonexistent path and a request with a malformed `Range` header, and inspects the bodies for stack traces, backend file paths, or internal hostnames.

**Remediate:** configure generic error pages for the proxy and every backend; never return stack traces or internal paths to clients.

## `disclosure.exposed_management`
## `proxy.disclosure.exposed_management`

Probes a fixed list of known reverse-proxy/gateway management paths — Traefik's `/api/rawdata` and `/dashboard/`, HAProxy's `/haproxy?stats`, Envoy's `/clusters`, `/config_dump`, and `/server_info`, nginx's `/nginx_status`, Apache's `/server-status` — and checks whether each responds successfully without authentication.

**Remediate:** bind admin/status interfaces to a separate internal-only listener, or require authentication in front of them; never expose them on the public listener.

## `disclosure.directory_listing`
## `proxy.disclosure.directory_listing`

Probes common static-asset paths (`/`, `/static/`, `/assets/`, `/files/`, `/public/`, `/uploads/`) for autoindex-style directory listings.

**Remediate:** disable directory autoindexing (`autoindex off;` on nginx, equivalent on other servers) for any static-file location.

## `disclosure.config_exposure`
## `proxy.disclosure.config_exposure`

Probes a fixed list of config-adjacent paths (`.env`, `nginx.conf`, `docker-compose.yml`, `.git/config`, `web.config`) for content that looks like configuration or secrets rather than the backend's ordinary not-found response.

Expand Down
32 changes: 16 additions & 16 deletions docs/checks/headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,58 @@ description: CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Perm

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `headers.csp` | Content-Security-Policy Header Missing | 2.6 | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `headers.frame_options` | Clickjacking Protection Missing | 2.6 | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `headers.content_type_options` | X-Content-Type-Options Header Missing | 2.6 | [CWE-16](https://cwe.mitre.org/data/definitions/16.html) | API8:2023 |
| `headers.referrer_policy` | Referrer-Policy Header Missing | 0 (informational) | [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | API8:2023 |
| `headers.permissions_policy` | Permissions-Policy Header Missing | 0 (informational) | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `headers.server_banner` | Server/X-Powered-By Banner Discloses Software or Version | 3.1 | [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | API7:2023 |
| `headers.cookie_flags` | Cookie Missing Secure, HttpOnly, or SameSite | 4.6 | [CWE-1004](https://cwe.mitre.org/data/definitions/1004.html) | API8:2023 |
| `headers.cors` | CORS Misconfiguration | 6.7 | [CWE-942](https://cwe.mitre.org/data/definitions/942.html) | API8:2023 |
| `proxy.headers.csp` | Content-Security-Policy Header Missing | 2.6 | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `proxy.headers.frame_options` | Clickjacking Protection Missing | 2.6 | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `proxy.headers.content_type_options` | X-Content-Type-Options Header Missing | 2.6 | [CWE-16](https://cwe.mitre.org/data/definitions/16.html) | API8:2023 |
| `proxy.headers.referrer_policy` | Referrer-Policy Header Missing | 0 (informational) | [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | API8:2023 |
| `proxy.headers.permissions_policy` | Permissions-Policy Header Missing | 0 (informational) | [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | API8:2023 |
| `proxy.headers.server_banner` | Server/X-Powered-By Banner Discloses Software or Version | 3.1 | [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | API7:2023 |
| `proxy.headers.cookie_flags` | Cookie Missing Secure, HttpOnly, or SameSite | 4.6 | [CWE-1004](https://cwe.mitre.org/data/definitions/1004.html) | API8:2023 |
| `proxy.headers.cors` | CORS Misconfiguration | 6.7 | [CWE-942](https://cwe.mitre.org/data/definitions/942.html) | API8:2023 |

## `headers.csp`
## `proxy.headers.csp`

Tests for the presence of a `Content-Security-Policy` header.

**Remediate:** add a `Content-Security-Policy` restricting script/style/resource sources to what the application actually needs.

## `headers.frame_options`
## `proxy.headers.frame_options`

Tests for `X-Frame-Options` **or** a CSP `frame-ancestors` directive — either is sufficient.

**Remediate:** set `X-Frame-Options: DENY` (or `SAMEORIGIN`), or `Content-Security-Policy: frame-ancestors 'none'` (or a specific origin).

## `headers.content_type_options`
## `proxy.headers.content_type_options`

Tests for `X-Content-Type-Options: nosniff`.

**Remediate:** add `X-Content-Type-Options: nosniff` to every response.

## `headers.referrer_policy`
## `proxy.headers.referrer_policy`

Tests for the presence of a `Referrer-Policy` header.

**Remediate:** add `Referrer-Policy: strict-origin-when-cross-origin` (or stricter, e.g. `no-referrer`, depending on what the application needs to share).

## `headers.permissions_policy`
## `proxy.headers.permissions_policy`

Tests for the presence of a `Permissions-Policy` header.

**Remediate:** add a `Permissions-Policy` disabling powerful browser features the application doesn't use (camera, microphone, geolocation, ...).

## `headers.server_banner`
## `proxy.headers.server_banner`

Checks the `Server` and `X-Powered-By` response headers for software (and, worse, version) disclosure.

**Remediate:** strip or generalize the `Server` header at the proxy, and remove `X-Powered-By` entirely.

## `headers.cookie_flags`
## `proxy.headers.cookie_flags`

Checks every `Set-Cookie` header in the response for the `Secure`, `HttpOnly`, and `SameSite` attributes.

**Remediate:** set `Secure`, `HttpOnly` (unless the cookie must be JS-readable), and an explicit `SameSite` (`Strict` or `Lax`) on every cookie.

## `headers.cors`
## `proxy.headers.cors`

Sends cross-origin requests to a fixed list of common API/account paths with a spoofed `Origin` (an attacker-controlled marker origin, and the literal `null` origin) plus an `OPTIONS` preflight, and inspects the `Access-Control-*` response headers directly rather than via reflection. Flags: an arbitrary `Origin` reflected back in `Access-Control-Allow-Origin` combined with `Access-Control-Allow-Credentials: true`; a wildcard `Access-Control-Allow-Origin: *` combined with `Access-Control-Allow-Credentials: true`; the literal `null` origin accepted; a preflight that grants credentialed access to an arbitrary origin; and an `Access-Control-Max-Age` beyond what any major browser actually caches a preflight for (2h).

Expand Down
Loading
Loading