`_TITLE_REGEX` takes quadratic time on unclosed `<title>` tags, stalling the scan
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- performance
Research direction
Start at response_to_event_dict in bbot/core/helpers/web/response_event.py:53 and the _TITLE_REGEX compiled just above it; run the reproduction snippet in the issue to confirm the quadratic blow-up, then measure any replacement the same way. The extraction is only used for the page title, so check the other callers named in the issue (http, wayback, lightfuzz) still get the same title values. Done means a 128 KiB body of repeated <title> tags returns quickly and the existing web helper tests still pass.
Written by the indexing model from the issue text.
Description
response_to_event_dict (bbot/core/helpers/web/response_event.py:53) extracts the page title by running _TITLE_REGEX (<title[^>]*>(.*?)</title>, IGNORECASE | DOTALL) over the whole response body. On a body with many <title> tags and no </title>, every opening tag scans to the end of the body, so the search takes quadratic time.
Body (<title> repeated) |
Time |
|---|---|
| 16 KiB | 0.16 s |
| 32 KiB | 0.65 s |
| 64 KiB | 2.69 s |
| 128 KiB | 11.66 s |
The search runs synchronously on the event loop, so the whole scan stalls while it runs, not just the module. In the http module it runs before the 4xx and WAF discard, so every response pays for it. wayback and lightfuzz call the same function. Bodies can be up to 10 MiB, so a single response can stall the scan for hours.
To reproduce:
import re, time
_TITLE_REGEX = re.compile(r"<title[^>]*>(.*?)</title>", re.IGNORECASE | re.DOTALL)
body = "<title>" * (128 * 1024 // 7)
t = time.perf_counter(); _TITLE_REGEX.search(body); print(time.perf_counter() - t)
- Dominant language
- Python
- Stars
- 10.9k
- Forks
- 959
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 84
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from blacklanternsecurity/bbot
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
blacklanternsecurity/bbot#3678 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
blacklanternsecurity/bbot#3671 ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
blacklanternsecurity/bbot#3646 · 2 reactions ·
Maintainers usually reply within 2 days
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 58/100
blacklanternsecurity/bbot#3630 · 1 assignee ·
Maintainers usually reply within 2 days
-
Publish python deps for modules as optional depencency groupsPossibly taken @liquidsec claimed this 27 days ago. Openenhancement
blacklanternsecurity/bbot#3581 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
All issues in blacklanternsecurity/bbot
Similar issues
-
eegprep-lean: set channel types from the Zarr group's channel_typePossibly taken @claude claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
sccn/eegprep#668 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Link Checker ReportOpenBot Type: Bug Type: Documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day
-
area: ci enhancement perceived difficulty: 1
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Nitjsefnie-Harness-Commons/daedalus#1826 ·
Maintainers usually reply within 1 day