Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpx crashes on services generating endless stream of data #1964

Open
ocervell opened this issue Oct 21, 2024 · 0 comments
Open

httpx crashes on services generating endless stream of data #1964

ocervell opened this issue Oct 21, 2024 · 0 comments
Assignees
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@ocervell
Copy link

ocervell commented Oct 21, 2024

httpx version:

v1.6.8

Current Behavior:

httpx hangs and the machine becomes OOM when hitting a service that generates an endless stream of data (memory usage keeps growing until crash).

In my case, it is a CHARGEN UDP service running on my internet box (provider: freebox).

nmap detection:

nmap -oX /home/osboxes/.secator/reports/default/tasks/18626/.outputs/nmap.xml <REDACTED> -p 8095 --script vulners -Pn -sV -sT
Starting Nmap 7.93 ( https://nmap.org ) at 2024-10-21 19:15 EDT
Nmap scan report for [REDACTED]
Host is up (0.00053s latency).
Other addresses for X (not scanned): <REDACTED>
rDNS record for <REDACTED>
PORT     STATE SERVICE VERSION
8095/tcp open  chargen xinetd chargen
Service Info: OS: Unix
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 5.27 seconds

httpx command:

httpx -u <MYHOST>:8095  # hangs, running with -debug OOMs the machine because of the endless stream

Note that adding a --timeout 1 --retries 0 will fix the issue, as well as restricting the max body size to read (-rstr 2000) but it would be preferable to fix without as it hinders the actual issue.

This is problematic in automatic workflows as any service running a char generator or yielding an endless stream of data will crash the machine the workflow is running on.

Expected Behavior:

httpx should:

  • not store the entire response in memory, as the used memory grow with the response body size, it should stream the data directly to a file if possible (it's preferable to use a bit more disk space than memory when running in resource-constrained environments)
    OR (harder / possibly not feasible):
  • detect that the stream keeps growing and stop after a while.

Steps To Reproduce:

@ocervell ocervell added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Oct 21, 2024
@dogancanbakir dogancanbakir self-assigned this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

2 participants