No. 21Security9 min read2,267 words
Web application security checklist: for 2026
A practical web application security checklist for 2026: authentication, sessions, authorization, input validation, headers, secrets, dependencies and logging.
- Written by
- Lazy Devs
- Published
- Updated
- Sources
- Cited inline

Key takeaways ยท 05
The short version
- 01Broken access control is ranked first in the OWASP Top 10:2025. Scope every database query to the authenticated user or organisation, and never trust an ID from the request on its own.
- 02Use a vetted auth provider or library. If you store passwords yourself, hash them with Argon2id (OWASP's minimum: 19 MiB memory, 2 iterations, parallelism 1) or bcrypt.
- 03Session cookies need HttpOnly, Secure and SameSite flags, a real expiry, rotation on login and server-side invalidation on logout.
- 04Validate every request body against a schema at the boundary, and treat Next.js Server Actions as public POST endpoints that need their own authentication and authorization checks.
- 05Software supply chain failures are now their own OWASP Top 10 category: commit lockfiles, install with npm ci, turn on secret scanning and patch dependencies continuously.
On this page ยท 12
To secure a web application, work through the risks in the order attackers actually exploit them: use authentication you did not write, check authorization on every data access, validate every input with a schema, keep secrets out of code and client bundles, lock and patch dependencies, set HTTPS with HSTS and a Content Security Policy, rate limit sensitive endpoints, and log security events without logging sensitive data. That covers the doors real attackers walk through.
Most breaches are not clever. They are a leaked API key in a public repository, a missing authorization check on an admin route, or a dependency that went unpatched for a year. Securing a web application is mostly about doing a handful of unglamorous things consistently, not buying a product. This is the checklist we run on every project and on every codebase we take over, updated for Next.js 16 and the OWASP Top 10:2025.
How to use this checklist
The OWASP Top 10 is the industry's shared list of the most critical web application risks. Here is how the 2025 edition maps to the sections below:
| OWASP Top 10:2025 | Where it is covered |
|---|---|
| A01 Broken Access Control | Authorization |
| A02 Security Misconfiguration | Security headers and HTTPS |
| A03 Software Supply Chain Failures | Secrets, dependencies and the supply chain |
| A04 Cryptographic Failures | Authentication, HTTPS |
| A05 Injection | Treat every input as hostile |
| A06 Insecure Design | Throughout, especially authorization and rate limiting |
| A07 Authentication Failures | Authentication, sessions |
| A08 Software or Data Integrity Failures | Supply chain, CSRF |
| A09 Security Logging and Alerting Failures | Logging and errors |
| A10 Mishandling of Exceptional Conditions | Logging and errors |
If you need a more detailed standard for a regulated product or a security review, use OWASP's Application Security Verification Standard (ASVS), which turns these categories into testable requirements.
1. Authentication you did not write
If you are hand-rolling password hashing, session handling and password resets, stop. Use a managed provider or a well-maintained library; our guide to authentication patterns for Next.js compares the options. The interesting bugs live in the boring edges: timing-safe token comparison, secure reset flows, and account enumeration through different error messages on the login or reset form.
If you do store passwords yourself, use a slow, salted hash designed for passwords. OWASP's Password Storage Cheat Sheet recommends Argon2id, with bcrypt as an acceptable alternative for legacy systems. Never use a general-purpose hash like SHA-256 for passwords.
import argon2 from "argon2";
export async function hashPassword(plain: string): Promise<string> {
return argon2.hash(plain, {
type: argon2.argon2id,
memoryCost: 19456, // 19 MiB, OWASP minimum
timeCost: 2,
parallelism: 1,
});
}
export async function verifyPassword(hash: string, plain: string) {
// Reads the salt and parameters from the stored hash.
return argon2.verify(hash, plain);
}Password policy has changed too. NIST's authentication guidelines (SP 800-63B) favour length over composition rules, checking new passwords against lists of breached passwords, and no forced periodic rotation. Offer multi-factor authentication to everyone and require it for admins. Passkeys are now well supported and remove phishing and password reuse from the picture entirely.
Sessions and cookies
Session cookies need three flags, no exceptions: HttpOnly (JavaScript cannot read it, so an XSS bug cannot steal it), Secure (HTTPS only) and SameSite. SameSite=Lax suits most apps; it blocks the common CSRF cases while keeping normal links working. In Next.js 16, set cookies on the server with the async cookies() API:
// app/lib/session.ts
import "server-only";
import { cookies } from "next/headers";
export async function setSessionCookie(token: string) {
const cookieStore = await cookies();
cookieStore.set("session", token, {
httpOnly: true,
secure: true,
sameSite: "lax",
path: "/",
maxAge: 60 * 60 * 24 * 7, // seconds in Next.js, not milliseconds
});
}Watch that maxAge unit: Express's res.cookie takes milliseconds, while Next.js takes seconds, which is an easy way to create a cookie that lives a thousand times longer than intended.
Set a real expiry, rotate the session ID on login to prevent session fixation, and invalidate sessions on the server at logout and password change. A JWT you cannot revoke is a liability, so keep access tokens short-lived and back them with a refresh token you can actually kill.
2. Authorization is where the real bugs hide
Authentication answers "who are you". Authorization answers "are you allowed to touch this row". Broken access control tops the OWASP list for a reason: it is the most common serious bug we find in real codebases. The pattern is always the same: an endpoint reads an ID from the request and trusts it.
// Broken: any logged-in user can read any invoice by changing the ID
const invoice = await db.invoice.findUnique({ where: { id: params.id } });
// Fixed: scope every query to the authenticated principal
const invoice = await db.invoice.findFirst({
where: { id: params.id, organizationId: session.user.orgId },
});Check ownership on every read, write and delete. Do not rely on the UI hiding a button. Centralise the rule in a server-only data access layer so a new endpoint cannot forget it; the Next.js data security guide recommends the same structure. In a multi-tenant product, tenant scoping is the single most important rule in the codebase, which is why we treat it as architecture in multi-tenant architecture without the headaches.
Two Next.js specifics:
- Server Actions are public endpoints. Next.js documents that they can be called by direct POST requests, not just through your UI. Verify the session and authorization inside every action.
- Proxy is not your authorization layer. In Next.js 16, Middleware has been renamed Proxy. It is fine for optimistic redirects, but the real check must happen next to the data, in the data access layer.
3. Treat every input as hostile
SQL injection
Use parameterised queries. ORMs like Prisma and Drizzle do this for you, but the second you reach for raw SQL, the danger comes back. Never build a query with string concatenation.
// Dangerous: user input lands directly in the query string
db.$queryRawUnsafe(`SELECT * FROM users WHERE email = '${email}'`);
// Safe: a tagged template is parameterised by the driver
db.$queryRaw`SELECT * FROM users WHERE email = ${email}`;Cross-site scripting (XSS)
React escapes values by default, which prevents most XSS. The exceptions are dangerouslySetInnerHTML, user-supplied URLs rendered into href (watch for javascript: URLs), and data injected into inline scripts. If you must render user HTML, such as rich-text comments, sanitise it on the server with a maintained library like DOMPurify and an allowlist. Do not write your own regex sanitiser.
Validate the shape, not just the type
Validate request bodies at the boundary with a schema library such as Zod or Valibot, and reject anything that does not match. It shrinks your attack surface by refusing unexpected fields and malformed payloads before they reach business logic.
import { z } from "zod"; // Zod 4
const CreateUser = z.object({
email: z.email().max(254),
displayName: z.string().min(1).max(80),
role: z.enum(["member", "admin"]), // never accept arbitrary role strings
});
const parsed = CreateUser.safeParse(await req.json());
if (!parsed.success) {
return Response.json({ error: "Invalid input" }, { status: 400 });
}Mass-assignment bugs happen when you spread a request body straight into a database write and a user smuggles in role: "admin" or organizationId. Zod strips unknown keys by default, but the real fix is to only ever write the fields you have explicitly accepted, and to decide who may set privileged fields like role in your authorization layer.
CSRF
SameSite=Lax cookies block most cross-site request forgery. Next.js adds a check for Server Actions, comparing the Origin and Host headers. Custom Route Handlers that change state get no such check, so keep them POST-only and verify the Origin header yourself, or require a token.
4. Security headers and HTTPS
Serve everything over HTTPS and set HSTS so browsers refuse to downgrade. Add a Content Security Policy to limit where scripts can load from, which turns many XSS bugs into non-events. In Next.js you can set static headers with the headers option in next.config.ts:
// next.config.ts
import type { NextConfig } from "next";
const csp = [
"default-src 'self'",
"script-src 'self' 'unsafe-inline'", // see note on nonces below
"style-src 'self' 'unsafe-inline'",
"img-src 'self' blob: data:",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self'",
"frame-ancestors 'none'",
"upgrade-insecure-requests",
].join("; ");
const nextConfig: NextConfig = {
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "Content-Security-Policy", value: csp },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
],
},
];
},
};
export default nextConfig;A note on script-src: Next.js uses inline scripts during hydration, so a bare script-src 'self' breaks App Router pages. The static policy above is what the Next.js docs suggest when you do not need nonces. For a strict policy without 'unsafe-inline', generate a per-request nonce in proxy.ts, as described in the Next.js Content Security Policy guide. Nonces require dynamic rendering, so weigh that against caching.
frame-ancestors 'none' supersedes the older X-Frame-Options header in modern browsers and stops clickjacking. Only add preload to HSTS once every subdomain serves HTTPS, because it is hard to undo.
5. Secrets, dependencies and the supply chain
Software supply chain failures are now their own OWASP category, and they are how many real compromises arrive.
- Keep secrets out of the repository and the client bundle. In Next.js, any variable prefixed
NEXT_PUBLIC_is inlined into browser JavaScript. A secret with that prefix is a public secret. - Mark server-only modules. Add
import "server-only"to modules that read secrets or the database, so importing them into a Client Component fails the build. - Turn on secret scanning and push protection. GitHub's secret scanning catches keys before or soon after they are committed. Rotate anything that has ever been committed; assume it has already been scraped.
- Use a secret manager or your host's encrypted environment configuration, with separate values per environment.
- Commit your lockfile and install with
npm ciin CI and production, so builds install exactly what you reviewed. - Patch continuously. Run
npm auditin CI and let Dependabot or Renovate open update pull requests. Known, already-patched vulnerabilities in outdated dependencies are a far more common way in than exotic zero-days. - Review new dependencies before adding them: maintenance activity, install scripts, and whether you really need it.
6. Rate limiting and abuse
Put rate limits on anything that costs money or leaks information: login, password reset, signup, search, and any endpoint that sends email or calls paid external APIs. A limit keyed on IP plus account stops most credential stuffing and brute force; without it, your login page is a free password-guessing service. Our guide to rate limiting strategies that scale covers token buckets, sliding windows and where to enforce them.
Uploads deserve their own care: validate type and size, store outside your web root, and serve from a separate domain. See handling file uploads safely.
7. Logging, errors and failing safely
- Return generic errors to clients; keep stack traces in server logs. A 500 that dumps a database error tells an attacker your schema.
- Log security events: logins, failed logins, password and MFA changes, authorization failures and admin actions, with a request ID to tie them together.
- Alert on them. OWASP renamed this category "Logging and Alerting Failures" for a reason: logs nobody watches do not stop anything.
- Never log passwords, tokens, session IDs or full card numbers. Scrub them before they reach your log platform or error tracker.
- Fail closed. If a permission check throws, a token cannot be verified or a dependency times out, deny the request. Code that defaults to "allow" on an exception is exactly what the new A10 category is about.
Extra steps for regulated products
If you handle health, financial or insurance data, this checklist is the floor, not the ceiling. Audit logging, vendor agreements, encryption requirements and data retention rules all get stricter. We cover the specifics in HIPAA-conscious software, healthtech web apps, fintech app compliance and insurance software development.
The quick checklist
Run this before you ship:
- Authentication handled by a vetted provider or library; passwords hashed with Argon2id or bcrypt; MFA available, and required for admins.
- Cookies are
HttpOnly,SecureandSameSite; sessions rotate on login and die on logout. - Every data access is scoped to the authenticated user or organisation, in a server-only data access layer.
- Server Actions and Route Handlers check authentication and authorization themselves.
- All input validated with a schema; raw SQL parameterised; privileged fields never mass-assigned.
- HTTPS everywhere, HSTS set, a Content Security Policy in place.
- No secrets in the repository or
NEXT_PUBLIC_variables; secret scanning on; lockfile committed; dependencies patched. - Rate limits on authentication and expensive endpoints.
- Generic errors for users, detailed logs for you, alerts on security events, nothing sensitive logged, failures closed.
Make it a habit
Security is not a launch task. Run dependency and secret scanning on every commit, give extra review to any change touching authentication, authorization or data access, and do a deeper review before major launches and at least once a year.
You do not need a large security budget to close the doors real attackers use. You need these basics done consistently. If you want a second pair of eyes on your application, a security-focused technical consulting review is a good place to start, or tell us what you are building.
Security is one part of a safe go-live. Our website launch checklist covers it alongside SEO, performance, accessibility, email and DNS.
For the response headers in detail, with safe starting values for each, see our free security headers checklist. Selling to larger companies? Read SOC 2 readiness for SaaS engineering teams.
FAQ ยท 05 questions
Frequently asked questions
What are the most important web application security measures?
Start with the ones that stop the most common real breaches: use a vetted authentication library, enforce authorization on every data access, validate all input with a schema, keep secrets out of code and client bundles, keep dependencies patched, set security headers including HSTS and a Content Security Policy, and rate limit login and other sensitive endpoints.
What is the OWASP Top 10?
The OWASP Top 10 is a widely used awareness list of the most critical web application security risks, published by the Open Worldwide Application Security Project. The 2025 edition is led by broken access control, security misconfiguration and software supply chain failures. It is a starting point for priorities, not a complete standard; OWASP's ASVS is the more detailed verification standard.
How often should a web application be security tested?
Continuously for the basics: dependency and secret scanning on every commit, and security-focused code review on every change touching authentication, authorization or data access. Add a deeper review or penetration test before major launches, after significant architecture changes, and at least annually for applications holding sensitive data.
Do Next.js Server Actions need authentication checks?
Yes. Next.js documents that Server Actions are reachable by direct POST requests, not only through your UI. Verify the session and check authorization inside every action, or call a server-only data access layer that does it for you. Next.js does compare the Origin and Host headers for Server Actions, which helps against CSRF but does not replace authorization.
Is HTTPS enough to secure a web app?
No. HTTPS protects data in transit between the browser and your server, but it does nothing about broken authorization, injection, stolen credentials, vulnerable dependencies or leaked secrets. It is a baseline requirement, alongside HSTS so browsers never fall back to plain HTTP.