fix: prevent crash on malformed FQDNs by handling LocationParseError (fixes #2970)#2972
Open
marcos-dataops wants to merge 1 commit into
Open
Conversation
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.
Description
This PR fixes the fatal crash reported in #2970 when searching for usernames ending in a period (e.g.,
alice.).The Root Cause:
When a username ending in a period is interpolated into a subdomain-based target (like
https://{}.empretienda.com.ar), it generates a malformed FQDN containing consecutive dots (alice..empretienda.com.ar). Whenrequests_futuresattempts to resolve this, the underlyingurllib3library raises aLocationParseError. Because this specific exception does not inherit fromrequests.exceptions.RequestException, it bypassed the existing error handling inget_response, crashing the entire application.The Solution:
Instead of playing whack-a-mole by adding regex filters to individual targets in
data.json(which breaks CI target validation as seen in PR #2971 and doesn't scale for future target additions), this PR implements a robust architectural fix at the network layer.By catching
urllib3.exceptions.LocationParseErrorandrequests.exceptions.InvalidURLdirectly in the asynchronous future resolution block (sherlock_project/sherlock.py), the application now gracefully handles any malformed URL generation, marks the specific target as failed ("Illegal URL"), and continues execution without crashing.Steps to Test
python3 -m sherlock_project alice.alice..empretienda.com.ar.Checklist:
data.jsonchanges).