Understanding Security in Your SaaS
One customer reading another customer’s invoices. A test login left on in the live app. A bot running up your AI bill. No scanner flags these, and any one of them can cost you a customer’s trust.
Most security guides start with tools. Tools are the easy part. The hard part is knowing what you are testing for. A scanner can tell you a package is old. It cannot tell you that one customer can read another customer’s invoices.
This page is the “what” behind my security audit toolkit. That post says how I ran the checks. This one says what each check is looking for, and why it comes where it does.
You don’t need to learn all twelve areas. I check each one on your app and tell you, in plain words, which ones fail and what fixing them involves.
The Technical tab has the proper names, the attack types and the checks in code terms.
Start here: what are you protecting, and from whom?
Before testing anything, write down two lists.
What is worth stealing or breaking. Customer data. Money. Accounts. The admin side. Your bills for AI, email or hosting.
Who might try. A stranger on the internet. A paying customer who wants more than they paid for. A customer curious about another customer. A bot. Someone who gets into your own email. And you, by mistake.
That second list matters more than people think. In my own audit, none of the real problems were clever hacks. They were missing rules and honest mistakes.
This is called a threat model. Mine is one short table: who, what they want, what stops them today, what is still open. Every area below is a way to fill in that table.
The twelve areas, in order
The order is by where the damage usually is in a small SaaS. The first five are where real problems hide. Tools barely see them.
1. Sign-in: who are you?
What it is: proving a person is who they say they are. Passwords, sign-in links, Google sign-in, two-step codes, and the “session” that keeps you signed in after.
What goes wrong:
- a password reset link that works forever, or works twice
- a session that never ends, so a stolen laptop stays signed in
- a test login left switched on in the live app
- no limit on password guesses
How to check: try every way in. Sign in, sign out, reset, use an old link, use someone else’s link. Check that test logins only work on a developer’s machine.
Most small apps hand sign-in to a service built for it. That is a good choice. It does not remove the need to check how your app uses it.
In my audit, all 65 doors into the app refused a visitor who was not signed in. A weekly review of the same app still found a sign-in link that could send someone to another site. It has since been fixed.
2. Permissions: what are you allowed to do?
What it is: after the app knows who you are, it decides what you can see and change. A customer sees their own data. An admin sees the admin pages. A free user does not get paid features.
This is the number one problem in web apps. It has topped the main industry list of web risks for years.
What goes wrong:
- changing the number in the address. You open
/invoices/1041. You change it to/invoices/1042. If the app does not check that 1042 is yours, you are reading someone else’s invoice. - an admin page that hides the button but not the page behind it
- a page that checks permissions, but the data request behind it does not
- a “delete” that checks who owns the item when you open it, but not when you press delete
How to check: make two fake customers. As customer A, try to read and change every one of customer B’s things. Every attempt should fail. Then turn that into an automatic test.
In my audit, this test passed all 8 times. It now runs every time code is shared.
The same weekly review found admin pages that did not check who was looking. Those were fixed the next day too. If one database holds every customer, row-level security adds a second wall: the database itself refuses the wrong rows.
3. Input: what are you sending in?
What it is: everything a user types, uploads or sends. Form fields, file uploads, links, web addresses, even the name of a file.
The rule: never trust it. Check its shape, its size and its type before using it.
What goes wrong:
- text treated as a command. A user types something into a search box that the database runs as an instruction. This is called injection.
- text treated as page code. A user saves a comment that runs as code in the next visitor’s browser.
- no size limit. Someone sends a 500 MB “job description”. The app slows down or your bill goes up.
- a link the app fetches for you. The user gives a web address, and the app visits it from inside your own network.
How to check: a code scanner finds many of the obvious cases. A person checks that every form and every data request has size and type limits.
In my audit, text boxes had no size limit. Now every field has one.
4. Money and app rules: can someone cheat the system?
What it is: the rules that only your app has. How trials work. When a plan upgrades. What happens when a payment fails. Who can invite whom.
No tool knows these rules. This is where a person earns their fee.
What goes wrong:
- two free trials by signing up twice
- paid features that stay on after a payment fails
- a fake “payment succeeded” message sent to your app
- clicking “buy” twice very fast and getting charged once but upgraded twice
How to check: list every rule about money and access. Try to break each one. Send a fake payment message and check it is refused.
In that weekly review: a payment update could get lost if the payment provider sent it twice, and a first-time customer could not finish checkout. Both were among the 17 fixes shipped the next day.
5. Abuse and limits: can someone use too much?
What it is: limits on how often and how much. How many sign-in tries per minute. How many AI requests per day. How many emails per hour.
What goes wrong:
- a bot guessing passwords all night
- a bot running up your AI bill by calling the same feature thousands of times
- someone using your “invite a friend” form to send spam
How to check: find every action that costs money or can be guessed. Check each has a limit, and that the limit holds when the app runs on more than one server.
In my audit, each server kept its own count, so the limit did not hold. The count now lives in the database, shared by every server.
The next areas are where tools help most. They are still worth understanding, because tools are noisy and a person has to decide what matters.
6. Secrets: are the keys safe?
What it is: passwords and keys the app itself uses. The database password. The payment provider key. The email service key.
What goes wrong:
- a key saved into the code by mistake, then shared with the code
- the same key used on the test site and the live site
- an old key nobody uses, still working
How to check: a tool searches every saved version of the code for things that look like keys. If a real one turns up, deleting it is not enough. Replace the key, because someone may already have a copy.
7. Settings: is the live app set up safely?
What it is: how the live app is switched on. Error pages. Safety settings the browser reads. Which test features are off.
What goes wrong:
- error pages that show the app’s code to visitors
- developer tools left on in the live app
- the test site able to write to the live database
- missing browser safety settings, like the one that stops other sites showing your app inside theirs
How to check: a tool visits the live site and reads its settings. A person checks the settings the tool cannot see, like which database each site points at.
Test the real site, not a laptop copy. The laptop copy turns on extra settings for building that look like holes.
8. Outside code: are the building blocks safe?
What it is: your app is built on hundreds of free code packages written by others. Sometimes one has a known hole.
What goes wrong:
- a package with a known hole that nobody updated
- a fake package with a name one letter off the real one
- a package that was safe last month and is not now
How to check: a tool lists every known hole in seconds. Then a person reads each one, because “critical” often only applies if the app is built a certain way. Run it monthly. Clean last month does not mean clean now.
9. Automatic jobs and deploys: what runs by itself?
What it is: the jobs that run on a schedule, and the steps that put new code live. These often have the most access of anything in the app.
What goes wrong:
- a broken job that still has the right to change live data
- a deploy step that pulls in outside code without checking it
- keys for these jobs that nobody remembers setting
How to check: first ask “does this job even run?” Then: what can it reach, and who can change it. In my audit, two jobs had failed every time for weeks. I removed both.
The last three areas are about what happens when things go wrong.
10. Errors: does it fail safe?
What it is: what the app does when something breaks. A missing setting. A service that is down. A request it does not understand.
The rule: when unsure, say no. A missing key should block the request, not let it through.
What goes wrong:
- a check that is skipped when its setting is missing
- an error that shows private details
- a half-finished payment that leaves the account upgraded
How to check: turn things off on a test site and see what happens. Remove a key. Send nonsense. The app should refuse, not guess.
11. Logs and alerts: would you notice?
What it is: a record of what happened, and an alert when something looks wrong.
What goes wrong:
- an attack that runs for weeks because nothing was watching
- logs that save passwords or customer data in plain text
- no way to tell, after a problem, who did what
How to check: can you answer “who changed this, and when?” Do failed sign-ins, admin actions and payment errors leave a record? Do logs hide private data?
In my job-alert app, job checks once stopped for 25 minutes. One refused request had made the browser extension throw away its pass, and the server kept no record of why. The fix added that record: which route refused, who refused, and the pass’s verdict. More in troubleshooting a live app.
12. Tests: will the fix stay fixed?
What it is: small automatic programs that check one rule still holds. “Customer A cannot open customer B’s draft.”
Why it is on a security list: every fix breaks again one day if nothing checks it. A security review finds the holes. Tests keep them closed.
How to check: every security fix has a test that fails if the fix is removed.
Who checks what
| Area | Tools help? | Who finds the real problems |
|---|---|---|
| 1. Sign-in | a little | person |
| 2. Permissions | no | person |
| 3. Input | partly | tool for patterns, person for limits |
| 4. Money and app rules | no | person |
| 5. Abuse and limits | no | person |
| 6. Secrets | yes | tool |
| 7. Settings | partly | tool for the website, person for the rest |
| 8. Outside code | yes | tool, then a person ranks it |
| 9. Automatic jobs | a little | person reading the job history |
| 10. Errors | a little | person |
| 11. Logs and alerts | no | person |
| 12. Tests | — | person writes them |
That is why my audit found little with tools and most of the real fixes by hand.
The order to test them
The order to learn them is the list above: where the damage is.
The order to test them is different. Run the cheap tools first, so the noise is out of the way:
- Outside code, secrets, code patterns, the live website (areas 6, 7, 8 and part of 3).
- Automatic jobs (area 9).
- By hand: sign-in, permissions, input limits, money, abuse limits, settings the tools miss (areas 1 to 5 and the rest of 7).
- Errors and logs (areas 10 and 11).
- A test for every fix (area 12).
- Update the threat model table with what is still open.
The toolkit post walks through exactly that run on a live app.
The short version
- Security is twelve areas. Each one asks a simple question, like “who are you?” or “what are you allowed to do?”
- The worst holes in a small SaaS are almost never clever hacks. They are missing rules: a page that forgets to check who is asking.
- Tools answer the easy questions fast, about a third of the areas. The ones that matter most, like “can one customer see another’s data?”, need a person who knows what the app should allow, and a test that keeps the answer right.
Tell me what your app is built with and I’ll tell you which of the twelve areas to check first.
Which of the twelve areas has your app never been checked for?
The same twelve areas, with the proper names, how they map to the OWASP Top 10:2025, the attack types inside each one, and what I actually check. The tool commands are in the toolkit post.
The examples assume a typical multi-tenant SaaS: a web framework with server routes, Postgres, a hosted auth provider, a billing provider with webhooks, and scheduled jobs.
The map
| # | Area | OWASP 2025 | Main attack types | Found by |
|---|---|---|---|---|
| 0 | Threat model | A06 Insecure Design | — | person |
| 1 | Authentication | A07 Authentication Failures | credential stuffing, session fixation, token reuse | person, a little tooling |
| 2 | Access control | A01 Broken Access Control | IDOR / BOLA, privilege escalation, forced browsing | person + cross-tenant tests |
| 3 | Input handling | A05 Injection, A01 (SSRF) | SQLi, XSS, SSRF, path traversal, mass assignment, oversized payloads | SAST for patterns, person for limits |
| 4 | Business logic | A06 Insecure Design | race conditions, replay, state skips | person |
| 5 | Abuse and limits | A06 Insecure Design | brute force, cost exhaustion, enumeration | person |
| 6 | Secrets | A04 Cryptographic Failures, A02 | leaked keys, shared keys, no rotation | secret scanner |
| 7 | Configuration | A02 Security Misconfiguration | debug in prod, missing headers, env cross-wiring | DAST + person |
| 8 | Supply chain | A03 Software Supply Chain Failures | known CVEs, typosquats, compromised packages | SCA |
| 9 | CI/CD and jobs | A03, A08 Software or Data Integrity Failures | over-privileged jobs, unpinned actions, poisoned builds | person + run history |
| 10 | Failure handling | A10 Mishandling of Exceptional Conditions | fail-open checks, partial writes, error disclosure | person |
| 11 | Logging and alerting | A09 Security Logging and Alerting Failures | undetected abuse, PII in logs, no audit trail | person |
| 12 | Regression tests | — | — | person writes them, CI runs them |
OWASP orders its list by how common and how damaging each category is across many apps. My order is close, but tuned for a small SaaS: business logic and abuse move up, because those are where a small team’s own rules live and no scanner can see them.
0. Threat model
One table per app: actor, goal, current control, gap. Actors worth listing for almost any SaaS:
- unauthenticated stranger
- authenticated tenant reading another tenant
- tenant escalating plan or role
- bot running up variable cost (AI tokens, email, SMS)
- holder of a stolen session
- holder of a leaked machine secret (cron, webhook)
- someone with access to an admin’s email
- malicious or compromised dependency
- the team itself, by mistake
The point is not the table. It is that every check below fills in a cell, and an empty “control” cell is the next thing to fix.
1. Authentication (A07)
Who is making this request?
Attack types:
- Credential stuffing: reused passwords from other breaches, tried at scale.
- Session fixation / hijacking: an attacker sets or steals a session ID.
- Token reuse: a reset or magic link that works twice, or never expires.
- Test auth in prod: a bypass meant for e2e tests that is reachable on a deployed site.
What I check:
- Every route resolves the user server-side from the session, never from a user ID in the body or query.
- Session cookies are
HttpOnly,Secure,SameSite=Laxor stricter. - Reset and invite tokens are single-use, short-lived and compared in constant time.
- Any test-login path is gated on more than one condition (not-production and local database), and returns 404 otherwise.
- Admins use two-step sign-in.
- Step-up checks for risky actions: re-confirm identity before changing email, payout details or deleting the account.
A hosted auth provider handles most of the protocol. It does not handle how your routes use its answer.
2. Access control (A01)
What is this user allowed to do to this object?
Attack types:
- IDOR / BOLA (insecure direct object reference / broken object-level authorization): change an ID in a request, get someone else’s row.
- Vertical privilege escalation: a member calls an admin route.
- Forced browsing: an admin page is hidden in the menu but still served.
- Function-level gaps: the page checks, the API route behind it does not.
- Check-then-act: ownership checked on read, not re-checked on write.
What I check:
- Every query that takes an ID also filters by owner:
WHERE id = $1 AND account_id = $2. EveryUPDATEandDELETEtoo, at the point of write, not just on the earlier read. - Read-then-write sequences run in a transaction with
SELECT … FOR UPDATE, so the row cannot change owner between the check and the write. - Every admin page and admin API calls the admin check itself. In Next.js App Router, a check in a
layoutdoes not protect the pages under it: layouts do not re-run on client navigation, and the page renders in parallel. - Plan checks run on the server, not only by hiding UI.
The test that matters: a live cross-tenant test against a real database. Create tenants A and B, give B one of every resource, then as A try GET, PATCH and DELETE on each by ID. Assert every call fails and B’s rows are unchanged. A grep proves the filter is written; this proves it works.
3. Input handling (A05, plus SSRF under A01)
Is this input the shape, size and type the code expects?
Attack types:
- SQL injection: user text concatenated into SQL. Fix: parameterized queries only.
- XSS (cross-site scripting): user text rendered as HTML or script. Watch every
dangerouslySetInnerHTML,innerHTML, markdown renderer and email template. - SSRF (server-side request forgery): the server fetches a user-supplied URL and reaches internal addresses (
169.254.169.254,localhost, private ranges). Fix: allowlist hosts, resolve and block private IPs, no redirects. - Path traversal:
../in a filename reaches files outside the upload folder. - Mass assignment: the client sends
{ "role": "admin" }and the code spreads the body into an update. - Oversized payloads: no
max()on a string field, so one request stores megabytes. - Unsafe JSON:
JSON.parseresults used without a runtime schema.
What I check:
- One validation layer at every boundary (request body, query string, webhook payload, JSON from the database, AI output), with a schema per input.
- Every string has a maximum length. Every array has a maximum count. Every upload has a size and type limit.
- Updates pick fields explicitly, never spread the request body.
- Semgrep’s OWASP rules catch the obvious sinks. A person checks the limits, because “no max length” is not a pattern a scanner flags.
4. Business logic (A06)
Can the product’s own rules be bent?
Attack types:
- Race conditions / TOCTOU (time of check to time of use): two requests in the same millisecond both pass a “has credits” check.
- Replay: a valid webhook or request sent again.
- State skips: jumping from “trial” to “active” without passing “paid”.
- Duplicate identities: a second trial on a second email for the same customer.
What I check:
- Every billing state change runs in one transaction, in a fixed order: customer first, then subscription, then entitlement.
- Webhooks verify the signature, reject old timestamps, and are idempotent on the provider’s event ID.
- Entitlements come from the billing provider’s state, not from the client.
- One trial per customer, enforced by a unique constraint, not just app code.
- Replay real webhook payloads against a local database in tests.
5. Abuse and limits (A06)
Can someone use too much, or guess too much?
Attack types:
- Brute force: sign-in, reset codes, invite codes.
- Cost exhaustion (sometimes called denial of wallet): repeated calls to an AI, email or SMS feature.
- Enumeration: “no account with this email” tells an attacker which emails exist.
What I check:
- Rate limits on every route that costs money or accepts a guess, keyed by user and by IP.
- The limit store is shared across instances (Redis, the database, or the platform firewall). An in-memory counter resets per instance, so on serverless it barely limits anything.
- Daily caps on variable-cost features per account.
- Same response for “account exists” and “account does not exist”.
6. Secrets (A04, A02)
Are the app’s own keys safe?
What I check:
gitleaks git .across history. History is what gets cloned.- Every secret is an env var read through one validated config module, and the app refuses to start without it.
- Separate keys per environment. A dev key must not work on production.
- Machine secrets (cron, webhooks) compared in constant time, one secret per caller, so one leak does not unlock everything.
- No unused secrets left set. A secret nothing reads is pure risk.
- On a real leak: rotate first, then check usage logs, then clean history. Assume the history has been copied.
7. Configuration (A02)
Is the deployed app switched on safely?
Headers worth knowing:
- CSP (Content-Security-Policy): which scripts, styles and connections the browser may load.
'unsafe-inline'weakens it against XSS. Aim for nonces or hashes. - HSTS (Strict-Transport-Security): browser only ever uses HTTPS for the site.
frame-ancestors(in CSP): which sites may show yours in an iframe. Stops clickjacking.X-Content-Type-Options: nosniff: browser trusts the declared file type.- CORS (
Access-Control-Allow-Origin): which other sites may read your API responses.*is fine on public static files, never on authenticated APIs. - COEP / COOP: isolation headers needed only for some browser features. Most apps can skip them.
- SRI (Subresource Integrity): a hash on a third-party script so the browser refuses a changed copy. Not practical when the vendor changes the script without changing the URL.
Beyond headers:
- No stack traces or framework banners (
x-powered-by) in responses. - Source maps not public.
- Debug and test flags off in production.
- Environment cross-wiring: a guard that refuses to start if a non-production deploy points at the production database host.
- Scan a deployed production build. A dev server adds
unsafe-evaland verbose errors that are not in production.
8. Supply chain (A03)
Is the code you did not write safe?
Attack types:
- Known CVEs in direct or transitive dependencies.
- Typosquatting:
reqeustsinstead ofrequests. - Compromised maintainers: a real package ships a malicious version.
- Install scripts that run on
npm install.
What I check:
npm auditandosv-scannermonthly, plus a lockfile committed and used (npm ci).- Read each advisory’s conditions before ranking. A “critical” that needs a build mode you do not use is not reachable.
npm audit fixwithout--force. Anything left is written down with a reason.- New dependencies get a quick look: download count, maintainer, install scripts, last release.
9. CI/CD and scheduled jobs (A03, A08)
What runs by itself, and what can it reach?
What I check:
- Run history first:
gh run list. A job that always fails but still holds deploy keys is risk with no benefit. - Third-party actions pinned to a commit SHA, not a tag.
- Least privilege: each workflow gets only the
permissionsand secrets it needs. - No
pull_request_targetworkflows that check out untrusted code with secrets. - Scheduled routes require a secret, refuse when it is unset, and are idempotent so a double run does no harm.
10. Failure handling (A10)
What happens when something is missing, down or malformed?
The rule: fail closed. When a check cannot decide, the answer is no.
What I check:
- A missing secret blocks the request. Patterns like
if (secret && header !== secret)fail open when the secret is unset. - Catch blocks do not swallow errors and continue as if the step worked.
- Multi-step writes are in a transaction, so a failure leaves nothing half done.
- Errors return one shape with no internal detail:
{ "error": "Not found" }. - Timeouts and capped retries on every outside call.
11. Logging and alerting (A09)
Would you know, and could you tell what happened?
What I check:
- Security events leave a record: failed sign-ins, admin actions, permission denials, webhook signature failures, billing state changes.
- Logs and error reports redact emails, tokens and free text before they leave the app.
- An alert reaches a person for the events that matter, not just a dashboard nobody opens.
- Logs are kept long enough to investigate something found a month later.
- Backups exist and a restore has actually been tried.
12. Regression tests
Every fix above gets a test that fails if the fix is removed:
| Fix | Test |
|---|---|
| Owner filter | cross-tenant test against a real database |
| Admin check | route test: member gets 403 |
| Input caps | schema tests at the limit and one over |
| Webhook signature | unsigned and tampered payloads rejected |
| Fail closed | route test with the secret unset |
| Rate limit | N+1th call refused |
Fast tests on every push. The slow live-database and browser tests on a schedule, so drift shows up in days.
Going further
- OWASP Top 10:2025: the category list this page maps to.
- OWASP ASVS: the full checklist version, level 1 is a sensible target for a small SaaS.
- OWASP API Security Top 10: the same idea for APIs, where BOLA is number one.
- My toolkit post: the commands and a real run.
More Posts
All posts
November 25, 2026
Why Your App Went Offline on Vercel's Free Plan (and How to Stay Under the Limits)
Vercel's free plan pauses every site on the account when one monthly limit runs out. What the limits mean in plain words, what uses them up, and the fixes, from a real case.
November 24, 2026
Why Your Project Starts With a Small Paid Step: Requirements and an Estimate Before the Build
A price given before the work is measured is a guess, and someone pays for it later. What a small paid first step gets you: written decisions, a cost range and a time range, and the choice to stop there.