Read a diff like an attacker
Lesson 2 of 27 · Why generated code fails · 2 min · Free Watch this lesson freeA diff of four hundred lines is not four hundred lines of risk. A handful of lines carry almost all of it, and they share one trait.
They are the places where outside input meets something powerful, like a database, a shell or the file system. Find those, and you have reviewed the part that matters, even in a very large change.
Start at the sinks
Do not read top to bottom. Search the diff for the powerful calls, which security people call sinks. Database execution, shell calls, file opens, outbound requests, deserialisers, and anything that treats text as code, such as eval or a template built from user text.
Here is a few seconds of searching over some generated code. Four hits, four different flaws, and none of them looks wrong at a glance, because each one works.
Walk back to the source
For each hit, walk backwards. Where did this value come from? If a request, a header, an uploaded file or a model produced it, an outsider can influence it.
If it is a constant, move on. A value built from a constant plus a request field is still tainted, because the outsider controls part of it.
That is the whole technique. A tool doing it is called taint tracking. You doing it is just careful reading, and it works on code from any author.
Then look for what is missing
Sinks find the flaws that are present. Many flaws are absences. Is there an ownership check? A limit on size? A failure path that does not leak?
Read each new route once more, asking only what would stop the wrong person. If you cannot point to the exact line that does it, the honest answer is that nothing does, and that is a finding worth writing down.
What to keep
Search for sinks, trace each one back to where its value came from, then look for the checks that should exist and do not. It takes minutes and it needs no tools. Next, we draw the map of Tidepool, so you know which sources deserve your distrust.
This is the narration of a video lesson from Secure the code AI writes. In the video it is animated, and you can pause it to ask a question.