cookie-sentinel

Sentinel · security scanner

cookie-sentinel

Audit the cookies your site sets before attackers do.

npm i -D cookie-sentinel

What it checks

  • missing-secureCookie on an HTTPS site without Secure
  • cookie-over-httpCookie set by a plain http:// response
  • missing-httponlySession-like cookie (configurable name patterns) without HttpOnly
  • samesite-missingNo SameSite attribute
  • samesite-noneSameSite=None (cross-site sending, CSRF exposure)
  • samesite-none-insecureSameSite=None without Secure: browsers reject it
  • samesite-invalidSameSite value that isn't Strict/Lax/None
  • host-prefix__Host- cookie without Secure, with Domain, without Path=/, or set over HTTP; mis-cased prefixes

Quick usage

CLI

npx cookie-sentinel https://example.com
npx cookie-sentinel https://example.com -p /login -p /account --fail-on medium
npx cookie-sentinel https://app.example.com --crawl urls.txt          # URLs or paths, one per line
npx cookie-sentinel https://app.example.com --crawl-depth 2 --max-pages 40   # follow same-origin links
npx cookie-sentinel https://app.example.com/account -H "Cookie: session=…"   # audit logged-in pages
npx cookie-sentinel https://app.example.com --headers-file auth.json --cookies-file jar.txt
npx cookie-sentinel https://app.example.com --browser playwright      # optional peer dep
COOKIE_SENTINEL_BEARER=… npx cookie-sentinel https://api.example.com/me
curl -si https://example.com | npx cookie-sentinel --input -              # offline
npx cookie-sentinel --input set-cookies.txt --origin https://app.example.com -f sarif > cookies.sarif

API

import { auditUrls, auditSetCookies, formatText, classifyCookie } from 'cookie-sentinel';
// const { auditUrls } = require('cookie-sentinel'); // Node 18+

const report = await auditUrls(['https://example.com'], {
  paths: ['/login'],
  crawl: { maxDepth: 1, maxPages: 10 },
  headers: { Cookie: 'sid=…' },
});
console.log(formatText(report, { failOn: 'high' }));
console.log(report.classificationSummary);

Every option is documented in the cookie-sentinel docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write
jobs:
  cookies:
    runs-on: ubuntu-latest
    steps:
      - uses: MrLouisWright/cookie-sentinel@<sha>
        with:
          urls: https://staging.example.com
          paths: /login /account
          bearer: ${{ secrets.STAGING_TOKEN }}
          fail-on: medium
          args: --crawl-depth 1 --max-pages 20
          sarif: cookies.sarif