Given a repository and a few days, the instinct is to start at the top and read. That approach finds very little, because security bugs are not evenly distributed — they cluster where data crosses a trust boundary and where authorisation decisions are made.
Start by mapping, not reading
Spend the first hours building a picture:
- Entry points. Every route, API endpoint, queue consumer, scheduled job and webhook. This is the full attack surface and it is usually larger than the team remembers.
- The authentication and authorisation model. How is identity established, where is it stored, and how is a permission check expressed in this codebase?
- Trust boundaries. Where does data arrive from a user, a third party, or another service?
- The sensitive operations. Payments, personal data, administrative actions, file handling, anything touching credentials.
Now read, starting at the highest-value entry points.
Follow data forwards, follow sinks backwards
Two complementary passes.
Forwards: take an input and trace it. Where does it go, what validates it, what transforms it, where does it end up? Validation that happens on one path and not another is a frequent finding, especially where an endpoint was added later.
Backwards: search for dangerous operations — query execution, command execution, deserialisation, file path construction, template rendering, redirects — and trace each input back to its source. This pass is faster and usually finds more, because there are fewer sinks than inputs.
Authorisation is where the real findings are
Injection flaws get the attention, but in modern frameworks parameterised queries are the default and the obvious cases are gone. Authorisation has no equivalent default, because only the application knows who should see what.
The pattern to hunt:
$order = Order::find($request->id);
return view('order', ['order' => $order]);
Authenticated, so it passes a login check. Nowhere does it confirm the order belongs to the requesting user. Change the identifier and read somebody else's data.
Search for every retrieval by identifier and ask, for each, where ownership is verified. Where an application has hundreds of such calls, the ones missing the check are rarely the ones anybody remembers writing.
Also check vertical escalation: a user-facing route that accepts an extra parameter, a role field accepted from a registration form, an administrative function whose only protection is that the link is not displayed.
What static analysis will and will not give you
Run it, because it covers ground quickly and finds the mechanical issues — hardcoded secrets, known-vulnerable dependencies, unsafe functions, missing output encoding.
It will not find authorisation bugs, because it cannot know who should be allowed to do what. It will not find business logic flaws — a discount applied twice, a negative quantity, a workflow step that can be skipped. Those require someone who understands what the application is supposed to do.
Treat the tool as the first pass that clears the noise, then spend human time where the tool is structurally blind.
Read the history, not just the code
Version control is an under-used source. Look for secrets committed and later removed — still present in history and still valid surprisingly often. Look for commits described as quick fixes near authentication code. Look for files that change constantly, which indicates complexity and therefore bugs.
Report causes, not instances
Finding nineteen endpoints missing an ownership check and listing nineteen findings produces nineteen patches and a twentieth endpoint with the same bug next month.
Report it once, as the pattern: the codebase has no enforced authorisation layer, here are nineteen current examples, and the fix is a central check applied at the data access layer. That turns a list of bugs into a design change that closes the class.
0 comments
Leave a comment