mirror of
https://github.com/elementalsouls/Claude-BugHunter.git
synced 2026-11-24 20:30:23 +01:00
* fix(scope): normalize every rule source to host; add Scope.warnings Out-of-scope rules written with a scheme/port/path/trailing punctuation or a wildcard matched nothing and silently failed open. One normalization point in Scope.__init__ now reduces every rule source (scope.md, scope.json, CLI flags, osint/recon helpers) to its host. Port/path widening is recorded in a new Scope.warnings channel. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): recognize IPv6 CIDR rules via ipaddress The CIDR detector used p.replace('.','').replace('/','').isdigit(), which colons make non-digit, so an IPv6 CIDR deny/allow rule (2001:db8::/32) never matched. Detect any CIDR via ipaddress.ip_network; a family mismatch returns False, never raises. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): soft-fail an invalid out-of-scope regex (warn, treat as host) A bad re: deny regex was caught and silently matched nothing — a fail-open on the one gate that must fail closed. Now it warns loudly and re-admits the remainder as a literal host deny rule, so the run continues with scope still enforcing. Valid regexes are unaffected. Reported by @fairoz-539 (#182). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): open a section only on a start/end scope heading; hint recon hosts A recon-seeded note heading ('... VERIFY in-scope before testing') matched the substring 'in-scope' and opened the in-scope section, silently promoting passive crt.sh/subfinder hosts to scope rules (#198). _section_of now opens a section only when the heading's label starts or ends with a scope phrase (trailing parenthetical and colon stripped first). Hosts found under a scope-mentioning note heading are surfaced as a Scope.warnings hint instead. Scaffolder heading reworded (no inner quotes; hunt.ps1 stays ASCII). Reported by @udarshmarthala (#198). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): surface scope warnings on stderr and in the engine log Scope.warnings (bad deny regex, widened rule, recon-seeded hosts) now print to stderr from scope.py and go to the engine log at start — nothing is silent, and stdout stays clean for --json-style consumers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(engine): follow recon redirects one hop at a time, inside scope Recon fetches followed redirects to any host: spa_recon adopted the landed (possibly off-scope) origin and crawled its robots/sitemap; _probe ran curl -L, so platform/openapi recon chased Location anywhere. A new _walk() follows at most MAX_REDIRECTS hops and only while the scope predicate accepts the next URL; all backends (requests, a no-redirect stdlib _OPENER, curl without -L) route through it. spa_recon re-checks the landed host, and platform/openapi recon skip out-of-scope seeds. In-scope redirects (http->https, / -> /home) are unaffected. Reported by @fairoz-539 (#181). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(engine): auth sweep grades a 3xx as enforcement, never chases Location A declared-secured op answering 302 -> /login was graded by the followed login page's 200 as 'declared-secured, NOT enforced' — a false positive. The sweep now uses the no-redirect opener, so a 3xx is graded as itself (enforcement) and no request chases Location. Repoints test_openapi_readonly to the module opener. Adds the scope-hardening CHANGELOG entry. Reported by @fairoz-539 (#181). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(scope): review follow-ups — bare IPv6 deny, prune redirect, test sockets Fresh-review fixes: - CRITICAL: a bare/zoned unbracketed IPv6 single-host rule normalized to its first hextet (urlparse split on ':'), so an IPv6 out-of-scope rule failed open. Detect a literal IP in _normalize_rule and return its canonical form. - IMPORTANT: prune_inert_params followed no redirects (allow=None), so a live parameterized endpoint behind an in-scope redirect (http->https, canonical slash) was mis-judged inert and dropped. Thread scope through and follow in-scope hops. - MINOR: loopback test servers now server_close() in tearDown (no leaked sockets under -W error). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs(superpowers): scope-hardening design + implementation plan Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(osint): enumeration_roots covers host after scope normalizes port/path Rebase interaction with #221: the scope gate (#205) now widens example.com/path and example.com:8080 to the host example.com, so enumeration_roots correctly yields ['example.com'] instead of dropping them. Update the #221 regression case to the combined correct behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
2.0 KiB
Python
40 lines
2.0 KiB
Python
"""Subdomain-enumeration roots must come from the authorized scope, not from
|
|
truncating a seed host to its last two labels. Under a multi-label public suffix
|
|
(`example.co.uk`, `*.com.au`) that truncation lands on the suffix itself (`co.uk`),
|
|
so enumeration queries the whole suffix and `--expand` never enumerates the target.
|
|
Reported in #213."""
|
|
import unittest
|
|
|
|
import osint
|
|
from scope import Scope
|
|
|
|
|
|
class EnumerationRootTests(unittest.TestCase):
|
|
def test_roots_follow_authorized_domains(self):
|
|
cases = [
|
|
# multi-label suffix: root stays the real domain, not co.uk
|
|
(["*.example.co.uk"], ["https://example.co.uk"], ["example.co.uk"]),
|
|
(["*.example.com"], ["https://api.example.com"], ["example.com"]),
|
|
# exact-host scope with no wildcard: root is that host
|
|
(["app.example.com"], ["https://app.example.com"], ["app.example.com"]),
|
|
# IP literals produce no enumeration root
|
|
(["127.0.0.1", "::1"], ["http://127.0.0.1", "http://[::1]"], []),
|
|
# regex rules are not roots; path/port forms are normalized to the host
|
|
# by the scope gate (#205), so they DO contribute example.com as a root
|
|
(["re:.*example.com", "example.com/path", "example.com:8080"], [], ["example.com"]),
|
|
# seed nothing covers → full hostname, lowercased, trailing dot stripped
|
|
([], ["https://App.Example.COM./"], ["app.example.com"]),
|
|
# seed covered by two domains → shortest covering root plus both domains
|
|
(["*.EXAMPLE.COM.", "api.example.com"], ["https://v1.api.example.com"],
|
|
["api.example.com", "example.com"]),
|
|
([], [], []),
|
|
([], ["http://[invalid"], []),
|
|
]
|
|
for patterns, seeds, expected in cases:
|
|
with self.subTest(patterns=patterns, seeds=seeds):
|
|
self.assertEqual(osint.enumeration_roots(Scope(patterns, seeds=seeds)), expected)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|