Repository navigation
Real client IP, Apple proxy detection, one eligibility query, expiring temp passwords - #20
Merged
Merged
Conversation
…xpiring temp passwords - Tracking records request.getRemoteAddr() (resolved by Tomcat's RemoteIpValve) instead of reading X-Forwarded-For, which anyone could forge. - Apple Mail Privacy Protection opens are flagged by Apple's network, 17.0.0.0/8; the User-Agent check never matched Apple's proxy. - Sending collects eligible recipients in one query instead of one suppression lookup per list member. - Temporary passwords are 16 SecureRandom characters and expire (V4): 7 days for invites, 24 hours for admin resets. Login refuses expired ones; changing or resetting clears it.
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 the last batch of audit findings (the minor items).
Problems
TrackingService.extractIpused the first entry ofX-Forwarded-For, which any client can set, so the recorded IP and location were whatever the client said.Mozilla/5.0User-Agent.collectEligibleRecipientschecked each list member separately, so a 100k-recipient campaign made 100k queries before queuing anything."Tmp-" + 8 hex characters(32 bits), valid forever.Changes
request.getRemoteAddr(). Tomcat'sRemoteIpValve(forward-headers-strategy: native) already sets it fromX-Forwarded-For, trusting the header only from internal proxy addresses.17.0.0.0/8, which Apple owns outright. The IP comes from the change above, so it can't be faked.RecipientRepository.findEligibleForCampaignreturns, in one query, the active recipients of the campaign's lists whose address isn't suppressed.CampaignSendingServicedrops three dependencies it no longer needs.TemporaryPasswords: 16SecureRandomcharacters from an alphabet without look-alikes (about 93 bits).V4__temp_password_expiry.sqladdsusers.temp_password_expires_at. Invites set it to 7 days, admin resets to 24 hours; null means no expiry, which covers the seeded admin.Deploy notes
V4runs at startup.X-Forwarded-For, and opens and clicks will be recorded with the proxy's IP. Add the proxy's address toserver.tomcat.remoteip.internal-proxies.Testing
./gradlew test integrationTest scaleTestpass locally (474 tests).17.0.0.0/8are flagged; neighbours, IPv6, null and malformed input aren't.X-Forwarded-Forrecords the connection's IP; an open from17.58.63.1is flagged as the Apple proxy.