Task: Security Vulnerability Audit. You are auditing a binary for exploitable vulnerabilities.
Approach
Systematic, evidence-based. Every finding needs: location (address), root cause, impact assessment, and proof from the decompiled code.
Phase 1: Attack Surface Mapping
list_imports — identify dangerous APIs:
- Memory: memcpy, memmove, strcpy, strncpy, sprintf, vsprintf, gets
- Format strings: printf, fprintf, syslog, snprintf with user-controlled format
- Heap: malloc, free, realloc (use-after-free, double-free)
- File I/O: fopen, CreateFile, read, write (path traversal)
- Network: recv, recvfrom, WSARecv (remote input)
- Command: system, popen, execve, ShellExecute (command injection)
list_exports — identify entry points accessible to attackers
search_strings — look for format strings, SQL patterns, command templates
Phase 2: Input Tracing
For each dangerous API found:
xrefs_to on the import — find all call sites
decompile_function on each caller
- Trace backwards: where does the buffer/size/format argument come from?
- Is it user-controlled? (network input, file input, IPC, environment)
- Are there bounds checks between input and dangerous API?
Phase 3: Vulnerability Classes
Buffer Overflow (Stack)
- Fixed-size stack buffer + unbounded copy (strcpy, sprintf, gets)
- Size parameter larger than destination buffer
- Off-by-one in loop bounds writing to stack buffer
Buffer Overflow (Heap)
- malloc(user_size) without upper bound check
- memcpy into heap buffer with unchecked length
- Integer overflow in size calculation → small allocation, large copy
Format String
- printf(user_input) without format specifier
- syslog, fprintf with attacker-controlled first argument
Integer Overflow/Underflow
- Arithmetic on user-controlled sizes before allocation
- Signed/unsigned comparison mismatches in bounds checks
- Multiplication overflow in array index calculations
Use-After-Free
- free() followed by continued use of the pointer
- Dangling pointers in linked structures after partial cleanup
- Race conditions in multi-threaded free/use paths
Command Injection
- system() / popen() with string concatenation from user input
- ShellExecute with user-controlled arguments
Type Confusion
- Cast between incompatible struct types
- Virtual function table corruption paths
- Union member access after wrong variant initialization
Phase 4: Report
For each finding:
[SEVERITY] Vulnerability Type at 0xADDRESS
Function: function_name
Root cause: <description>
Input path: <how attacker-controlled data reaches the vulnerable point>
Impact: <what an attacker can achieve>
Evidence: <relevant decompiled code snippet>
Severity levels: CRITICAL (remote code execution), HIGH (local code execution, info leak), MEDIUM (DoS, limited info leak), LOW (theoretical, requires unlikely conditions).
1---2name: vulnerability-audit3description: Security audit — buffer overflows, format strings, integer issues, memory safety4---5Task: Security Vulnerability Audit. You are auditing a binary for exploitable vulnerabilities.67## Approach89Systematic, evidence-based. Every finding needs: location (address), root cause, impact assessment, and proof from the decompiled code.1011## Phase 1: Attack Surface Mapping12131. `list_imports` — identify dangerous APIs:14 - **Memory**: memcpy, memmove, strcpy, strncpy, sprintf, vsprintf, gets15 - **Format strings**: printf, fprintf, syslog, snprintf with user-controlled format16 - **Heap**: malloc, free, realloc (use-after-free, double-free)17 - **File I/O**: fopen, CreateFile, read, write (path traversal)18 - **Network**: recv, recvfrom, WSARecv (remote input)19 - **Command**: system, popen, execve, ShellExecute (command injection)202. `list_exports` — identify entry points accessible to attackers213. `search_strings` — look for format strings, SQL patterns, command templates2223## Phase 2: Input Tracing2425For each dangerous API found:261. `xrefs_to` on the import — find all call sites272. `decompile_function` on each caller283. Trace backwards: where does the buffer/size/format argument come from?294. Is it user-controlled? (network input, file input, IPC, environment)305. Are there bounds checks between input and dangerous API?3132## Phase 3: Vulnerability Classes3334**Buffer Overflow (Stack)**35- Fixed-size stack buffer + unbounded copy (strcpy, sprintf, gets)36- Size parameter larger than destination buffer37- Off-by-one in loop bounds writing to stack buffer3839**Buffer Overflow (Heap)**40- malloc(user_size) without upper bound check41- memcpy into heap buffer with unchecked length42- Integer overflow in size calculation → small allocation, large copy4344**Format String**45- printf(user_input) without format specifier46- syslog, fprintf with attacker-controlled first argument4748**Integer Overflow/Underflow**49- Arithmetic on user-controlled sizes before allocation50- Signed/unsigned comparison mismatches in bounds checks51- Multiplication overflow in array index calculations5253**Use-After-Free**54- free() followed by continued use of the pointer55- Dangling pointers in linked structures after partial cleanup56- Race conditions in multi-threaded free/use paths5758**Command Injection**59- system() / popen() with string concatenation from user input60- ShellExecute with user-controlled arguments6162**Type Confusion**63- Cast between incompatible struct types64- Virtual function table corruption paths65- Union member access after wrong variant initialization6667## Phase 4: Report6869For each finding:70```71[SEVERITY] Vulnerability Type at 0xADDRESS72Function: function_name73Root cause: <description>74Input path: <how attacker-controlled data reaches the vulnerable point>75Impact: <what an attacker can achieve>76Evidence: <relevant decompiled code snippet>77```7879Severity levels: CRITICAL (remote code execution), HIGH (local code execution, info leak), MEDIUM (DoS, limited info leak), LOW (theoretical, requires unlikely conditions).