Security5 min read

Security beyond the checklist in a Laravel app

One small Laravel app through the whole OWASP Top 10, one weakness at a time: named from the attacker's side, reproduced with a test, fixed at the layer that holds, measured with a scanner. Six parts, thirty attack tests, nine scanner warnings to two.

By Abhishek Fouzdar

A security checklist tells you what to add. It does not tell you what you are protecting, who from, or how the thing you added is quietly undone by next month's feature. This series takes one small Laravel application through the whole OWASP Top 10, one weakness at a time, and for each one does the thing a checklist cannot: it names the invariant from the attacker's side, writes a test that proves it, introduces the weakness the way a real codebase gets it, and fixes it at the layer that holds. Six parts, every weakness reproduced before it is fixed, every header change measured by a scanner. Laravel 13.40, PHP 8.5, MySQL 8.4, OWASP ZAP 2.17, on 4 November 2026.

The NoteMini notes list for team Acme: a search box, a sort menu, a New note button and a table of notes with author and last update

The application is NoteMini: accounts and teams, notes written in Markdown, attachments, share links, a feature that clips a web page into a note, an admin area and a JSON API. It is small enough to read in an afternoon and has, somewhere in it, every category on the list.

Who this is for

You build Laravel applications that hold one customer's data apart from another's, take uploads, render things people typed, and have an admin area and an API, and you have read the OWASP Top 10 and want to see it as code rather than as a list of nouns. Nothing is assumed about security tooling; the one scanner in the series is introduced where it first earns its place. The interview question this answers is not "what is XSS" but "show me how you would find it in this codebase and prove it is fixed", and the answer is a test that fails before it passes.

What you will end up with

The application, NoteMini, in the shipbytes/blog-examples repository, one commit per part, with two test suites, a scanner wired to run signed-in against the app, and a CI workflow that gates on the dependency audit. One suite is the ordinary feature suite. The other, tests/Attack, is written from the other side: every test does what an attacker would do and passes only when that fails.

Part OWASP 2025 What it covers
The method — the app, a threat model in one paragraph, the attack suite, the first scan
Broken Access Control A01 the id in the URL, the field in the form, the GET that changed state, the route outside its group
Injection A05 a search read as SQL, a note read as HTML, a filename read as a path, a filename read as a command
Authentication & Cryptographic A07, A04 a token hashed not stored, a password re-checked, a two-factor seed encrypted, hash versus encrypt
Misconfiguration & Integrity A02, A08 headers at the edge, debug mode, version banners, a signed link that was never checked
Supply Chain, Logging, Exceptional A03, A09, A10 composer audit as a CI gate, a security log without secrets, a write that fails closed

The numbers

A scanner cannot find most of what this series fixes, and the one number it does produce is the honest measure of that. A signed-in OWASP ZAP baseline scan at the end of each part:

After part Scanner warnings Why
1 11 the starting state: headers, version banners, cookies
2 11 access control is invisible to a passive scan
3 9 a 500 the scanner found, fixed; the injection it could not see
4 9 authentication is invisible to a passive scan too
5 2 headers at the edge, versions off, debug understood
6 2 supply chain and logging are CLI and log, not scan

The two warnings that remain are a cookie that is readable on purpose and a redirect that is Laravel working as designed; there are no failures and sixty-five of the scanner's rules pass. The attack suite went from eleven tests to thirty, the feature suite to thirty-eight, and both stayed green through every part. composer audit is clean and gated in CI.

The gap in that table is the point. The scanner found the headers and the banners, which it is better at than a person because it never forgets to check. It was blind to the access-control, injection and authentication bugs of parts 2, 3 and 4, which is most of the list, and those were caught by tests written as the attacker. A tool runs the checklist; a person writes the test the checklist could never contain.

The parts

  1. The app, the threat model, and a test suite written from the other side. The method; NoteMini as a careful team would write it; a threat model in one paragraph; the attack suite, eleven green on day one; OWASP ZAP in Docker, signed in, and the one real bug it found on the first run.
  2. Broken access control: the id in the URL, the field in the form, the route that forgot. A JSON endpoint without the policy, a profile form fed the whole request, a delete on GET, an admin route outside its group; fixed with route model binding, validated input, a DELETE form and the group, and two route-level invariants.
  3. Injection and output: SQL in the search, a script in the page, a path and a shell. One mistake in four places; bound queries, the sanitising Markdown renderer, a lookup by record instead of path, and Process in array form with no shell.
  4. Authentication and cryptographic failures: tokens, passwords and a second factor. An API token hashed, a password change that proves you are the owner now, and TOTP two-factor with the seed encrypted, a constant-time check and a rate limit; hash versus encrypt, and why each is which.
  5. Security misconfiguration and data integrity: headers, debug mode and a signed link. The headers moved to the edge so error pages carry them; version banners off; debug mode as the worst production mistake; cookies explained; a signed download link whose signature nothing checked.
  6. Supply chain, logging and the unexpected: composer audit, what to record, and failing closed. The dependency gate, the security log without the password, and the write wrapped in a transaction that fails closed; plus the whole series in one table.

The decisions

The attacker is a customer. The threat model that runs through the series is not the anonymous internet; it is Mallory, who has an account, a team, and every page the app serves to a signed-in user. She can change any id, add any field, and send any request a browser can. Most of the series is Mallory and one confidential note.

Reproduce from the other side, every time. No fix was written before a test showed the weakness, and every test in the attack suite does the misuse and passes only when it fails. The suite is green from part 1, which is the point: each later part adds a feature the way features are added, and a test goes red, and the suite is the thing that notices.

Fix at the layer that holds, and let the framework hold it. Most fixes are reaching for a tool already in Laravel: a policy, a scoped binding, a bound query, an escaped echo, an encrypted cast, a rate limiter, a signed URL, a transaction. The weakness is almost never missing knowledge; it is a new path to the data that the existing protection was never asked about.

Fail closed. The SSRF guard refuses a host it cannot prove public, the authorization denies by default, the signature check refuses what it cannot verify, and the duplicate rolls back on a missing file. A system is secure to the degree that its unexpected paths all lead to "no".

An explained scan, not a clean one. The scanner's last two warnings were left on purpose, understood and written down, because chasing them to zero would have meant breaking something useful. A clean scan reached by stripping a CSRF token's purpose is worse than a warning with a sentence next to it.

Where it stands

NoteMini keeps one team's notes from another, stores its secrets the way each kind of secret should be stored, carries its security headers on every response including the error pages, records the attacks it refuses, and fails closed on the paths it did not plan for. Its attack suite is thirty sentences an owner would want true whatever the request, and each one has been seen red. The tools are ordinary; what the series adds is the order to reach for them, and a way to know, before the breach, that the one you reached for held.

New posts by email

Get new posts by email. Nothing else, no digests, unsubscribe in one click.

Comments

Comments are GitHub Discussions in shipbytes/discussions. Sign in with GitHub to post.