Mitigate relay-details DNS lookup availability risk#475
Merged
JuliusHenke merged 2 commits intomasterfrom May 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce reverse-DNS availability risk in the backend relay-details flow by limiting per-request hostname verification work and coalescing concurrent cache misses for the same relay IP.
Changes:
- Adds a 10-hostname cap to PTR hostname verification in
ReverseDnsLookupService. - Enables synchronized cache loading for reverse-DNS lookups with
@Cacheable(..., sync = true). - Adds a unit test covering the verification cap behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
backend/src/main/kotlin/org/tormap/service/ReverseDnsLookupService.kt |
Caps PTR verification work and enables synchronized cache loading for reverse-DNS results. |
backend/src/test/kotlin/org/tormap/service/ReverseDnsLookupServiceTest.kt |
Adds unit coverage for the new hostname-verification limit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ehavior Agent-Logs-Url: https://github.com/TorMap/tormap/sessions/a743ca48-5f4b-4732-b161-d90704fab317 Co-authored-by: JuliusHenke <23460202+JuliusHenke@users.noreply.github.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.
Motivation
relay/**details endpoint performed unbounded, synchronous PTR and forward DNS lookups in the HTTP request path, allowing attacker-controlled PTR responses or slow DNS to tie up request threads and cause availability loss.Description
MAX_PTR_HOSTNAMES_TO_VERIFY = 10and applying.take(MAX_PTR_HOSTNAMES_TO_VERIFY)to the distinct PTR hostnames list inReverseDnsLookupService.lookupHostNamesto cap forward-lookup calls per request. (backend/src/main/kotlin/org/tormap/service/ReverseDnsLookupService.kt)sync = trueto the@Cacheableannotation for reverse DNS lookups to reduce concurrent cache-miss stampedes for the same IP. (backend/src/main/kotlin/org/tormap/service/ReverseDnsLookupService.kt)"lookupHostNames limits number of host names verified"toReverseDnsLookupServiceTestthat verifies only 10 forward lookups are performed when PTR returns 20 names. (backend/src/test/kotlin/org/tormap/service/ReverseDnsLookupServiceTest.kt)Testing
org.tormap.service.ReverseDnsLookupServiceTestthat asserts the hostname verification limit and expected forward-lookup call count../gradlew test --tests org.tormap.service.ReverseDnsLookupServiceTest --no-daemon, but the run failed in this environment due to a JVM/Gradle compatibility issue reported as25.0.1, not due to the test logic itself, so tests could not be executed here.Codex Task