Repository navigation
Trust the proxy's last X-Forwarded-For hop, and decide trust once - #45
Merged
Merged
Conversation
Behind the trusted proxy, the audit log recorded the first X-Forwarded-For value. Proxies append the address they saw to whatever the client sent, so the first value was the client's to choose, and logins and admin actions could be logged under a made-up address. The last value, the one the proxy added, is used now. Whether to believe a request's X-Forwarded-* headers was worked out again (shared secret compare, address scan) on each of the 3-4 calls a request makes. A middleware now decides it once and keeps the host, scheme and client address in the request context. Port 8080 also read the HTTPS state from SQLite on every request, on the single connection the ledger writes through. The state is now read once and kept in memory; only the HTTPS settings handlers change it. Fixes #29 Fixes #37
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.
Fixes #29 and #37.
Audit address (#29). Behind the trusted proxy, the audit log recorded the first
X-Forwarded-Forvalue. Proxies append the address they saw to whatever the client sent, so the first value was the client's to choose. Logins and admin actions could be logged under a made-up address. The last value, the one the proxy appended, is used now.X-Forwarded-Hostand-Protokeep their first value, which the proxy sets.docs/install.mdnotes which value is used and the nginx line that appends it.Proxy trust once per request (#37). Whether to believe a request's
X-Forwarded-*headers was worked out again (secret compare and address scan) on each of the 3–4 calls a request makes (isHTTPS,clientIP,forwardedHost,isSiteHost).withForwardedmiddleware now decides it once and keeps the host, scheme and client address in the request context.ProxyIdentitykeeps its own check: the gateway uses a stricter rule (secret only) than the UI.HTTPS state in memory (#37). Port 8080 read the
httpssetting from SQLite on every request, on the single connection the ledger also writes through. It is now read once and kept in memory, andsetHTTPSStatesaves changes to both the database and memory. Only the name and confirm handlers andSeedHTTPSNamechange it.Tests:
TestForwardedHeadersTrustedLikeIdentitynow sends a made-up first hop and expects the proxy's address. It fails on the old first-value code.TestHTTPSStateIsReadOnceAndSavedis new.