r/nextjs • • 4d ago

What website security issues do developers commonly overlook?

I've been reviewing common security considerations across WordPress websites and Next.js applications.

Something I've noticed is that developers often focus heavily on performance, design and functionality, while some basic security practices receive less attention.

A few examples:

  • Exposed API keys and environment variables
  • Missing server-side authorization checks
  • Outdated dependencies and plugins
  • Improper input validation
  • Insecure file uploads
  • Missing backup and recovery strategies

I think security should be part of the development process from the beginning, rather than something added just before launch.

I'm interested in hearing from developers who maintain production websites.

Questions:

  1. What security vulnerability have you encountered most often?
  2. Do you perform security checks before every deployment?
  3. What tools do you use for dependency and vulnerability scanning?
  4. Do you follow a security checklist for WordPress and Next.js projects?

Interested in practical experiences and recommendations.

4 Upvotes

14 comments sorted by

2

u/usestackrank 4d ago

a few Next-specific ones I keep running into:

  • anything prefixed NEXT_PUBLIC_ gets inlined into the client bundle at build time. people stick a secret key there because it was the only way to make it work in a client component, and now it's sitting in JS anyone can download.
  • auth only in middleware. middleware is fine for redirects, but the real check should also happen where the data is read (server action, route handler, or your data access layer). the x-middleware-subrequest bypass from early 2025 is a good example of why. if you're on an older 14.x or 15.x, make sure you're at least on 14.2.25 / 15.2.3.
  • passing a whole db row from a server component into a client component. every field gets serialized to the browser, including the ones you never render (password hashes, internal notes, emails). pick only the fields you need.
  • server actions are basically public POST endpoints, so validate the input with zod or similar inside each one, not just in the form.

for scanning, dependabot or renovate plus npm audit in CI catches most of the dependency stuff.

2

u/lemhion1908 1d ago

In Next.js + Supabase apps, the biggest thing I see is people only checking auth in the page or middleware and forgetting the server action or route handler. Server actions are basically public POST endpoints, so you still have to re-check the user and resource ownership inside every one.

RLS is the other big one. Tables with it left off, or lazy policies like using (true), mean the anon key can read or write everything. And obviously never put the service_role key in a NEXT_PUBLIC_ var since it bypasses RLS completely.

Also worth watching out for getSession() on the server when making auth decisions. It just reads the cookie without verifying the JWT, so you want getClaims() or getUser() instead.

For tooling, npm audit plus Dependabot in CI handles the dependency side well enough. For anything multi-tenant, I make sure to test RLS policies with different roles before shipping, since that's usually where the nasty bugs hide.

2

u/No-Marionberry8257 1d ago

Your list covers the big ones. The issue I run into most is missing server-side authorization. On Next.js it usually shows up in API routes or server actions that check whether the user is logged in but not whether they actually own the record they're requesting. Changing an ID in the request returns someone else's data. Close second is secrets leaking to the client through NEXT_PUBLIC_ variables, or keys committed to the repo early on and never rotated. On WordPress it's almost always abandoned plugins, old admin accounts, and XML-RPC or the REST user endpoint left open.

For checks, we run automated scans on every pull request rather than relying on someone remembering before a deploy. Dependabot or Renovate keeps dependencies updated, npm audit and Snyk catch known vulnerabilities, and Gitleaks or GitHub secret scanning blocks committed keys. On WordPress, Wordfence or Patchstack flags vulnerable plugins, and WPScan is handy for a quick audit of a site you've inherited. We also set security headers like CSP, HSTS and X-Frame-Options, and add rate limiting to login and form endpoints.

We keep a short checklist rather than a huge one, because long ones get skipped: authorization checked on every route, no secrets in client code, dependencies current, uploads validated by type and stored outside the web root, and backups that have actually been restored at least once. That last one gets skipped more than anything else on the list. Lots of teams have backups but have never tested a restore. Has anyone here had a backup fail when they actually needed it?

1

u/Few-Ad-1155 4d ago

the one that bit me was auth checks only living in the UI. button was hidden for non-admins but the server action behind it happily ran if you called it directly. found it way later than I’d like to admit

what actually fixed it long term was a dumb test that loops over every api route and fails if it doesn’t check the session (unless I explicitly mark it public). checklists I forget, the test I can’t

1

u/AirportRepulsive3482 4d ago

Rendering headless WordPress content with dangerouslySetInnerHTML without sanitizing it first. CMS content isn’t automatically trusted content.

1

u/fahadhelpspeoplewith 4d ago

Most common one I see when we take over older projects is not exotic at all: backups that exist but were never restored once. A school client of ours had nightly database dumps going to the same VPS, so when the disk failed during a long load shedding day in Dhaka, the backups went with it. We now copy them offsite and do a test restore every month, which feels tedious until the day you need it.

The other thing I'd add to what's here is file uploads on headless WordPress plus Next.js setups. People lock down the Next side carefully, then leave the WP admin and media endpoint open on a public subdomain with an old form plugin accepting any file type. We started putting the WP backend behind basic auth or an IP allowlist since the frontend only needs the API. No fancy tooling, but it closed more holes than any scanner did for us.

1

u/Janczik_yelianny44 4d ago

leaky server actions are probably the biggest thing right now. people treat them like private internal functions and forget they compile down to public HTTP endpoints that still need auth and payload validation.

1

u/Otherwise-Leather965 4d ago

For the dependency part, running npm audit in your CI so the build fails on high severity issues is a cheap way to check before every deploy. Pair it with an automated dependency update bot so updates come in as small pull requests instead of one big scary upgrade later.