Repository navigation
fix(audit): record the trusted-proxy-aware client IP, never raw X-Forwarded-For (#877) - #883
Merged
Merged
Conversation
…warded-For (#877) Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #877
AuditService.LogFiberreplacedc.IP()with the rawX-Forwarded-Forheader whenever the header was there, so any client could write the IP of its choice intoauth_audit_logs(login, refresh, MFA, SSO events). It now recordsc.IP()only. Fiber resolves the forwarded address inc.IP()only when the peer is a configured trusted proxy (F-04).The same raw read was in
MFARateLimitandOAuthRateLimit(internal/middleware/auth.go). Neither is mounted anywhere today, but both now usec.IP()too, so the defect can't come back when someone wires them.Verification
TestLogFiber_UntrustedPeerCannotChooseTheAuditedIP: fails on master (the audit row recorded the client-supplied X-Forwarded-For), passes here.TestLogFiber_TrustedProxyForwardedAddressIsKept: passes (a trusted proxy's forwarded address is still recorded).grep -rn 'Get("X-Forwarded-For")' --include=*.go backend | grep -v _test→ 0 lines.go build ./... && go vet ./... && go test ./... -race: BUILD_OK · VET_OK · TEST_OK, 80 packagesok, 0FAIL. Note: master currently doesn't build (fix(auth): master does not build — the #866 merge kept the unsigned SAML ACS body #881), so this gate ran with fix(auth): master does not build — restore the #866 SAML handler (#881) #882's commit temporarily applied on top. That commit isn't part of this PR.Honest remainders
internal/handler.