Zero-Day Hunting Methodology
Overview
Zero-day hunting is the systematic process of discovering previously unknown vulnerabilities in software. This requires combining multiple analysis techniques, deep understanding of common vulnerability classes, and methodical exploration of attack surfaces. Success comes from patience, persistence, and systematic methodology.
Core principle: Combine automated and manual analysis. Automated tools find low-hanging fruit; manual analysis finds complex logic flaws. Document everything.
When to Use
Use this skill when:
- Researching software for novel vulnerabilities
- Building vulnerability research capability
- Participating in bug bounty programs (in-scope targets)
- Conducting security assessments of complex systems
- Academic security research
Don't use when:
- No authorization to test the target
- Software is outside your authorized scope
- You lack resources for responsible disclosure
- You're not prepared to handle discovered vulnerabilities responsibly
The Five-Phase Methodology
Phase 1: Target Selection and Reconnaissance
Goal: Choose promising targets and understand the attack surface.
Target Selection Criteria:
Complexity Indicators
- Large codebase (more code = more bugs)
- Heavy use of C/C++ (memory unsafety)
- Complex parsing (file formats, protocols, data structures)
- Privileged operations (system calls, kernel interaction)
- Network-facing code (remote attack surface)
Historical Vulnerability Indicators
# Check CVE databases
searchsploit "target software"
# Review past vulnerabilities
# - What vulnerability classes were found?
# - Were fixes complete or partial?
# - Pattern of similar bugs suggests more exist
Attack Surface Analysis
"""
Map the attack surface:
INPUT VECTORS:
- Network protocols (HTTP, custom binary protocols)
- File formats (images, documents, archives)
- Command-line arguments
- Environment variables
- IPC mechanisms (pipes, sockets, shared memory)
- Configuration files
TRUST BOUNDARIES:
- User input → Application
- Application → System calls
- Unprivileged → Privileged contexts
- Network → Local processing
- Untrusted data → Parser
INTERESTING CODE AREAS:
- Parsers and deserializers
- Cryptographic implementations
- Authentication and authorization
- Memory management
- Privileged operations
"""
Phase 2: Static Analysis
Goal: Understand code structure and identify suspicious patterns through source code review.
Manual Code Review:
Vulnerability Pattern Recognition
// PATTERN 1: Buffer Overflow
// Look for unsafe functions with controllable size
char buffer[256];
strcpy(buffer, user_input); // ❌ No bounds check
char buffer[256];
strncpy(buffer, user_input, sizeof(buffer)-1); // ✓ Bounds checked
buffer[sizeof(buffer)-1] = '\0';
// PATTERN 2: Integer Overflow
size_t alloc_size = user_count * sizeof(struct item); // ❌ Can overflow
void *ptr = malloc(alloc_size); // Allocates small buffer, then overflow
// Better:
if (user_count > SIZE_MAX / sizeof(struct item)) {
return ERROR;
}
size_t alloc_size = user_count * sizeof(struct item);
// PATTERN 3: Use After Free
free(ptr);
// ... more code ...
ptr->field = value; // ❌ Use after free
// PATTERN 4: Format String
printf(user_input); // ❌ Format string vulnerability
printf("%s", user_input); // ✓ Safe
// PATTERN 5: Command Injection
char cmd[512];
sprintf(cmd, "ping %s", user_input); // ❌ Command injection
system(cmd);
// Better: Use execve with argument array
// PATTERN 6: Path Traversal
char filepath[256];
sprintf(filepath, "/var/data/%s", user_filename); // ❌ ../../../etc/passwd
FILE *f = fopen(filepath, "r");
// Better: Validate, sanitize, use realpath()
Automated Static Analysis
# Semgrep - pattern-based analysis
semgrep --config=auto /path/to/source/
# Cppcheck - C/C++ static analyzer
cppcheck --enable=all --inconclusive --std=c11 /path/to/source/
# CodeQL - semantic code analysis
codeql database create /tmp/db --language=cpp --source-root=/path/to/source/
codeql database analyze /tmp/db codeql/cpp-queries:codeql-suites/cpp-security-and-quality.qls
# Coverity, SonarQube (commercial but powerful)
Data Flow Analysis
"""
Trace untrusted input through the codebase:
1. Identify sources (user input points)
2. Identify sinks (dangerous operations)
3. Trace paths from sources to sinks
4. Check for validation/sanitization
Example trace:
[SOURCE] HTTP request parameter "filename"
→ parse_request()
→ extract_param("filename") // No validation
→ load_file(filename)
→ fopen(filename) // [SINK] File operation
FINDING: Path traversal vulnerability
- No validation between source and sink
- User controls filename directly
"""
Phase 3: Dynamic Analysis and Fuzzing
Goal: Trigger vulnerabilities through runtime testing and intelligent input generation.
Fuzzing Strategies:
Coverage-Guided Fuzzing
# AFL++ (American Fuzzy Lop)
# Compile with instrumentation
export CC=afl-clang-fast
export CXX=afl-clang-fast++
./configure
make clean && make
# Create seed corpus
mkdir seeds
echo "valid input 1" > seeds/seed1.txt
echo "another valid input" > seeds/seed2.txt
# Run fuzzer
afl-fuzz -i seeds -o findings -m none -- ./target @@
# Monitor for crashes
# Triage crashes: unique, exploitable, duplicate?
Protocol Fuzzing
# Boofuzz - network protocol fuzzer
from boofuzz import *
def main():
session = Session(
target=Target(
connection=SocketConnection("target.com", 8080, proto='tcp')
)
)
# Define protocol structure
s_initialize("HTTP_REQUEST")
s_static("GET ")
s_string("/", name="path", fuzzable=True)
s_static(" HTTP/1.1\r\n")
s_static("Host: ")
s_string("target.com", name="host", fuzzable=True)
s_static("\r\n\r\n")
session.connect(s_get("HTTP_REQUEST"))
session.fuzz()
if __name__ == "__main__":
main()
Structured Fuzzing
# For file formats, use structure-aware fuzzers
# Honggfuzz with dictionaries
honggfuzz -i input_corpus/ -o output/ -- ./target_binary ___FILE___
# Libfuzzer for in-process fuzzing
# Compile with -fsanitize=fuzzer
clang++ -fsanitize=fuzzer,address target_fuzzer.cpp -o fuzzer
./fuzzer corpus/ -max_len=1024
Sanitizer Integration
# AddressSanitizer (ASan) - memory errors
export CFLAGS="-fsanitize=address -g"
export CXXFLAGS="-fsanitize=address -g"
make clean && make
# UndefinedBehaviorSanitizer (UBSan)
export CFLAGS="-fsanitize=undefined -g"
# MemorySanitizer (MSan) - uninitialized memory
export CFLAGS="-fsanitize=memory -g"
# Run tests or fuzzer with sanitizers
# They will detect and report issues
Phase 4: Vulnerability Validation
Goal: Confirm discovered issues are real vulnerabilities, not false positives.
Validation Steps:
Reproduce the Bug
#!/usr/bin/env python3
# reproduce_crash.py
import subprocess
# Minimal test case that triggers the bug
malicious_input = b"A" * 1000 # From fuzzer crash
# Reproduce
with open("crash_input.bin", "wb") as f:
f.write(malicious_input)
# Run target
result = subprocess.run(
["./target", "crash_input.bin"],
capture_output=True,
timeout=5
)
if result.returncode < 0:
print(f"[+] Crashed with signal {-result.returncode}")
print(f"[*] stderr: {result.stderr.decode()}")
Minimize Test Case
# AFL test case minimization
afl-tmin -i crash_sample -o minimized_crash -- ./target @@
# Manual minimization
# - Remove bytes while maintaining crash
# - Identify minimal triggering input
# - Understand what parts of input matter
Root Cause Analysis with Debugger
# GDB with ASAN/UBSAN reports
gdb ./target
(gdb) run crash_input.bin
# When crash occurs:
(gdb) bt # Backtrace
(gdb) info registers
(gdb) x/100x $rsp # Examine stack
# Identify:
# - Type of vulnerability (overflow, UAF, etc.)
# - Root cause (specific code location)
# - Exploitability (can attacker control execution?)
Exploitability Assessment
"""
Severity Classification:
CRITICAL:
- Remote Code Execution (RCE)
- Authentication bypass in privileged service
- SQL injection in sensitive database
HIGH:
- Local privilege escalation
- Information disclosure (passwords, keys)
- Denial of Service in critical service
MEDIUM:
- XSS, CSRF in web applications
- DoS in non-critical service
- Information disclosure (non-sensitive)
LOW:
- Minor information leaks
- DoS requiring local access
- Theoretical issues with no practical exploit
Exploitability Factors:
- Can attacker trigger remotely?
- Does attacker control any registers/memory?
- Are mitigations (ASLR, NX, etc.) bypassable?
- What privileges does vulnerable process have?
"""
Phase 5: Proof of Concept and Disclosure
Goal: Create demonstrable PoC and follow responsible disclosure process.
PoC Development:
Create Proof of Concept
#!/usr/bin/env python3
"""
Proof of Concept: Buffer Overflow in parse_header()
Target: Example HTTP Server v2.1.0
Type: Stack-based buffer overflow
Impact: Remote Code Execution
This PoC demonstrates the vulnerability by crashing the server.
For responsible disclosure, does not include exploit code.
"""
import socket
import sys
def create_poc():
# Trigger vulnerability without exploitation
payload = b"A" * 300 # Exceeds buffer, causes crash
request = b"GET / HTTP/1.1\r\n"
request += b"Host: " + payload + b"\r\n"
request += b"\r\n"
return request
def main():
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <target_ip> <target_port>")
sys.exit(1)
target_ip = sys.argv[1]
target_port = int(sys.argv[2])
print(f"[*] Sending PoC to {target_ip}:{target_port}")
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((target_ip, target_port))
s.send(create_poc())
s.close()
print("[+] PoC sent. Check if target crashed.")
except Exception as e:
print(f"[-] Error: {e}")
if __name__ == "__main__":
main()
Document the Vulnerability
# Vulnerability Report: Buffer Overflow in Example HTTP Server
## Summary
A stack-based buffer overflow exists in the parse_header() function
of Example HTTP Server versions 2.0.0 through 2.1.0, allowing remote
attackers to crash the service or potentially execute arbitrary code.
## Vulnerability Details
- **Type**: Stack-based buffer overflow (CWE-121)
- **Affected Versions**: 2.0.0 - 2.1.0
- **Fixed Version**: Not yet fixed
- **CVSS Score**: 9.8 (Critical)
- **Attack Vector**: Network (Remote)
- **Authentication**: None required
## Technical Description
The vulnerability exists in `src/http_parser.c` at line 234 in the
`parse_header()` function. The function uses `strcpy()` to copy the
HTTP Host header into a fixed 256-byte stack buffer without bounds
checking:
```c
void parse_header(char *header) {
char buffer[256];
strcpy(buffer, header); // Vulnerable line
// ... rest of function
}
An attacker can send an HTTP request with a Host header exceeding
256 bytes, causing a buffer overflow that overwrites the return
address on the stack.
Impact
- Remote Code Execution: Attacker can gain complete control
- Denial of Service: Service crashes on malformed input
- Privilege Escalation: If service runs as root/SYSTEM
Proof of Concept
See attached poc_crash.py. This PoC demonstrates the crash but
does not include exploitation code.
Steps to Reproduce
- Start Example HTTP Server v2.1.0
- Run:
python3 poc_crash.py 127.0.0.1 8080
- Observe server crash with segmentation fault
Recommended Fix
Replace strcpy() with bounds-checked alternative:
void parse_header(char *header) {
char buffer[256];
strncpy(buffer, header, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = '\0';
// ... rest of function
}
Timeline
- YYYY-MM-DD: Vulnerability discovered
- YYYY-MM-DD: Vendor notified
- YYYY-MM-DD+90: Public disclosure (if not fixed)
Credits
Discovered by: [Your Name]
Contact: [your.email@example.com]
```
Responsible Disclosure Process:
Initial Contact
Subject: Security Vulnerability Report - Example HTTP Server
Dear Security Team,
I have discovered a security vulnerability in Example HTTP Server
that could allow remote code execution. I would like to report this
through your responsible disclosure program.
Please confirm receipt of this email and provide instructions for
submitting the detailed vulnerability report.
Thank you,
[Your Name]
Follow Timeline
- Day 0: Report to vendor
- Day 7: Follow up if no response
- Day 14: Follow up again, consider alternate contacts
- Day 30: Check on status, patch development
- Day 90: Standard public disclosure timeline
- Coordinate: Vendor may request extension
Public Disclosure
- Wait for vendor patch (or 90 days)
- Publish advisory with CVE if assigned
- Share PoC (non-weaponized)
- Update bug bounty platform if applicable
Specialized Techniques
1. Differential Testing
# Compare behavior of different implementations
# Inconsistencies may indicate bugs
def test_parsers():
test_inputs = generate_edge_cases()
for input_data in test_inputs:
result_a = parser_implementation_a(input_data)
result_b = parser_implementation_b(input_data)
if result_a != result_b:
print(f"Inconsistency found: {input_data}")
# Investigate which is correct
2. Symbolic Execution
# Use angr or other symbolic execution tools
# to explore program paths
python3 -c '
import angr
project = angr.Project("./target")
state = project.factory.entry_state()
simgr = project.factory.simulation_manager(state)
simgr.explore(find=0x401234, avoid=0x401500)
if simgr.found:
print("Found path:", simgr.found[0].posix.dumps(0))
'
3. Kernel Vulnerability Research
# Requires deep knowledge, use with caution
# syzkaller - kernel fuzzer
git clone https://github.com/google/syzkaller
# Configure for your kernel
# Run fuzzer
./bin/syz-manager -config my.cfg
# Analyze crashes, develop exploits
# Kernel vulns have high impact
Tool Ecosystem
Static Analysis:
- Semgrep, CodeQL (pattern matching)
- Cppcheck, Clang Static Analyzer
- Coverity, SonarQube (commercial)
Fuzzing:
- AFL++, libFuzzer (coverage-guided)
- Honggfuzz (feedback-driven)
- Boofuzz, Peach (protocol fuzzing)
Dynamic Analysis:
- Valgrind (memory debugging)
- ASan, MSan, UBSan (sanitizers)
- GDB, WinDbg (debuggers)
Binary Analysis:
- Ghidra, IDA Pro (reverse engineering)
- Binary Ninja (analysis platform)
- radare2 (open-source RE)
Common Pitfalls
| Mistake |
Impact |
Solution |
| Targeting wrong software |
Wasted effort |
Select based on complexity, exposure |
| Relying only on fuzzing |
Miss logic flaws |
Combine fuzzing with manual review |
| Not triaging crashes |
False positives, duplicates |
Analyze each crash, group similar |
| Premature disclosure |
Vendor can't patch, users at risk |
Follow 90-day disclosure timeline |
| Poor documentation |
Can't reproduce/fix |
Document thoroughly with PoC |
| Weaponizing exploits |
Ethical/legal issues |
Create PoCs only, not weaponized |
Legal and Ethical Considerations
CRITICAL - Always follow these rules:
Authorization
- Only research authorized targets
- Bug bounties have clear scope
- Open source research is generally OK
- Closed source requires permission
Responsible Disclosure
- Report to vendor first
- Follow coordinated disclosure
- Don't weaponize or release exploits publicly
- Consider CERT/CC for coordination
Handle Data Responsibly
- Don't access user data
- Don't cause damage
- Test in isolated environments
Know the Law
- CFAA (US), Computer Misuse Act (UK)
- Local laws on security research
- Safe harbor provisions
Integration with Other Skills
This skill works with:
- skills/analysis/static-vuln-analysis - Core technique
- skills/analysis/binary-analysis - For closed-source targets
- skills/exploitation/exploit-dev-workflow - Next step after discovery
- skills/documentation/* - Document findings
- skills/automation/* - Automate discovery pipelines
Success Metrics
Successful zero-day hunting should:
- Use systematic methodology
- Discover genuine vulnerabilities
- Properly assess severity/exploitability
- Follow responsible disclosure
- Document findings thoroughly
- Contribute to software security
References and Further Reading
- "The Art of Software Security Assessment" by Dowd, McDonald, Schuh
- "Fuzzing: Brute Force Vulnerability Discovery" by Sutton, Greene, Amini
- "A Bug Hunter's Diary" by Tobias Klein
- Google Project Zero blog
- Trail of Bits security research
- AFL and fuzzing documentation
- CVE database for learning from past vulnerabilities
1---2name: zero-day-hunting-methodology3description: Systematic approach to discovering novel vulnerabilities through code analysis, fuzzing, and attack surface research4---56# Zero-Day Hunting Methodology78## Overview910Zero-day hunting is the systematic process of discovering previously unknown vulnerabilities in software. This requires combining multiple analysis techniques, deep understanding of common vulnerability classes, and methodical exploration of attack surfaces. Success comes from patience, persistence, and systematic methodology.1112**Core principle:** Combine automated and manual analysis. Automated tools find low-hanging fruit; manual analysis finds complex logic flaws. Document everything.1314## When to Use1516Use this skill when:17- Researching software for novel vulnerabilities18- Building vulnerability research capability19- Participating in bug bounty programs (in-scope targets)20- Conducting security assessments of complex systems21- Academic security research2223**Don't use when:**24- No authorization to test the target25- Software is outside your authorized scope26- You lack resources for responsible disclosure27- You're not prepared to handle discovered vulnerabilities responsibly2829## The Five-Phase Methodology3031### Phase 1: Target Selection and Reconnaissance3233**Goal:** Choose promising targets and understand the attack surface.3435**Target Selection Criteria:**36371. **Complexity Indicators**38 - Large codebase (more code = more bugs)39 - Heavy use of C/C++ (memory unsafety)40 - Complex parsing (file formats, protocols, data structures)41 - Privileged operations (system calls, kernel interaction)42 - Network-facing code (remote attack surface)43442. **Historical Vulnerability Indicators**45 ```bash46 # Check CVE databases47 searchsploit "target software"48 49 # Review past vulnerabilities50 # - What vulnerability classes were found?51 # - Were fixes complete or partial?52 # - Pattern of similar bugs suggests more exist53 ```54553. **Attack Surface Analysis**56 ```python57 """58 Map the attack surface:59 60 INPUT VECTORS:61 - Network protocols (HTTP, custom binary protocols)62 - File formats (images, documents, archives)63 - Command-line arguments64 - Environment variables65 - IPC mechanisms (pipes, sockets, shared memory)66 - Configuration files67 68 TRUST BOUNDARIES:69 - User input → Application70 - Application → System calls71 - Unprivileged → Privileged contexts72 - Network → Local processing73 - Untrusted data → Parser74 75 INTERESTING CODE AREAS:76 - Parsers and deserializers77 - Cryptographic implementations78 - Authentication and authorization79 - Memory management80 - Privileged operations81 """82 ```8384### Phase 2: Static Analysis8586**Goal:** Understand code structure and identify suspicious patterns through source code review.8788**Manual Code Review:**89901. **Vulnerability Pattern Recognition**91 ```c92 // PATTERN 1: Buffer Overflow93 // Look for unsafe functions with controllable size94 char buffer[256];95 strcpy(buffer, user_input); // ❌ No bounds check96 97 char buffer[256];98 strncpy(buffer, user_input, sizeof(buffer)-1); // ✓ Bounds checked99 buffer[sizeof(buffer)-1] = '\0';100 101 // PATTERN 2: Integer Overflow102 size_t alloc_size = user_count * sizeof(struct item); // ❌ Can overflow103 void *ptr = malloc(alloc_size); // Allocates small buffer, then overflow104 105 // Better:106 if (user_count > SIZE_MAX / sizeof(struct item)) {107 return ERROR;108 }109 size_t alloc_size = user_count * sizeof(struct item);110 111 // PATTERN 3: Use After Free112 free(ptr);113 // ... more code ...114 ptr->field = value; // ❌ Use after free115 116 // PATTERN 4: Format String117 printf(user_input); // ❌ Format string vulnerability118 printf("%s", user_input); // ✓ Safe119 120 // PATTERN 5: Command Injection121 char cmd[512];122 sprintf(cmd, "ping %s", user_input); // ❌ Command injection123 system(cmd);124 125 // Better: Use execve with argument array126 127 // PATTERN 6: Path Traversal128 char filepath[256];129 sprintf(filepath, "/var/data/%s", user_filename); // ❌ ../../../etc/passwd130 FILE *f = fopen(filepath, "r");131 132 // Better: Validate, sanitize, use realpath()133 ```1341352. **Automated Static Analysis**136 ```bash137 # Semgrep - pattern-based analysis138 semgrep --config=auto /path/to/source/139 140 # Cppcheck - C/C++ static analyzer141 cppcheck --enable=all --inconclusive --std=c11 /path/to/source/142 143 # CodeQL - semantic code analysis144 codeql database create /tmp/db --language=cpp --source-root=/path/to/source/145 codeql database analyze /tmp/db codeql/cpp-queries:codeql-suites/cpp-security-and-quality.qls146 147 # Coverity, SonarQube (commercial but powerful)148 ```1491503. **Data Flow Analysis**151 ```python152 """153 Trace untrusted input through the codebase:154 155 1. Identify sources (user input points)156 2. Identify sinks (dangerous operations)157 3. Trace paths from sources to sinks158 4. Check for validation/sanitization159 160 Example trace:161 [SOURCE] HTTP request parameter "filename"162 → parse_request()163 → extract_param("filename") // No validation164 → load_file(filename)165 → fopen(filename) // [SINK] File operation166 167 FINDING: Path traversal vulnerability168 - No validation between source and sink169 - User controls filename directly170 """171 ```172173### Phase 3: Dynamic Analysis and Fuzzing174175**Goal:** Trigger vulnerabilities through runtime testing and intelligent input generation.176177**Fuzzing Strategies:**1781791. **Coverage-Guided Fuzzing**180 ```bash181 # AFL++ (American Fuzzy Lop)182 # Compile with instrumentation183 export CC=afl-clang-fast184 export CXX=afl-clang-fast++185 ./configure186 make clean && make187 188 # Create seed corpus189 mkdir seeds190 echo "valid input 1" > seeds/seed1.txt191 echo "another valid input" > seeds/seed2.txt192 193 # Run fuzzer194 afl-fuzz -i seeds -o findings -m none -- ./target @@195 196 # Monitor for crashes197 # Triage crashes: unique, exploitable, duplicate?198 ```1992002. **Protocol Fuzzing**201 ```python202 # Boofuzz - network protocol fuzzer203 from boofuzz import *204 205 def main():206 session = Session(207 target=Target(208 connection=SocketConnection("target.com", 8080, proto='tcp')209 )210 )211 212 # Define protocol structure213 s_initialize("HTTP_REQUEST")214 s_static("GET ")215 s_string("/", name="path", fuzzable=True)216 s_static(" HTTP/1.1\r\n")217 s_static("Host: ")218 s_string("target.com", name="host", fuzzable=True)219 s_static("\r\n\r\n")220 221 session.connect(s_get("HTTP_REQUEST"))222 session.fuzz()223 224 if __name__ == "__main__":225 main()226 ```2272283. **Structured Fuzzing**229 ```bash230 # For file formats, use structure-aware fuzzers231 232 # Honggfuzz with dictionaries233 honggfuzz -i input_corpus/ -o output/ -- ./target_binary ___FILE___234 235 # Libfuzzer for in-process fuzzing236 # Compile with -fsanitize=fuzzer237 clang++ -fsanitize=fuzzer,address target_fuzzer.cpp -o fuzzer238 ./fuzzer corpus/ -max_len=1024239 ```2402414. **Sanitizer Integration**242 ```bash243 # AddressSanitizer (ASan) - memory errors244 export CFLAGS="-fsanitize=address -g"245 export CXXFLAGS="-fsanitize=address -g"246 make clean && make247 248 # UndefinedBehaviorSanitizer (UBSan)249 export CFLAGS="-fsanitize=undefined -g"250 251 # MemorySanitizer (MSan) - uninitialized memory252 export CFLAGS="-fsanitize=memory -g"253 254 # Run tests or fuzzer with sanitizers255 # They will detect and report issues256 ```257258### Phase 4: Vulnerability Validation259260**Goal:** Confirm discovered issues are real vulnerabilities, not false positives.261262**Validation Steps:**2632641. **Reproduce the Bug**265 ```python266 #!/usr/bin/env python3267 # reproduce_crash.py268 269 import subprocess270 271 # Minimal test case that triggers the bug272 malicious_input = b"A" * 1000 # From fuzzer crash273 274 # Reproduce275 with open("crash_input.bin", "wb") as f:276 f.write(malicious_input)277 278 # Run target279 result = subprocess.run(280 ["./target", "crash_input.bin"],281 capture_output=True,282 timeout=5283 )284 285 if result.returncode < 0:286 print(f"[+] Crashed with signal {-result.returncode}")287 print(f"[*] stderr: {result.stderr.decode()}")288 ```2892902. **Minimize Test Case**291 ```bash292 # AFL test case minimization293 afl-tmin -i crash_sample -o minimized_crash -- ./target @@294 295 # Manual minimization296 # - Remove bytes while maintaining crash297 # - Identify minimal triggering input298 # - Understand what parts of input matter299 ```3003013. **Root Cause Analysis with Debugger**302 ```bash303 # GDB with ASAN/UBSAN reports304 gdb ./target305 (gdb) run crash_input.bin306 307 # When crash occurs:308 (gdb) bt # Backtrace309 (gdb) info registers310 (gdb) x/100x $rsp # Examine stack311 312 # Identify:313 # - Type of vulnerability (overflow, UAF, etc.)314 # - Root cause (specific code location)315 # - Exploitability (can attacker control execution?)316 ```3173184. **Exploitability Assessment**319 ```python320 """321 Severity Classification:322 323 CRITICAL:324 - Remote Code Execution (RCE)325 - Authentication bypass in privileged service326 - SQL injection in sensitive database327 328 HIGH:329 - Local privilege escalation330 - Information disclosure (passwords, keys)331 - Denial of Service in critical service332 333 MEDIUM:334 - XSS, CSRF in web applications335 - DoS in non-critical service336 - Information disclosure (non-sensitive)337 338 LOW:339 - Minor information leaks340 - DoS requiring local access341 - Theoretical issues with no practical exploit342 343 Exploitability Factors:344 - Can attacker trigger remotely?345 - Does attacker control any registers/memory?346 - Are mitigations (ASLR, NX, etc.) bypassable?347 - What privileges does vulnerable process have?348 """349 ```350351### Phase 5: Proof of Concept and Disclosure352353**Goal:** Create demonstrable PoC and follow responsible disclosure process.354355**PoC Development:**3563571. **Create Proof of Concept**358 ```python359 #!/usr/bin/env python3360 """361 Proof of Concept: Buffer Overflow in parse_header()362 363 Target: Example HTTP Server v2.1.0364 Type: Stack-based buffer overflow365 Impact: Remote Code Execution366 367 This PoC demonstrates the vulnerability by crashing the server.368 For responsible disclosure, does not include exploit code.369 """370 371 import socket372 import sys373 374 def create_poc():375 # Trigger vulnerability without exploitation376 payload = b"A" * 300 # Exceeds buffer, causes crash377 378 request = b"GET / HTTP/1.1\r\n"379 request += b"Host: " + payload + b"\r\n"380 request += b"\r\n"381 382 return request383 384 def main():385 if len(sys.argv) != 3:386 print(f"Usage: {sys.argv[0]} <target_ip> <target_port>")387 sys.exit(1)388 389 target_ip = sys.argv[1]390 target_port = int(sys.argv[2])391 392 print(f"[*] Sending PoC to {target_ip}:{target_port}")393 394 try:395 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)396 s.connect((target_ip, target_port))397 s.send(create_poc())398 s.close()399 print("[+] PoC sent. Check if target crashed.")400 except Exception as e:401 print(f"[-] Error: {e}")402 403 if __name__ == "__main__":404 main()405 ```4064072. **Document the Vulnerability**408 ```markdown409 # Vulnerability Report: Buffer Overflow in Example HTTP Server410 411 ## Summary412 A stack-based buffer overflow exists in the parse_header() function413 of Example HTTP Server versions 2.0.0 through 2.1.0, allowing remote414 attackers to crash the service or potentially execute arbitrary code.415 416 ## Vulnerability Details417 - **Type**: Stack-based buffer overflow (CWE-121)418 - **Affected Versions**: 2.0.0 - 2.1.0419 - **Fixed Version**: Not yet fixed420 - **CVSS Score**: 9.8 (Critical)421 - **Attack Vector**: Network (Remote)422 - **Authentication**: None required423 424 ## Technical Description425 The vulnerability exists in `src/http_parser.c` at line 234 in the426 `parse_header()` function. The function uses `strcpy()` to copy the427 HTTP Host header into a fixed 256-byte stack buffer without bounds428 checking:429 430 ```c431 void parse_header(char *header) {432 char buffer[256];433 strcpy(buffer, header); // Vulnerable line434 // ... rest of function435 }436 ```437 438 An attacker can send an HTTP request with a Host header exceeding439 256 bytes, causing a buffer overflow that overwrites the return440 address on the stack.441 442 ## Impact443 - **Remote Code Execution**: Attacker can gain complete control444 - **Denial of Service**: Service crashes on malformed input445 - **Privilege Escalation**: If service runs as root/SYSTEM446 447 ## Proof of Concept448 See attached `poc_crash.py`. This PoC demonstrates the crash but449 does not include exploitation code.450 451 ## Steps to Reproduce452 1. Start Example HTTP Server v2.1.0453 2. Run: `python3 poc_crash.py 127.0.0.1 8080`454 3. Observe server crash with segmentation fault455 456 ## Recommended Fix457 Replace `strcpy()` with bounds-checked alternative:458 459 ```c460 void parse_header(char *header) {461 char buffer[256];462 strncpy(buffer, header, sizeof(buffer) - 1);463 buffer[sizeof(buffer) - 1] = '\0';464 // ... rest of function465 }466 ```467 468 ## Timeline469 - YYYY-MM-DD: Vulnerability discovered470 - YYYY-MM-DD: Vendor notified471 - YYYY-MM-DD+90: Public disclosure (if not fixed)472 473 ## Credits474 Discovered by: [Your Name]475 Contact: [your.email@example.com]476 ```477478**Responsible Disclosure Process:**4794801. **Initial Contact**481 ```482 Subject: Security Vulnerability Report - Example HTTP Server483 484 Dear Security Team,485 486 I have discovered a security vulnerability in Example HTTP Server487 that could allow remote code execution. I would like to report this488 through your responsible disclosure program.489 490 Please confirm receipt of this email and provide instructions for491 submitting the detailed vulnerability report.492 493 Thank you,494 [Your Name]495 ```4964972. **Follow Timeline**498 - Day 0: Report to vendor499 - Day 7: Follow up if no response500 - Day 14: Follow up again, consider alternate contacts501 - Day 30: Check on status, patch development502 - Day 90: Standard public disclosure timeline503 - Coordinate: Vendor may request extension5045053. **Public Disclosure**506 - Wait for vendor patch (or 90 days)507 - Publish advisory with CVE if assigned508 - Share PoC (non-weaponized)509 - Update bug bounty platform if applicable510511## Specialized Techniques512513**1. Differential Testing**514```python515# Compare behavior of different implementations516# Inconsistencies may indicate bugs517518def test_parsers():519 test_inputs = generate_edge_cases()520 521 for input_data in test_inputs:522 result_a = parser_implementation_a(input_data)523 result_b = parser_implementation_b(input_data)524 525 if result_a != result_b:526 print(f"Inconsistency found: {input_data}")527 # Investigate which is correct528```529530**2. Symbolic Execution**531```bash532# Use angr or other symbolic execution tools533# to explore program paths534535python3 -c '536import angr537project = angr.Project("./target")538state = project.factory.entry_state()539simgr = project.factory.simulation_manager(state)540simgr.explore(find=0x401234, avoid=0x401500)541if simgr.found:542 print("Found path:", simgr.found[0].posix.dumps(0))543'544```545546**3. Kernel Vulnerability Research**547```bash548# Requires deep knowledge, use with caution549550# syzkaller - kernel fuzzer551git clone https://github.com/google/syzkaller552# Configure for your kernel553# Run fuzzer554./bin/syz-manager -config my.cfg555556# Analyze crashes, develop exploits557# Kernel vulns have high impact558```559560## Tool Ecosystem561562**Static Analysis:**563- Semgrep, CodeQL (pattern matching)564- Cppcheck, Clang Static Analyzer565- Coverity, SonarQube (commercial)566567**Fuzzing:**568- AFL++, libFuzzer (coverage-guided)569- Honggfuzz (feedback-driven)570- Boofuzz, Peach (protocol fuzzing)571572**Dynamic Analysis:**573- Valgrind (memory debugging)574- ASan, MSan, UBSan (sanitizers)575- GDB, WinDbg (debuggers)576577**Binary Analysis:**578- Ghidra, IDA Pro (reverse engineering)579- Binary Ninja (analysis platform)580- radare2 (open-source RE)581582## Common Pitfalls583584| Mistake | Impact | Solution |585|---------|--------|----------|586| Targeting wrong software | Wasted effort | Select based on complexity, exposure |587| Relying only on fuzzing | Miss logic flaws | Combine fuzzing with manual review |588| Not triaging crashes | False positives, duplicates | Analyze each crash, group similar |589| Premature disclosure | Vendor can't patch, users at risk | Follow 90-day disclosure timeline |590| Poor documentation | Can't reproduce/fix | Document thoroughly with PoC |591| Weaponizing exploits | Ethical/legal issues | Create PoCs only, not weaponized |592593## Legal and Ethical Considerations594595**CRITICAL - Always follow these rules:**5965971. **Authorization**598 - Only research authorized targets599 - Bug bounties have clear scope600 - Open source research is generally OK601 - Closed source requires permission6026032. **Responsible Disclosure**604 - Report to vendor first605 - Follow coordinated disclosure606 - Don't weaponize or release exploits publicly607 - Consider CERT/CC for coordination6086093. **Handle Data Responsibly**610 - Don't access user data611 - Don't cause damage612 - Test in isolated environments6136144. **Know the Law**615 - CFAA (US), Computer Misuse Act (UK)616 - Local laws on security research617 - Safe harbor provisions618619## Integration with Other Skills620621This skill works with:622- skills/analysis/static-vuln-analysis - Core technique623- skills/analysis/binary-analysis - For closed-source targets624- skills/exploitation/exploit-dev-workflow - Next step after discovery625- skills/documentation/* - Document findings626- skills/automation/* - Automate discovery pipelines627628## Success Metrics629630Successful zero-day hunting should:631- Use systematic methodology632- Discover genuine vulnerabilities633- Properly assess severity/exploitability634- Follow responsible disclosure635- Document findings thoroughly636- Contribute to software security637638## References and Further Reading639640- "The Art of Software Security Assessment" by Dowd, McDonald, Schuh641- "Fuzzing: Brute Force Vulnerability Discovery" by Sutton, Greene, Amini642- "A Bug Hunter's Diary" by Tobias Klein643- Google Project Zero blog644- Trail of Bits security research645- AFL and fuzzing documentation646- CVE database for learning from past vulnerabilities