Template structure
Use descriptive template IDs
Template IDs should clearly describe what the template detects using lowercase letters and hyphens.Template IDs must match the pattern
^([a-zA-Z0-9]+[-_])*[a-zA-Z0-9]+$ as enforced in pkg/templates/templates.go:48.Include comprehensive metadata
Every template requires completeinfo section with mandatory fields:
Add references and classification
Include external references and classification data for better context:Matchers and detection logic
Use multiple matchers for accuracy
Combine different matcher types withmatchers-condition: and to reduce false positives:
Leverage negative matchers
Usenegative: true to exclude false positives:
Be specific with word matchers
Choose unique strings that are unlikely to appear in non-vulnerable responses:Protocol-specific best practices
HTTP templates
Use appropriate HTTP methods
Use appropriate HTTP methods
Match the HTTP method to the vulnerability being tested:
Set reasonable timeouts
Set reasonable timeouts
Use the
annotation-timeout for slow operations:Handle redirects appropriately
Handle redirects appropriately
Consider whether redirects should be followed:
Code protocol templates
Code protocol templates require special handling due to security implications:Code templates are considered sensitive and must be signed before distribution.
Variables and dynamic values
Use variables for reusable values
Define variables at the template level for values used multiple times:Leverage DSL functions
Use built-in DSL functions for dynamic value generation:Extract values for multi-step requests
Capture data from responses for use in subsequent requests:Performance optimization
Minimize request count
Combine checks when possible
Use multiple matchers on a single request instead of multiple requests:
Disable path auto-merge when needed
Control path merging behavior for specific use cases:Testing and validation
Validate before testing
Always validate templates before running them:Test against multiple scenarios
- Vulnerable targets
- Safe targets
- Edge cases
Verify the template detects vulnerable instances:
Use debug mode for troubleshooting
Security considerations
Avoid destructive operations
Handle sensitive data carefully
Don’t expose credentials or sensitive information in template output:Respect rate limits
Use appropriate delays for rate-limited APIs:Documentation
Include usage examples
Add comments or description showing how to use the template:Document expected behavior
Clearly describe what constitutes a positive match and why it’s significant.
Common pitfalls to avoid
Overly broad matchers
Overly broad matchers
Problem: Matching common strings that appear in normal responses.Solution: Use multiple specific matchers with
and condition.Ignoring status codes
Ignoring status codes
Problem: Matching content without validating HTTP status.Solution: Always include status code validation.
Missing negative matchers
Missing negative matchers
Problem: False positives from error pages.Solution: Add negative matchers for common error patterns.
Hardcoded values
Hardcoded values
Problem: Using hardcoded credentials or API keys.Solution: Use variables and environment-based configuration.
Unclear template names
Unclear template names
Problem: Generic names like “test-template” or “check-1”.Solution: Use descriptive names that explain what’s being detected.
Template checklist
Before submitting or using a template, verify:✓ Template ID follows naming conventions✓ All mandatory metadata fields are present✓ Description clearly explains detection logic✓ Severity is appropriate for the vulnerability✓ Multiple matchers reduce false positives✓ Negative matchers exclude common errors✓ Template passes validation (
nuclei -validate)✓ Tested against vulnerable targets (true positives)✓ Tested against safe targets (no false positives)✓ Request count is minimized✓ No destructive operations✓ References and classification included✓ Code is well-formatted and readableNext steps
Template validation
Learn about template validation and syntax checking
Template signing
Understand template signing for code protocol templates
Contributing templates
Submit your templates to the community
Protocol reference
Explore protocol-specific features