fix: DNS and SMTP drop interactions when nonce lengths differ#1345
fix: DNS and SMTP drop interactions when nonce lengths differ#1345jentfoo wants to merge 11 commits intoprojectdiscovery:devfrom
Conversation
…ion-strategy feat(server) added eviction strategy
…-1275-feature/eviction-strategy Revert "feat(server) added eviction strategy"
interactsh v1.3.0
Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.8.0 to 1.8.2. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](refraction-networking/utls@v1.8.0...v1.8.2) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-version: 1.8.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
…abot/go_modules/github.com/refraction-networking/utls-1.8.2 chore(deps): bump github.com/refraction-networking/utls from 1.8.0 to 1.8.2
release interactsh v1.3.1
DNS and SMTP accumulated sliding-window matches in a single variable (last match wins) and stored only once after the loop. This silently dropped valid interactions when the server's correlation-id-nonce-length was shorter than a client's. This change updates both to dispatch per match inside the loop, mirroring the working HTTP/LDAP pattern. SMTP also gains the missing SlideWithLength and ToLower normalization.
Neo - PR Security ReviewNo security issues found Highlights
Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe changes extract and centralize interaction encoding/storage into new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pkg/server/smtp_server.go (1)
83-85: Add a length guard before slicinguniqueID.This helper assumes validated input; adding a guard prevents accidental panic if another call path is introduced later.
🛡️ Proposed guard
func (h *SMTPServer) storeInteraction(uniqueID, fullID, dataString, from, remoteAddr string) { + if len(uniqueID) < h.options.CorrelationIdLength { + gologger.Warning().Msgf("Skipping smtp interaction with short uniqueID: %q", uniqueID) + return + } correlationID := uniqueID[:h.options.CorrelationIdLength] interaction := &Interaction{🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/server/smtp_server.go` around lines 83 - 85, The storeInteraction helper slices uniqueID into correlationID without checking length, which can panic; add a guard in SMTPServer.storeInteraction that verifies len(uniqueID) >= h.options.CorrelationIdLength before slicing and, if the check fails, fall back to a safe value (e.g., use uniqueID as the correlationID or an empty string) or early-return; reference the unique symbols uniqueID, h.options.CorrelationIdLength and the function storeInteraction when making the change so the slice operation is protected.pkg/server/dns_server.go (1)
302-304: Harden helper against future short-input panics.
uniqueID[:h.options.CorrelationIdLength]will panic if a future caller passes malformed input. Current callers are safe, but this helper is a good place for a defensive guard.🛡️ Proposed guard
func (h *DNSServer) storeInteraction(uniqueID, fullID, qtype, requestMsg, responseMsg, remoteAddr string) { + if len(uniqueID) < h.options.CorrelationIdLength { + gologger.Warning().Msgf("Skipping dns interaction with short uniqueID: %q", uniqueID) + return + } correlationID := uniqueID[:h.options.CorrelationIdLength] interaction := &Interaction{🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/server/dns_server.go` around lines 302 - 304, The slice operation uniqueID[:h.options.CorrelationIdLength] in DNSServer.storeInteraction can panic if uniqueID is shorter than h.options.CorrelationIdLength; add a defensive guard in storeInteraction that checks len(uniqueID) and uses a safe fallback (e.g., use uniqueID itself or an empty string) when it's too short, then proceed to build the Interaction normally (referencing DNSServer.storeInteraction, Interaction struct, and h.options.CorrelationIdLength); optionally emit a debug/warn log when the fallback is used to aid future debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/server/server_test.go`:
- Around line 21-33: The tests create IDs that don't match the configured length
rules, causing the sliding-window case to pass on generic alphanumerics rather
than an actual embedded correlation ID; update the test fixtures so they use
Options.GetIdLength() (or compute expected total length from
Options.CorrelationIdLength and Options.CorrelationIdNonceLength) when building
id strings, and construct the "longer" string so the nonce differs but the
embedded xid segment remains exactly the expected CorrelationIdLength;
specifically adjust the "exact length match" and "sliding window finds embedded
ID" cases to derive lengths from Options (or call GetIdLength()) and ensure
Options.isCorrelationID is exercised with an actual valid xid substring rather
than a random alphanumeric window.
---
Nitpick comments:
In `@pkg/server/dns_server.go`:
- Around line 302-304: The slice operation
uniqueID[:h.options.CorrelationIdLength] in DNSServer.storeInteraction can panic
if uniqueID is shorter than h.options.CorrelationIdLength; add a defensive guard
in storeInteraction that checks len(uniqueID) and uses a safe fallback (e.g.,
use uniqueID itself or an empty string) when it's too short, then proceed to
build the Interaction normally (referencing DNSServer.storeInteraction,
Interaction struct, and h.options.CorrelationIdLength); optionally emit a
debug/warn log when the fallback is used to aid future debugging.
In `@pkg/server/smtp_server.go`:
- Around line 83-85: The storeInteraction helper slices uniqueID into
correlationID without checking length, which can panic; add a guard in
SMTPServer.storeInteraction that verifies len(uniqueID) >=
h.options.CorrelationIdLength before slicing and, if the check fails, fall back
to a safe value (e.g., use uniqueID as the correlationID or an empty string) or
early-return; reference the unique symbols uniqueID,
h.options.CorrelationIdLength and the function storeInteraction when making the
change so the slice operation is protected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c75cb439-e1ac-430f-9592-c3d3629118cd
📒 Files selected for processing (3)
pkg/server/dns_server.gopkg/server/server_test.gopkg/server/smtp_server.go
|
This would be a valuable fix, allowing servers to configure a lower nonce length to allow for client flexibility. However if willing to accept a larger change I just submitted #1347 which I believe is a more complete and flexible solution. |
DNS and SMTP accumulated sliding-window matches in a single variable (last match wins) and stored only once after the loop. This silently dropped valid interactions when the server's correlation-id-nonce-length was shorter than a client's.
This change updates both to dispatch per match inside the loop, mirroring the working HTTP/LDAP pattern. SMTP also gains the missing SlideWithLength and ToLower normalization.
Summary by CodeRabbit
Tests
Refactor