Cookie set without its protective attributes
A cookie is written without `httpOnly`, `secure`, or `sameSite`. Missing `httpOnly` turns any cross-site scripting bug into session theft; missing `secure` sends the cookie over plain HTTP; missing `sameSite` attaches it to cross-site requests. A cookie holding no sensitive value may not need all three, which is why the finding names the ones it did not find rather than assuming the worst.
medium likely application source OWASP A05:2021 / CWE-614
What it looks like
From app/api/login/route.ts in the fixture suite.
The fixture test asserts this finding.
How to fix it
Set httpOnly, secure, and sameSite when writing a cookie that carries anything the user would not want read or replayed.
The fix for your framework
Choose the API used by your project.
- Next.js
- Nuxt
- NestJS
- Express
- Fastify
- Hono
- Koa
- Hapi
- Sails.js
- Astro
- Remix
- Gatsby
- SvelteKit
- TanStack Start
- SolidStart
- Elysia
Check your own repository
npx owlwarden scan --preset deep
npx owlwarden explain insecure-cookie
explain prints the rule and fixes in the terminal. It does not
use the network.