oauth2-proxy/pkg
Georgi Georgiev 08ce94d1c0 security: harden X-Forwarded-For parsing against spoofing
The real-client-IP lookup used by the --trusted-ip auth-bypass allowlist
blindly trusted the leftmost value in X-Forwarded-For (or other
configured --real-client-ip-header). When trusting X-Forwarded-For (which
is the only header set by AWS ALB for example) the connecting peer's
address is appended to X-Forwarded-For rather than replacing the header,
and a client could set X-Forwarded-For to an allowlisted IP and have it
trusted regardless of who actually connected to the proxy.

The parser now walks the hop chain from the newest (rightmost) entry
inward, skipping hops that are themselves trusted proxies, and returns
the first entry that isn't. If the direct connecting peer isn't itself a
trusted proxy, the header is ignored entirely. This reuses the existing
--trusted-proxy-ip configuration, so behavior for deployments that leave
it unset (today's documented trust-all default) is unchanged.

Signed-off-by: Georgi Georgiev <310867+chutzimir@users.noreply.github.com>
2026-07-21 03:53:36 +09:00
..
apis security: harden X-Forwarded-For parsing against spoofing 2026-07-21 03:53:36 +09:00
app Merge commit from fork 2026-04-13 18:22:56 +02:00
authentication chore(goconsts): use proper constants for http methods 2026-06-08 12:54:58 +02:00
cookies Merge commit from fork 2026-04-13 18:22:56 +02:00
encryption fix alpha config 2025-11-16 22:38:40 +01:00
header revert: secrets as []byte instead of string 2025-11-16 22:38:42 +01:00
ip security: harden X-Forwarded-For parsing against spoofing 2026-07-21 03:53:36 +09:00
logger Request ID Logging (#1087) 2021-03-21 18:20:57 +00:00
middleware Merge commit from fork 2026-04-13 18:22:56 +02:00
providers feat: add support for specifying allowed OIDC JWT signing algorithms (#2753) (#2851) 2026-03-18 22:24:27 +08:00
proxyhttp feat: add support for setting a unix binding's socket file mode (#3376) 2026-03-19 00:08:50 +08:00
requests chore(goconsts): use proper constants for http methods 2026-06-08 12:54:58 +02:00
sessions feat: add same site option for csrf cookies (#3347) 2026-03-18 23:14:36 +08:00
upstream chore(deps): bump Go to 1.26 and migrate upstream reverse proxies to Rewrite 2026-06-08 14:12:56 +02:00
util feat: allow arbitrary claims from the IDToken and IdentityProvider UserInfo endpoint to be added to the session state (#2685) 2026-03-14 12:04:33 +08:00
validation security: harden X-Forwarded-For parsing against spoofing 2026-07-21 03:53:36 +09:00
version feat: Replace default Go user-agent with oauth2-proxy and version (#2570) 2024-07-14 21:09:17 +01:00
watcher Fix Linting Errors (#1835) 2022-10-21 11:57:51 +01:00