Replies: 3 comments
-
Beta Was this translation helpful? Give feedback.
-
|
After investigating the history, I found this behavior is actually by design, not a bug. In PR #3770, the While this is working as designed, I find the current behavior confusing when debugging templates with multiple requests since you can't see which specific requests are failing. I'd like to propose two improvements:
Example of what # Current (-ms): Shows only last failure
$ nuclei -t template.yaml -u http://example.com -ms
[template-id] [failed] [http] [info] http://example.com
# Proposed (-msr): Shows all failures
$ nuclei -t template.yaml -u http://example.com -msr
[template-id] [failed] [http] [info] http://example.com/path1
[template-id] [failed] [http] [info] http://example.com/path2
[template-id] [failed] [http] [info] http://example.com/path3This would maintain backward compatibility while providing the debugging flexibility that was originally intended in PR #3770. |
Beta Was this translation helpful? Give feedback.
-
|
@reta-ygs thanks for the suggestion! However, I don’t think -msr fits well with Nuclei’s template system. There are many edge cases this would introduce. For example:
Since Nuclei doesn’t operate at the request level and is intentionally focused on template-level configuration, adding this functionality would be inconsistent with its design. More importantly, it’s not something we could confidently maintain in the long run. For those reasons, I don’t think it’s a good idea to introduce -msr at this point. Moving this to discussion to keep it as idea for future! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
Current Behavior
When using the
-matcher-status(-ms) flag with templates containing multiple requests, only the last failed request is output when multiple or all requests fail to match. This is a regression introduced after August 2024.For example, when running a template with 3 paths that all fail to match:
-ms: No output (expected)-ms: Only 1 failure event is output (the last request)-ms: All 3 failure events should be outputThis affects both standard output and JSONL (
-j) output formats.Expected Behavior
When
-matcher-statusis enabled, ALL failed matcher results should be output, not just the last one.Standard output example:
JSONL output example:
{"template-id":"test-all-fail","host":"example.com","path":"/","matcher-status":false,...} {"template-id":"test-all-fail","host":"example.com","path":"/test","matcher-status":false,...} {"template-id":"test-all-fail","host":"example.com","path":"/admin","matcher-status":false,...}Steps To Reproduce
test-multiple-failures.yaml:-msflag (no output expected):-msflag:Observe that only one failure is shown instead of three
For JSONL output, run:
nuclei -t test-multiple-failures.yaml -u https://example.com -ms -j -silent | wc -lThis outputs
1instead of the expected3Relevant log output
Environment
Anything else?
Root Cause Analysis:
The regression was introduced in commit
cc5c5509(feat: global matchers #5701) on October 14, 2024. The bug is inpkg/tmplexec/exec.golines 184-189:The problem is that
lastMatcherEventis being set in theelseblock even whenWriteResultreturns true (successful write) ifisGlobalMatchersis true. This causes all events to overwrite the previous one, resulting in only the last event being retained.Impact:
-matcher-statusflag is commonly used for security assessments to log all attempted checksProposed Fix:
The else condition should be corrected to only set
lastMatcherEventwhenWriteResultreturns false:Beta Was this translation helpful? Give feedback.
All reactions