-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix multiple mem leaks + optimizations #4630
Merged
Merged
Conversation
This file contains 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
This was referenced Jan 12, 2024
Closed
This was
linked to
issues
Jan 15, 2024
Closed
POC for #4632$ wc -l /etc/hosts
920 /etc/hosts
Nuclei v3.1.5$ cmdutil nuclei
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v3.1.5
projectdiscovery.io
[INF] Current nuclei version: v3.1.5 (latest)
[INF] Current nuclei-templates version: v9.7.3 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 46
[INF] Templates loaded for current scan: 7426
[INF] Executing 7448 signed templates from projectdiscovery/nuclei-templates
[INF] No results found. Better luck next time!
------------------------------
Command: nuclei
Max RSS: 5396 MB
Sys Time: 536.258µs
User Time: 558.783µs
Actual Time: 2m3.176838083s
Voluntary Context Switch (nvcsw): 9715
This branch$ cmdutil ./nuclei
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v3.1.6-dev
projectdiscovery.io
[INF] Current nuclei version: v3.1.6-dev (development)
[INF] Current nuclei-templates version: v9.7.3 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 46
[INF] Templates loaded for current scan: 7426
[INF] Executing 7448 signed templates from projectdiscovery/nuclei-templates
[INF] No results found. Better luck next time!
------------------------------
Command: ./nuclei
Max RSS: 334 MB
Sys Time: 561.432µs
User Time: 150.796µs
Actual Time: 11.957603583s
Voluntary Context Switch (nvcsw): 8159 |
Improvements between single target scan in latest release and this PRCurrent release i.e v3.1.5------------------------------
Command: nuclei -u scanme.sh -c 100 -stats
Max RSS: 566 MB
Sys Time: 69.303µs
User Time: 746.993µs
Actual Time: 3m14.976412625s
Voluntary Context Switch (nvcsw): 755 This PRCommand: ./nuclei -u scanme.sh -c 100 -stats
Max RSS: 410 MB
Sys Time: 6.936µs
User Time: 73.32µs
Actual Time: 3m15.477689209s
Voluntary Context Switch (nvcsw): 9651
|
ehsandeep
approved these changes
Jan 18, 2024
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.
Proposed Changes
This PR brings multiple memory optimizations and fixes recently found memory leaks
Bug 1) Missing Bounds check on http response body cause over consumption of memory ( ex: if server returns 500MB response that was loaded / evaluated etc . which caused nuclei to crash)
Bug 2) Unnecessary creation of contextargs when multiprotocol/flow is not used ( i.e for normal templates )
Bug 3) skip evaluating dynamic variables after creation of request
Note
As solution for #bug3 we removed old logic because its not needed any more ( tested locally to see if the map contained any un-evaluated variables i.e
{{Path}}
etc something like that . but didn't find any.User reported that this change might have affected some functionality and some CVE results are missing but this hasn't been confimed / reproduced from our side yet
Bug4) Re-creation of fastdialer everytime we reference default client , options or transport from
retryablehttp-go
Bug5) loading hostfile everytime new fastdialer is created
Bug6) Missing bounds check on
/etc/hosts
in fastdialer and