Don't follow OSINT HTTP redirects off the scan target - #26
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
fingerprint_http imported urllib.error inside the function after using urllib.request, so every call raised UnboundLocalError and returned no technologies. Once that path actually ran, urllib followed 3xx Location to metadata/RFC1918 and could fingerprint the wrong origin. Refuse redirects, match raw header lines, and cover both with tests. Co-authored-by: dmitryflynn <dmitryflynn@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.
Bug and impact
src/osint.pyfingerprint_httpnever produced technology hits, and once that path actually ran it would followLocationoff the authorized origin.Trigger: any
--osint/--full/--aiscan. The innerimport urllib.errormadeurlliba local name, sourllib.request.Request(...)raisedUnboundLocalErroron every call. The bareexcept Exception: passswallowed it, so OSINT always reported an empty technology list.Second trigger (after the import is fixed, or if someone reorders it): the scan target answers
HEAD /with302 Location: http://169.254.169.254/…(or any RFC1918 neighbor). urllib's default opener follows the redirect and fingerprints the destination — SSRF from the agent plus false stack data.Root cause
import urllib.errorinside the function body, afterurllib.request.Request, bindsurllibas a local and breaks every call.urlopenfollows 3xx with no same-origin check (same class as Don't follow HTTP redirects off the scan target #24/Don't follow HTTP redirects in vuln_prober fetches #25, but this site was not in those PRs).str(dict(headers))is Python dict repr and never matches signatures likeServer: nginx.This is not a duplicate of #24 (header/stack/service/web fetchers) or #25 (
vuln_prober._http_get).Fix
ssl/urllib.errorat module level.HTTPError.Name: valueheader lines soTECH_SIGNATUREScan fire.Validation
python3 -m pytest test_osint.py -q— 23 passed (including new redirect + in-scope header tests).python3 -m pytest test_osint.py test_security_hardening.py test_active_validation.py -q— 70 passed.python3 -m bandit -r src/osint.py --severity-level high— no high findings.