Null Pointer Dereference Detection
Detection Workflow
- Identify pointer dereferences: Find all pointer dereferences (*ptr, ptr->field), array accesses (ptr[index]), function calls with pointer parameters, pointer operations
- Trace pointer sources: Use
xrefs_to to trace pointers, find where pointers originate, identify pointer assignments, track pointer values
- Check null validation: Verify null checks before dereference, assess check completeness, identify missing validation paths, check validation logic correctness
- Assess impact: Can attacker control pointer value? Is dereference reachable? What's the crash potential? Can it lead to security issues?
Key Patterns
- Missing null checks: pointer dereference without null check, function calls with unchecked pointers, array access through null pointers, member access through null pointers
- Conditional dereference: dereference after partial null check, dereference in only some code paths, dereference after pointer assignment, dereference in loop conditions
- Function parameter issues: unchecked function parameters, assumptions about non-null parameters, missing validation in public APIs, null pointers from external sources
- Return value issues: dereferencing potentially null return values, assuming malloc/new never returns null, missing checks on function returns, dereferencing failed allocations
Output Format
Report with: id, type, subtype, severity, confidence, location, dereferenced_pointer, dereference_type, dereference_operation, pointer_source, null_check, vulnerability, exploitable, attack_scenario, impact, mitigation.
Severity Guidelines
- HIGH: Null dereference in critical code paths
- MEDIUM: Null dereference causing crashes
- LOW: Null dereference with limited impact
See Also
patterns.md - Detailed detection patterns and exploitation scenarios
examples.md - Example analysis cases and code samples
references.md - CWE references and mitigation strategies
1---
2name: detecting-null-pointer-dereference
3description: Detects null pointer dereference vulnerabilities by identifying unchecked pointer usage and missing validation. Use when analyzing pointer operations, input validation, or investigating crash vulnerabilities.
4metadata:
5 source: https://skillmd.com/skills/aibot88/detecting-null-pointer-dereference
6---
7
8# Null Pointer Dereference Detection
9
10## Detection Workflow
11
121. **Identify pointer dereferences**: Find all pointer dereferences (*ptr, ptr->field), array accesses (ptr[index]), function calls with pointer parameters, pointer operations
132. **Trace pointer sources**: Use `xrefs_to` to trace pointers, find where pointers originate, identify pointer assignments, track pointer values
143. **Check null validation**: Verify null checks before dereference, assess check completeness, identify missing validation paths, check validation logic correctness
154. **Assess impact**: Can attacker control pointer value? Is dereference reachable? What's the crash potential? Can it lead to security issues?
16
17## Key Patterns
18
19- Missing null checks: pointer dereference without null check, function calls with unchecked pointers, array access through null pointers, member access through null pointers
20- Conditional dereference: dereference after partial null check, dereference in only some code paths, dereference after pointer assignment, dereference in loop conditions
21- Function parameter issues: unchecked function parameters, assumptions about non-null parameters, missing validation in public APIs, null pointers from external sources
22- Return value issues: dereferencing potentially null return values, assuming malloc/new never returns null, missing checks on function returns, dereferencing failed allocations
23
24## Output Format
25
26Report with: id, type, subtype, severity, confidence, location, dereferenced_pointer, dereference_type, dereference_operation, pointer_source, null_check, vulnerability, exploitable, attack_scenario, impact, mitigation.
27
28## Severity Guidelines
29
30- **HIGH**: Null dereference in critical code paths
31- **MEDIUM**: Null dereference causing crashes
32- **LOW**: Null dereference with limited impact
33
34## See Also
35
36- `patterns.md` - Detailed detection patterns and exploitation scenarios
37- `examples.md` - Example analysis cases and code samples
38- `references.md` - CWE references and mitigation strategies