Fix cookie set without its protective attributes in Fastify

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 Fastify CWE-614 / OWASP A05:2021

The vulnerable pattern in Fastify

MEDIUM likely Cookie set without its protective attributes A05:2021 src/server.ts:26:40 24 │ // insecure-cookie: options object present but missing secure and sameSite, 25 │ // which is the "team owns cookie config and has a gap" case. 26 │ reply.setCookie('last_search', term, { httpOnly: true }) │ ~~~~~~~~~~~~~~~~~~ cookie options missing protective attributes 27 │ 28 │ // cors-permissive: hand-rolled wildcard + credentials.

This finding comes from the Fastify fixture in the owlwarden test suite. This cookie is missing protections: secure stops the cookie being sent over plain HTTP; sameSite stops the browser attaching the cookie to cross-site requests.

The corrected handler

Pass the attributes to reply.setCookie.

reply.setCookie('session', token, {
  httpOnly: true,
  secure: process.env.NODE_ENV === 'production',
  sameSite: 'lax',
  path: '/',
})

If you are not using Fastify

Set httpOnly, secure, and sameSite when writing a cookie that carries anything the user would not want read or replayed.

Check your own repository

npx owlwarden scan
npx owlwarden explain insecure-cookie

Runs on your machine. No account, no telemetry, no network unless you ask. In CI, SARIF uploads to code scanning and the exit code is the gate.

Other Fastify checks

Rules with a tested Fastify example.

insecure-cookie for every framework / All rules / owlwarden