test(ratelimit): make XFF bypass vulnerability test deterministic (issue #179) #3073
Reference in New Issue
Block a user
Delete Branch "fix/ratelimit-xff-bypass-test-179"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Makes
TestRateLimit_XFF_BypassDocumenteddeterministic by explicitly configuring the test Gin router to trust the synthetic test proxy (10.0.0.1/32).Why
Modern Gin defaults to trusting NO proxies, so the previous test relied on ambient default behavior and would
t.Skipwhen the bypass did not reproduce. The new test explicitly opts the test source into the trusted-proxies list, soc.ClientIP()readsX-Forwarded-Forand the bypass is reproduced reliably. The assertion is also upgraded fromt.Skipftot.Errorfbecause the bypass is now expected under the controlled config.Fixes #179
Test plan
SOP checklist
SOP checklist
APPROVED on head
1b09529066.5-axis review: correctness looks sound for a deterministic documentation/regression test. The test now explicitly configures Gin to trust the synthetic source proxy 10.0.0.1/32, so c.ClientIP() deterministically honors X-Forwarded-For and reproduces the documented pre-fix bypass instead of depending on ambient Gin defaults and skipping. It still pairs with the existing SetTrustedProxies(nil) regression test that proves the real fix blocks spoofed XFF. Robustness improves by replacing t.Skipf with a real failure under controlled setup; security/runtime behavior is unchanged (test-only); performance impact is none; readability is clear.
CI was not green when checked: several contexts pending plus gate/security-review failures, so merge should wait for branch protection/all-required.
APPROVED on current head
1b095290.5-axis: Correctness: the test now explicitly trusts 10.0.0.1/32, matching the synthetic RemoteAddr, so Gin will honor X-Forwarded-For and the documented bypass path is deterministic instead of ambient/default-dependent. It also upgrades the bypass expectation from skip to failure, so the test now pins behavior. Robustness: leaves the secure SetTrustedProxies(nil) regression test intact. Security: test-only, but it strengthens coverage for #179. Performance: no runtime impact. Readability: comments explain modern Gin defaults and the intentional trusted-proxy setup.
CI verified: non-empty diff; CI / all-required, Platform (Go), E2E API, qa/security review gates all green.
/sop-ack 1
/sop-ack 2
/sop-ack 3
/sop-ack 4
/sop-ack 5
/sop-ack 6
/sop-ack 7