Skip to content
Preptima
hardScenarioConceptMidSeniorStaff

You are told there is a memory-safety bug somewhere in a large C or C++ codebase, and you cannot read all of it. How do you narrow the search?

Start from where untrusted bytes enter, not from line one. Rank the parsers and decoders that turn attacker input into lengths and indices, build them with AddressSanitizer and UBSan, fuzz those entry points, and use crash reports and git history to point at the exact access that goes wrong.

5 min readUpdated 2026-10-09

Answer

Short answer

You narrow the search by following attacker-controlled bytes, not by reading code. A memory-safety bug matters when untrusted input can reach it. So list the entry points, rank the parsers that turn input into lengths and offsets, rebuild them with AddressSanitizer and UBSan, and aim fuzzing at those functions. Crash reports and git history then take you from a region to one line.

Was this answer helpful?

Likely follow-ups

  • The fuzzer has run for two days on your chosen parser and found nothing. What do you conclude, and what do you change?
  • AddressSanitizer reports a heap-use-after-free with three stack traces. What does each one tell you, and which do you fix?
  • The codebase routes every allocation through its own pool allocator. How do you get a sanitiser to see overflows inside it?
  • You found the bug. How do you decide whether it is exploitable or merely a crash, and does that change how fast it ships?

Related questions

Further reading

Related Topics