Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/checks/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Card, CardGrid, LinkCard } from '@/components/docs';
<LinkCard title="Proxy-Level Template Injection" description="Request headers reflected through a server-side template engine (e.g. Caddy templates). Aggressive suite." href="./templateinjection/" />
<LinkCard title="Open Proxy / SSRF" description="Absolute-URI forwarding to arbitrary external and internal hosts, including cloud metadata. Aggressive suite." href="./ssrf/" />
<LinkCard title="Request Smuggling / Desync" description="Whether the proxy rejects ambiguous request framing (CL.TE / TE.CL / TE.TE). Aggressive suite." href="./smuggling/" />
<LinkCard title="Rate Limiting & DoS Resilience" description="Per-client throttling, spoofed client-IP bypass, oversized request headers. Aggressive suite." href="./ratelimit/" />
</CardGrid>

## Severity
Expand Down
61 changes: 61 additions & 0 deletions docs/checks/ratelimit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Rate Limiting & DoS Resilience
description: Whether the proxy throttles per client, keys its throttle on a spoofable header, and caps request header size.
---

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

A proxy should absorb abusive load before it reaches the backend: throttle
per client, key that throttle on the real connection peer (not a
client-supplied header), and cap request sizes. These checks measure those
properties with small, bounded probes.

<Aside type="caution">
These checks are part of the v0.4 aggressive suite and only run with
`--aggressive`. The bursts are deliberately small (≈20–30 requests) — they
measure throttling behaviour, not a flood.
</Aside>

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `ratelimit.missing_throttling` | No Per-Client Request Throttling at the Proxy | 5.3 | [CWE-770](https://cwe.mitre.org/data/definitions/770.html) | API4:2023 |
| `ratelimit.spoofed_ip_bypass` | Rate Limit Bypassed via Spoofed Client-IP Header | 6.9 | [CWE-770](https://cwe.mitre.org/data/definitions/770.html) | API4:2023 |
| `ratelimit.oversized_header` | Oversized Request Headers Accepted Without a Limit | 5.3 | [CWE-770](https://cwe.mitre.org/data/definitions/770.html) | API4:2023 |

## `ratelimit.missing_throttling`

Sends a small burst from one client and reports when none of the requests
is throttled. Informational-to-low: throttling at the backend or an
external layer is not visible to a single-client burst.

**Remediate:** enforce per-client request rate limiting at the proxy
(e.g. nginx `limit_req`, an API gateway plan).

## `ratelimit.spoofed_ip_bypass`

For a proxy that does throttle, drives it into throttling, confirms a plain
request is still throttled, then flips the response back to success by
rotating a spoofed IP in `X-Forwarded-For`, `X-Real-IP`, `True-Client-IP`,
`X-Client-IP`, or `X-Forwarded`. A header that resets the limit is a
confirmed bypass; the check skips when no throttling is observed.

**Remediate:** key rate limiting on the real connection peer, and only
trust a client-IP header when it arrives from a known, trusted upstream
(see the Client-IP & Header Trust Boundary checks).

## `ratelimit.oversized_header`

Sends one request with a single 128 KiB header and flags acceptance rather
than a 431/400/413 rejection — a proxy with no header-size cap lets a client
force large per-request allocations.

**Remediate:** set conservative request-header size limits (nginx
`large_client_header_buffers`, Apache `LimitRequestFieldSize`).

## Not yet covered

Slowloris / slow-body resistance and connection/keepalive limits under load
(checklist items 3 and 5) are genuine denial-of-service tests that can
degrade a live target even when bounded; they are intentionally left to a
dedicated, separately gated capability rather than running under
`--aggressive`.
12 changes: 12 additions & 0 deletions proxy/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import (
xforwardedfor "github.com/cerberauth/proxyaudit/proxy/checks/headertrust/x_forwarded_for"
xforwardedhost "github.com/cerberauth/proxyaudit/proxy/checks/headertrust/x_forwarded_host"
xrealip "github.com/cerberauth/proxyaudit/proxy/checks/headertrust/x_real_ip"
missingthrottling "github.com/cerberauth/proxyaudit/proxy/checks/ratelimit/missing_throttling"
oversizedheader "github.com/cerberauth/proxyaudit/proxy/checks/ratelimit/oversized_header"
spoofedipbypass "github.com/cerberauth/proxyaudit/proxy/checks/ratelimit/spoofed_ip_bypass"
ambiguousframing "github.com/cerberauth/proxyaudit/proxy/checks/smuggling/ambiguous_framing"
internaltargetaccess "github.com/cerberauth/proxyaudit/proxy/checks/ssrf/internal_target_access"
openforwardproxy "github.com/cerberauth/proxyaudit/proxy/checks/ssrf/open_forward_proxy"
Expand Down Expand Up @@ -120,6 +123,11 @@ func AllChecks() ([]harnessx.Check, map[harnessx.CheckID]checkdef.CheckDef) {
internaltargetaccess.Check,
// Request Smuggling / Desync (Agg-tier, --aggressive).
ambiguousframing.Check,

// Rate Limiting & DoS Resilience (Agg-tier, --aggressive).
missingthrottling.Check,
spoofedipbypass.Check,
oversizedheader.Check,
}

defs := map[harnessx.CheckID]checkdef.CheckDef{
Expand Down Expand Up @@ -171,6 +179,10 @@ func AllChecks() ([]harnessx.Check, map[harnessx.CheckID]checkdef.CheckDef) {
internaltargetaccess.Check.ID: internaltargetaccess.Def,

ambiguousframing.Check.ID: ambiguousframing.Def,

missingthrottling.Check.ID: missingthrottling.Def,
spoofedipbypass.Check.ID: spoofedipbypass.Def,
oversizedheader.Check.ID: oversizedheader.Def,
}

return checks, defs
Expand Down
52 changes: 52 additions & 0 deletions proxy/checks/ratelimit/missing_throttling/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Package missingthrottling sends a small, bounded burst of requests and
// reports when none of them is throttled — the proxy enforces no per-client
// request rate limit of its own, so a single client can drive unbounded
// load straight through to the backend.
//
// The finding is informational-to-low: many deployments rate-limit at the
// backend or an external layer instead, which a black-box burst from one
// client cannot see. It flags only the observable fact that the proxy
// itself did not throttle a rapid burst.
//
// Requires --aggressive: it sends a burst of requests, part of the opt-in
// attack-simulation suite.
package missingthrottling

import (
"context"
_ "embed"
"strconv"

"github.com/cerberauth/harnessx"
"github.com/cerberauth/harnessx/checkdef"
"github.com/cerberauth/proxyaudit/proxy/checks/ratelimit/rlprobe"
"github.com/cerberauth/proxyaudit/proxy/probebase"
"github.com/cerberauth/proxyaudit/proxy/scanctx"
)

//go:embed check.yaml
var checkYAML []byte

var Def = checkdef.MustParseCheckDefYAML("missing_throttling", checkYAML)

var Check = checkdef.NewCheck(Def, func(ctx context.Context, target harnessx.Target, _ harnessx.ResultStore) (harnessx.Result, error) {
sctx := scanctx.TargetContext(target)
if !sctx.Aggressive {
return harnessx.Result{Skipped: true, SkipReason: "aggressive-suite check — rerun with --aggressive to send a rate-limit burst"}, nil
}

statuses, err := rlprobe.Burst(ctx, sctx, target.URL, rlprobe.BurstSize)
if err != nil {
return harnessx.Result{Err: err}, nil
}
if rlprobe.AnyThrottled(statuses) {
return harnessx.Result{}, nil
}

return harnessx.Result{Observations: []harnessx.Observation{{
Title: "Proxy enforces no per-client request throttling",
Description: "A burst of " + strconv.Itoa(len(statuses)) + " requests from a single client was served without any being rate-limited (no 429 or 503). The proxy applies no per-client throttling of its own, so one client can drive unbounded request load through to the backend. If rate limiting exists only at the backend or an external layer, it is not visible here and may not protect the backend from pre-auth floods.",
Evidence: strconv.Itoa(len(statuses)) + " consecutive requests, none throttled (last status " + strconv.Itoa(statuses[len(statuses)-1]) + ")",
Metadata: map[string]string{"requests": strconv.Itoa(len(statuses))},
}}}, nil
}, checkdef.WithSkip(probebase.SkipUnlessFetched))
13 changes: 13 additions & 0 deletions proxy/checks/ratelimit/missing_throttling/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: "ratelimit.missing_throttling"
name: "No Per-Client Request Throttling at the Proxy"
description: "Sends a small bounded burst from a single client and reports when none of the requests is throttled (no 429/503) — the proxy enforces no per-client rate limit of its own, so one client can drive unbounded load through to the backend. Informational-to-low: rate limiting at the backend or an external layer is not visible to a single-client burst. Requires --aggressive."
link: "https://owasp.org/www-project-api-security/"
tags:
- rate-limiting
- dos
depends_on:
- "probe.http_fetch"
cvss_vector: "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
cvss_score: 5.3
cwe_id: "CWE-770"
owasp: "API4:2023"
72 changes: 72 additions & 0 deletions proxy/checks/ratelimit/oversized_header/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Package oversizedheader tests whether the proxy caps request header size.
// A front-end that forwards an arbitrarily large header set (rather than
// rejecting it with 431/400/413) lets a client force large per-request
// allocations on the proxy and backend — a cheap memory-pressure / DoS
// vector, and often a sign the proxy isn't buffering defensively.
//
// It sends one request carrying a single very large (128 KiB) header,
// well above typical proxy limits (nginx 8 KiB, Apache ~8 KiB) but bounded,
// and flags acceptance. It confirms an ordinary request is accepted first,
// so a target that rejects everything isn't misread.
//
// Requires --aggressive: it sends a deliberately oversized request, part of
// the opt-in attack-simulation suite.
package oversizedheader

import (
"context"
_ "embed"
"strconv"
"strings"

"github.com/cerberauth/harnessx"
"github.com/cerberauth/harnessx/checkdef"
"github.com/cerberauth/proxyaudit/proxy/checks/ratelimit/rlprobe"
"github.com/cerberauth/proxyaudit/proxy/probebase"
"github.com/cerberauth/proxyaudit/proxy/scanctx"
)

//go:embed check.yaml
var checkYAML []byte

var Def = checkdef.MustParseCheckDefYAML("oversized_header", checkYAML)

// headerBytes is the size of the single oversized header value — above
// common proxy caps, far below anything that could itself exhaust memory.
const headerBytes = 128 * 1024

var Check = checkdef.NewCheck(Def, func(ctx context.Context, target harnessx.Target, _ harnessx.ResultStore) (harnessx.Result, error) {
sctx := scanctx.TargetContext(target)
if !sctx.Aggressive {
return harnessx.Result{Skipped: true, SkipReason: "aggressive-suite check — rerun with --aggressive to send an oversized request"}, nil
}

control, err := rlprobe.Get(ctx, sctx, target.URL, nil)
if err != nil {
return harnessx.Result{Err: err}, nil
}
if control == 0 || control >= 400 {
return harnessx.Result{Skipped: true, SkipReason: "ordinary request not accepted (status " + strconv.Itoa(control) + ") — can't tell an oversize rejection from a blanket one"}, nil
}

oversized, err := rlprobe.Get(ctx, sctx, target.URL, map[string]string{
"X-Proxyaudit-Pad": strings.Repeat("A", headerBytes),
})
if err != nil {
// A transport-level refusal (connection reset/closed) is the proxy
// rejecting the oversized request — the desired behaviour.
return harnessx.Result{}, nil
}
// Rejected with a status: 431/400/413/414 (or any 4xx/5xx) is correct
// defensive handling.
if oversized == 0 || oversized >= 400 {
return harnessx.Result{}, nil
}

return harnessx.Result{Observations: []harnessx.Observation{{
Title: "Proxy accepts oversized request headers without a limit",
Description: "A request carrying a single " + strconv.Itoa(headerBytes/1024) + " KiB header was accepted (" + strconv.Itoa(oversized) + ") instead of being rejected with 431/400/413. The proxy enforces no request-header size cap, so a client can force large per-request allocations on the proxy and backend — a low-cost memory-pressure / denial-of-service vector.",
Evidence: strconv.Itoa(headerBytes/1024) + " KiB header -> " + strconv.Itoa(oversized) + "; ordinary request -> " + strconv.Itoa(control),
Metadata: map[string]string{"header_bytes": strconv.Itoa(headerBytes), "status": strconv.Itoa(oversized)},
}}}, nil
}, checkdef.WithSkip(probebase.SkipUnlessFetched))
13 changes: 13 additions & 0 deletions proxy/checks/ratelimit/oversized_header/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: "ratelimit.oversized_header"
name: "Oversized Request Headers Accepted Without a Limit"
description: "Sends one request carrying a single 128 KiB header — above common proxy caps (nginx/Apache ~8 KiB) but bounded — and flags acceptance (not a 431/400/413 rejection). A proxy with no header-size cap lets a client force large per-request allocations, a low-cost memory-pressure / DoS vector. Confirms an ordinary request is accepted first. Requires --aggressive."
link: "https://owasp.org/www-project-api-security/"
tags:
- rate-limiting
- dos
depends_on:
- "probe.http_fetch"
cvss_vector: "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
cvss_score: 5.3
cwe_id: "CWE-770"
owasp: "API4:2023"
Loading
Loading