`response_to_event_dict` crashes on repeated Content-Length headers, dropping the http batch

Open Beginner friendly
#3,678 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in bbot/core/helpers/web/response_event.py at line 43, where header_dict lowercases names, turns - into _ and joins repeats with ", " before the bare int() on content_length; that join is why "1, 1" reaches the parser. Reproduce with the two-header response in the issue, then decide how duplicate lengths should collapse to a single value. Also read handle_batch in the http module for the 429 rescheduling that a throw skips, and check wayback/lightfuzz callers. Done means the duplicate-header response yields an event and the batch keeps processing.

Written by the indexing model from the issue text.

Description

bug

response_to_event_dict (bbot/core/helpers/web/response_event.py:43) parses content_length with a bare int() on the header value. While building header_dict, it lowercases header names, turns - into _, and joins repeated headers with ", ". A response with two Content-Length headers, or with both Content-Length and Content_Length, reaches int() as "1, 1" or "1, nope" and raises ValueError.

Repeated identical Content-Length values are valid (RFC 9110, section 8.6) and blasthttp accepts them, so ordinary servers can trigger this, not only crafted responses.

In the http module the exception escapes handle_batch, so every result still left in that batch is dropped, not just the bad one. The scan logs Error in http.handle_batch(...). It also skips the end of handle_batch, so an event already held back for a 429 retry in the same batch is never rescheduled. wayback and lightfuzz call the same function.

To reproduce, serve:

HTTP/1.1 200 OK
Content-Length: 1
Content-Length: 1

X

and pass the blasthttp response to response_to_event_dict:

ValueError: invalid literal for int() with base 10: '1, 1'
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blacklanternsecurity/bbot

All issues in blacklanternsecurity/bbot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.