fix(backend): prevent DoS by limiting scraper fetch payload size#95
Open
Vedhant26 wants to merge 2 commits into
Open
fix(backend): prevent DoS by limiting scraper fetch payload size#95Vedhant26 wants to merge 2 commits into
Vedhant26 wants to merge 2 commits into
Conversation
Contributor
Author
|
@avishek0769 I am ready for any constructuve criticism :) |
Owner
|
@Vedhant26 One suggestion: instead of throwing an error when the 5 MB limit is exceeded, return the data collected up to that limit. That way, the function still provides useful output rather than failing entirely once the limit is reached. |
Owner
|
@Vedhant26 Any update on this PR? |
Contributor
Author
|
Working in it , I'll reach out soon |
Owner
|
@Vedhant26 Resolve the conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Why
Calling etch(url).text() on user-provided URLs without size constraints creates an unconstrained resource consumption vulnerability (DoS). If a malicious actor inputs a URL that serves an infinite data stream or a massive multi-gigabyte file, the Node.js process attempts to buffer the entire payload into a single string. This rapidly exhausts the heap memory limit, crashing the backend API via an Out Of Memory (OOM) Panic. This fix ensures that oversized payloads are rejected and aborted before they can crash the server.
How to test
Run the backend:
�ash id="t1x9ab" pnpm run devExpected result:
Screenshots (if UI change)
N/A
Related issue
Closes #94
Pre-Submission Checklist