Repository navigation
Close click-tracking open redirect; add rate limits; use the PRD's Bucket4j, Caffeine and MaxMind GeoIP2 - #15
Merged
Conversation
- Remove claims of Caffeine caching and Bucket4j rate limiting (neither is used). - Add Docker and CI: Dockerfile usage, docker run, CI workflow, Docker prerequisite. - Fix the project structure (no service/email package; security, util, worker contents). - Database setup that works on PostgreSQL 15+ (database owned by the app user). - Complete key tables, deletion rules (409 when in use, list uploads cascade). - Three test suites, not two; mock email log now shows text and links. - Correct retry schedule, analytics delivered fallback, engagement recency input. - Document disabled /register, hashed one-time tokens, test-send validation. - Example migration is V2 after the squash.
…eine and MaxMind GeoIP2 Security - /track/click only redirects to a link that is in that recipient's email (the sent HTML is checked); unknown tokens or other URLs get 404 and record nothing. - Per-IP rate limits (Bucket4j) on login (20/min) and forgot/reset-password and verify-email (10/h), answering 429 with Retry-After; at most 3 reset emails per address per hour. PRD libraries - Bucket4j caps the send worker at app.sending.rate-per-second (default 14, SES's default limit); an interrupted worker hands the rest of its batch back. - Caffeine caches the analytics queries and engagement scores (app.analytics.cache-ttl, default 60s); a score refresh clears its cache. - MaxMind GeoIP2 replaces IPinfo: offline lookups from a GeoLite2/GeoIP2 database file (GEOIP_DATABASE_PATH), optional; private addresses and host names are never looked up. - Drop the unused SNS SDK module; keep STS (needed by the credentials chain for IAM roles) with a comment saying why. Also: register endpoint javadoc no longer describes removed account creation; README brought in line with the code (Docker, CI, tables, limits, geolocation).
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 issues from the last review and brings the libraries in line with the PRD. Also includes the README refresh.
Security
GET /track/click/{token}?t=…redirected to any URL encoded int, even for unknown tokens, and fell back tomailengine.com(a domain we don't own). Anyone could make a link on our domain that lands on a phishing page, and could record fake clicks. Now the server redirects only to a link that is in that recipient's sent email; otherwise 404, with nothing recorded.Retry-After):getRemoteAddr(), which Tomcat resolves fromX-Forwarded-Foronly behind trusted proxies, so a client can't fake it.PRD libraries
SEND_RATE_PER_SECOND(default 14, SES's default limit; 1 in the sandbox; 0 = off). Waiting is interruptible: on shutdown the rest of the batch is handed back.@EnableCaching; the 5 campaign analytics queries and engagement scores are cached forANALYTICS_CACHE_TTL(default 60 s), and a score refresh clears its cache.GEOIP_DATABASE_PATH. Optional: without it, events are stored without location, as before without an IPinfo token. Private addresses and host names are never looked up (no DNS).SnsMessageVerifierchecks them. STS stays: the default credentials chain needs it for IAM roles (web identity / EKS,role_arnprofiles); a comment says so.IPINFO_TOKENis no longer read. For locations, download GeoLite2 City (free MaxMind account), mount it, and setGEOIP_DATABASE_PATH. The file can't be committed (MaxMind licence);geoipupdatekeeps it current. See the README section "IP geolocation".SEND_RATE_PER_SECONDto your provider's limit if it isn't 14.Also
AuthController.registerjavadoc no longer describes the removed account creation..env.examplelists the new settings.Testing
AuthRateLimitFilterTest,GeoIpServiceTest(MaxMind reader mocked; GeoLite2 files need a licence key), the worker's rate cap and interrupted hand-back, the per-address reset limit, the click redirect (followed only for links in the email; 404 otherwise, no fake clicks) and the analytics cache inSweepFixesIntegrationTest.