You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b95e406
Browse filesBrowse the repository at this point in the historyBrowse files
feat(delivery): optional trustedForwarders — proxy-pinned XFF classification (Class A/B labels), zero-trust default untouched, signed by contract
trustedForwarders: [addresses] arms a client-class gate that LABELS forwarded-client claims on every response via x-dde-client-class: forwarder-claimed (a listed proxy vouches for the XFF claim; every guard still keys on the proxy's socket), forwarder-no-xff, self-claimed (an unlisted peer's header — an unverified client claim), or direct. The default posture is unchanged and contract-proven to stay unchanged: with no list configured the XFF header is never read, never parsed, and no class header is emitted; a 403'd stranger is refused before classification; allowlist, rate buckets, and the boundary read the direct peer alone in EVERY configuration. createClientClassGate normalizes peers exactly like the allowlist (mapped-v6 collapse), is exported for unit tests, and the doc gains the option, the classification arm of the proxy posture, and a wire-proven start line (doc-curl pin 7->8).
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Copy file name to clipboardExpand all lines: docs/delivery-dispute-boundary.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,6 +194,24 @@ Hardening for a deliberate public bind (three fail-closed guards, all tested):
194
194
-**Two-layer size gate** — a declared `content-length` over the cap is
195
195
refused before any body byte is read; the 1 MiB streaming cap remains the
196
196
truth for absent or lying declarations.
197
+
-**Trusted-forwarder classification (OPTIONAL, off by default)** —
198
+
`trustedForwarders: ["127.0.0.1", …]` names the proxies whose
199
+
`X-Forwarded-For` claims may be CLASSIFIED. With a list configured, every
200
+
response carries `x-dde-client-class`: `forwarder-claimed` (the peer IS a
201
+
listed forwarder and it supplied an XFF claim — the proxy vouches; the wire
202
+
identity every guard keys on is still the proxy), `forwarder-no-xff`
203
+
(listed forwarder, no claim), `self-claimed` (an unlisted peer sent an XFF
204
+
header — an unverified client-supplied claim, exactly the forged-header
205
+
posture the default rejects trusting), or `direct` (no forwarder
206
+
infrastructure; the peer address is the client identity). The classes are
207
+
an observability and policy-adjacent surface: allowlist and rate-limit
208
+
decisions still key on the direct peer alone in every configuration.
209
+
Absent or empty → the header is never read at all: the zero-trust default
210
+
is the default, not a mode you fall out of by omission.
211
+
-**Forwarded-header rule (unchanged)** — forwarded headers are LOGGING data
212
+
and, with `trustedForwarders` configured, CLASSIFICATION input — never
213
+
identity. No configuration makes a header open the allowlist, alter the
214
+
rate bucket, or replace the socket peer in any decision.
197
215
198
216
### Wire-level integration — a copy-ready payout gate
199
217
@@ -329,6 +347,22 @@ default of 1m); adapt names to your proxy if it is not nginx.
329
347
private network, list the proxy hosts' addresses. (They all share one
330
348
verdict: the proxy is the front door by design.)
331
349
350
+
3b. **OPTIONAL: classify forwarded-client claims with `trustedForwarders`.**
351
+
Passing the same proxy addresses to `trustedForwarders` arms the
352
+
client-class gate WITHOUT moving any decision off the socket: responses
353
+
then carry `x-dde-client-class` — `forwarder-claimed` when the proxy (a
354
+
listed forwarder) supplied an `X-Forwarded-For` claim (the proxy vouches;
355
+
every guard still keys on the proxy's socket), `forwarder-no-xff`,
356
+
`self-claimed` when an UNLISTED peer sends the header (an unverified
357
+
client-supplied claim — exactly what the zero-trust default refuses to
358
+
trust), or `direct`. The classes feed YOUR logging, metrics, or
359
+
downstream policy — the allowlist, the rate buckets, and the boundary
360
+
never read the header. Leave the option off and nothing changes at all:
361
+
the header is not even parsed. (A listed forwarder on a private network
362
+
is the only posture where this mode says anything; on loopback with a
363
+
same-host proxy it distinguishes proxied traffic from direct
364
+
probes — useful, still zero-decision.)
365
+
332
366
4.**The in-process rate limiter becomes a backstop, not the primary limiter.**
333
367
Size it above the proxy's per-client ceiling (e.g. `rateLimit: {
334
368
windowMs: 60_000, max: 600 }` for a 10 r/s edge limit) so it only fires on
@@ -347,6 +381,7 @@ default of 1m); adapt names to your proxy if it is not nginx.
347
381
|`host`|`127.0.0.1`|`127.0.0.1` (proxy on same host) or a privateinterface — never `0.0.0.0`|
348
382
|`rateLimit`|`120/min` per real client | backstop per proxy, sized **above** the proxy's per-client ceiling (e.g. 600/min); primary limiting at the edge |
349
383
| `allowAddresses` | omit — the loopback bind *is* the guard | pin the proxy's source address(es) — containment for a misexposed port |
384
+
|`trustedForwarders`| omit — XFF is never read (zero-trust default) | optionally the proxy's address(es) — adds `x-dde-client-class` labels (`forwarder-claimed` / `self-claimed` / `direct`); no decision ever reads the header |
350
385
| body cap | 1 MiB (two layers) | 1 MiB, with the edge cap ≤ 1 MiB so oversize dies at the proxy |
351
386
| TLS | out of scope (loopback) | terminated at the proxy; the app speaks plain HTTP over loopback/private net |
352
387
@@ -362,7 +397,16 @@ The limiter keys on the proxy (the direct peer), so its `x-ratelimit-*`
362
397
headers read as the backstop budget — `x-ratelimit-limit: 600` on every
363
398
response is the proof the posture took. Per-client limiting lives at the
364
399
edge (`limit_req`), the app ignores forwarded headers by contract, and the
365
-
allowlist is the containment layer for a misexposed port.
400
+
allowlist is the containment layer for a misexposed port. Add the same
401
+
address to `trustedForwarders` to additionally label every response with
// agent-incident-evidence — the hardening line joined the count only after
473
-
// the comment-inert tokenizer fix made it visible). A line LOST fails here
474
-
// by name; a line ADDED must update this pin in the same commit AND
475
-
// inherit the per-line proof above — which is the point: a start line
476
-
// never ships unproven again, in either direction.
470
+
// [C25]+[C32] exactness: the pin is the MEASURED set (8 start lines:
471
+
// delivery-dispute-boundary ×4 — base, hardening, production, and the
472
+
// optional trustedForwarders classification arm — examples README, README,
473
+
// INTEGRATION, agent-incident-evidence). A line LOST fails here by name;
474
+
// a line ADDED must update this pin in the same commit AND inherit the
475
+
// per-line proof above — which is the point: a start line never ships
476
+
// unproven again, in either direction.
477
477
assert.equal(
478
-
totalStartCmds,7,
479
-
`documented start-line set moved: found ${totalStartCmds}, pin is 7 — a line was lost (restore/prove it) or added (update the pin in the same commit and confirm the per-line proof above ran for it)`,
478
+
totalStartCmds,8,
479
+
`documented start-line set moved: found ${totalStartCmds}, pin is 8 — a line was lost (restore/prove it) or added (update the pin in the same commit and confirm the per-line proof above ran for it)`,
0 commit comments