Skip to content

[BUG] Restrict file name length for debug mode (-srd flag) to avoid system file creation errors. #5929

@Lercas

Description

@Lercas

Is there an existing issue for this?

  • I have searched the existing issues.

Current Behavior

When the -srd flag is enabled, the WriteStoreDebugData function generates file names based on the host and template ID. If these components are too verbose, the resulting file name can exceed the operating system's maximum file name length. This causes the debug files to fail to be created, resulting in a broken debug logging experience.

Expected Behavior

File names should be truncated to a maximum length that adheres to operating system limitations, ensuring that debug files are always created successfully regardless of the length of the host or template ID.

Steps To Reproduce

  1. Enable the -srd flag during a scan.
  2. Use a host or template ID with an excessively long name.
  3. Observe that debug files are not created and an error is logged.

nuclei -t ./templates/ -list ./result/katana_result.txt -dast -dfp -im list -je ./result/nucleiGetFuzz.json -srd ./result/debug_nuclei -nc -stats -headless -fa high -debug

katana_result:

...
https://api.test.com/method/test/test.getConfig?access_token=03NNuOkyDuwHXDvL8T4Pv048AYq3Hok6oCxWWn7MZRoVEk6-pJYSHhm65omhCDrxy6KbCE9obJhbihbGH36JK732kThhH72HiuepqmnKz3bkjMQnZJerVAr0iMqNhon-05lnWAijMzsfD4tmHLFyVREmdxTe-OrrPh8E6xfuCrp9P3BbY-VbvnvTILfFoKLd7OnbIE4ucCuD1pkh7VtJ8WGjBcVJIWPXCr59nte6IQ6YBkob8w&fields=1&ids=3&owner_id=1&version=1&with_hidden=true
...

Relevant log output

No error or warning logs

Environment

- OS: MacOS 15.1
- Nuclei: v3.3.7
- Go: go1.23.0 darwin/arm64

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions