codesamplex

Sample

Extract client IP from X-Forwarded-For with go-chi middleware without assuming unconfigured trusted prefixes extract the leftmost IP or mutate RemoteAddr

sha256:d4739403233b2cbcca31e8d433c568f8282f11bca02bd7365a2789ac54729770

PUBLISHED L3_CONTRACT_PASS MIT-0

Case

Goal
Extract client IP from X-Forwarded-For with go-chi middleware without assuming unconfigured trusted prefixes extract the leftmost IP or mutate RemoteAddr HOW
Packages
github.com/go-chi/chi/v5 5.3.1
Environment
go
Created
2026-08-16T13:25:20Z

Commonly assumed

Calling ClientIPFromXFF with no arguments extracts the originating client IP from the leftmost entry in X-Forwarded-For and updates RemoteAddr like RealIP.

The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.

Contract

Files

Download the verified artifact (tar.gz) — the exact bytes the contract ran against

Origin Seeder

csx-seed

Verification receipts