Skip to content

collapse PTR-style floods in chaos response#3115

Merged
liquidsec merged 5 commits into
devfrom
chaos-collapse-flood
Jun 9, 2026
Merged

collapse PTR-style floods in chaos response#3115
liquidsec merged 5 commits into
devfrom
chaos-collapse-flood

Conversation

@liquidsec

Copy link
Copy Markdown
Collaborator

Summary

Chaos sometimes returns over a million subdomains for a single domain — typically ISP reverse-DNS explosions where every customer IP has a PTR record under the same parent. Today bbot pushes every one of those names through the pipeline, causing huge memory use and effectively DoSing the scan.

  • Drop subdomains whose leading segments look like IPv4 octets (dotted or hyphenated). These are domain-agnostic regexes catching the most common PTR shape, e.g. 001.106.103.218.foo and 000-1-246-220.foo.
  • After filtering, group surviving names by immediate parent. If a parent has more than PER_PARENT_CAP (300) children, drop them and emit just the parent. We deliberately do NOT assert wildcard ourselves — bbot's standard DNS wildcard detection runs on the parent and rewrites the event to _wildcard.<parent> if it actually is wildcard. If it isn't (e.g. ISP PTRs that all resolve to distinct IPs), we just lose the noisy children, which we couldn't usefully enumerate anyway.
  • Run the filter/group/collapse in the CPU executor (run_in_executor_cpu) so processing >1M string entries doesn't block the event loop.

PER_PARENT_CAP is set to 300 after looking at the parent-size distribution on a known noisy domain: the histogram is bimodal — parents are either small (≤49 children, real subdomain clusters) or massive (≥462 children, PTR explosions). 300 is the safe middle.

Resolves #2879.

Chaos sometimes returns more than a million subdomains for a single
domain, typically ISP reverse-DNS explosions. Without intervention this
floods the event pipeline.

- Drop subdomains whose leading segments look like IPv4 octets (dotted
  or hyphenated), the most common PTR-record shape.
- After filtering, group surviving names by immediate parent. If a
  parent has more than PER_PARENT_CAP (300) children, drop them and
  emit just the parent — let bbot's normal DNS wildcard detection
  decide whether it actually is wildcard, rather than asserting it
  from chaos's evidence alone.
- Run the filter/group/collapse in the CPU executor so processing
  large responses doesn't block the event loop.

Resolves #2879.
Comment thread bbot/test/test_step_2/module_tests/test_module_chaos.py Dismissed
Comment thread bbot/test/test_step_2/module_tests/test_module_chaos.py Dismissed
@liquidsec liquidsec requested a review from ausmaster May 20, 2026 16:35
@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Performance Benchmark Report

⚠️ No current benchmark data available

This might be because:

  • Benchmarks failed to run
  • No benchmark tests found
  • Dependencies missing

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.50562% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91%. Comparing base (1256454) to head (8088ab2).
⚠️ Report is 81 commits behind head on dev.

Files with missing lines Patch % Lines
bbot/modules/chaos.py 91% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             dev   #3115     +/-   ##
=======================================
+ Coverage     90%     91%     +1%     
=======================================
  Files        447     448      +1     
  Lines      40462   42611   +2149     
=======================================
+ Hits       36320   38355   +2035     
- Misses      4142    4256    +114     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

liquidsec added 2 commits May 21, 2026 08:16
- Skip per-parent cap when parent == query (apex), so >300
  direct-apex subdomains are not silently dropped
- Require exactly 4 groups of 1-3 digits in PTR patterns,
  preventing false positives on date-prefixed names
- Add TestChaosApexFlood and date-survival assertion
Comment thread bbot/test/test_step_2/module_tests/test_module_chaos.py Dismissed
Comment thread bbot/test/test_step_2/module_tests/test_module_chaos.py Dismissed
liquidsec added 2 commits June 8, 2026 19:45
Deduplicate children per parent (set instead of list) so duplicates
from the chaos API don't inflate the per-parent cap count and silently
drop legitimate subdomains.
@liquidsec liquidsec merged commit d207be7 into dev Jun 9, 2026
18 checks passed
@liquidsec liquidsec mentioned this pull request Jun 9, 2026
@ausmaster ausmaster deleted the chaos-collapse-flood branch June 11, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants