# csrf-csrf: 6.1 out of 10

Reasonable, with limits. 8th of 10 in [Web security libraries](https://elestia.ai/opensource/web-security/index.md).

csrf-csrf is a small Express middleware for stateless CSRF protection with the signed double-submit cookie pattern. It is one of the main maintained replacements for the deprecated csurf. It does a narrow job well, but one maintainer releases it rarely, and it ties you to Express and cookie-parser.

**Best for:** Express apps without server sessions, such as SPA backends, that need a maintained replacement for csurf.

## Scores

- **Overall: 6.1** (likely 4.9 to 7.2)
  - Claude Opus 5.5 (5.5): For Express apps that need stateless CSRF tokens, it is a sound choice and one of the few maintained ones. Its design fixes the main weakness of csurf. Slow work by one maintainer, the Express-only scope and little outside validation keep it in the reasonable-with-limits band. Many new apps can rely on SameSite cookies or the protection built into their framework instead.
  - GPT-6.2 Sol (6.6): It is a reasonable choice for new Express apps that specifically need stateless, cookie-based CSRF tokens. Sparse releases and unresolved Express 5 typing temper that recommendation. Helmet and DOMPurify have much stronger maintenance and adoption signals for their respective security jobs. Future Express compatibility work and wider production experience could change how confidently teams can choose it.
- **Needed by many: 3.4** (likely 2.4 to 4.8)
  - Claude Opus 5.5 (3.5): CSRF protection matters only for apps that authenticate with cookies, and this package serves only Express. SameSite cookies and framework-built protection cover many apps without it. That makes it a clear niche next to helmet, cors or rate limiting.
  - GPT-6.2 Sol (3.3): Express is widely used, and browser apps that authenticate with cookies need CSRF protection. This package serves the subset that needs stateless tokens. Surveys measure Express usage, leaving the size of that subset uncertain.
- **Helps a lot: 6.6** (likely 5.5 to 7.9)
  - Claude Opus 5.5 (6.0): Version 4 signs tokens with HMAC and binds them to a session identifier, which fixes the known weakness of naive double-submit cookies. It has types, configurable options and good warnings in the docs. Limits: it is Express-only, it depends on cookie-parser order, and it has rough edges such as the Express 5 types issue and a report of a missing http-errors package. Developers also often misconfigure getSessionIdentifier.
  - GPT-6.2 Sol (7.2): Version 4.1.0 implements OWASP's signed, session-bound pattern and adds timing-safe token comparison. The reference covers token delivery and configurable errors, but developers have reported confusion over setup and an Express 5 type mismatch. The current manifest still uses Express 4 types, and some examples that coding agents may find use the version 3 API. Independent performance and agent accuracy measurements are scarce.
- **Holds up over time: 4.7** (likely 3.2 to 6.2)
  - Claude Opus 5.5 (4.5): The project is not archived, and version 4.1.0 came out in November 2026. But it had only 3 commits in the last year, it has no GitHub releases, and the work rests mostly on one maintainer. Issues such as Express 5 type support stay open for months, and the v4 upgrade broke existing setups. Its domain is small and stable, so slow work hurts it less than it would a larger library.
  - GPT-6.2 Sol (4.8): The November hardening release followed a 17-month gap, and three commits in the past year put it well behind Helmet and express-rate-limit. The npm package has one listed maintainer, the Express 5 typing issue remains open, and the last major upgrade required new tokens. NestJS now offers built-in CSRF protection, and the timing of future Express compatibility work is uncertain.
- **Used widely: 3.9** (likely 2.8 to 5.0)
  - Claude Opus 5.5 (4.5): It has about 280k weekly downloads, and its yearly ratio of 4.18 is about the median of 4.1, so it holds its ground but does not gain. It has 217 dependent repositories, far below the tens of thousands of helmet or express-rate-limit, which suggests a few thousand projects choose it directly. It has almost no attention on Hacker News or Bluesky.
  - GPT-6.2 Sol (3.2): Four-week downloads rose from 270,065 to 1.13 million, or 4.18×, just above the catalog's 4.1× baseline. The 217 indexed repositories and seven dependent packages point to modest direct use, and every peer with a repository count is ahead. Automated installs and incomplete repository coverage leave the actual number of projects uncertain.
- **Vouched for: 4.5** (likely 3.4 to 5.9)
  - Claude Opus 5.5 (3.0): Guides and the csrf-sync docs point to it as the stateless replacement for csurf, but no well-known company or framework backs it in public. Express itself does not name it. I found no independent audit or benchmark.
  - GPT-6.2 Sol (6.0): NestJS documents it as the token-based option for its Express adapter. Ride The Lightning shipped a migration from csurf, and another adopter reported a successful migration in the Express discussion. Independent package benchmarks and survey-based satisfaction data are scarce, so these reports establish practical use more clearly than comparative quality.
- **Safe: 7.2** (likely 5.7 to 8.3)
  - Claude Opus 5.5 (7.0): It has one runtime dependency and an ISC licence on npm. Its one advisory was low severity, from 2022, and fixed. There is no Scorecard, the GitHub repo shows no licence field, and releases come mostly from one person, so the publishing process cannot be checked. Misconfiguration is the main risk for a security middleware.
  - GPT-6.2 Sol (7.3): The package has one direct runtime dependency and a permissive ISC license. Its only cataloged advisory was a low-severity cookie-name issue patched in 2.2.1, and version 4.1.0 hardened token comparison. One listed npm maintainer, a missing Scorecard and unverified release provenance leave uncertainty about publishing safeguards.

## Good

- It uses HMAC-signed tokens tied to a session identifier, which blocks the cookie-tossing weakness that hit csurf.
- It has one runtime dependency and ships its own TypeScript types.
- The README and FAQ are careful, with clear warnings about common mistakes such as reading the token from the cookie.
- You can configure secret rotation, cookie options, ignored methods and error responses.

## Bad

- It works only with Express and needs cookie-parser registered in the right order.
- Work is slow: 3 commits and one npm release in the last year, from mostly one maintainer.
- Version 4 had breaking changes (the required getSessionIdentifier, a new token format), and Express 5 type support was still an open issue in 2026.
- The repository has no OpenSSF Scorecard and no GitHub releases, so the publishing process is hard to check.

## The numbers

- Downloads, 4 weeks: 1.1M
- In a year: ×4.2
- GitHub stars: 197
- Commits, 12 months: 3
- Last npm release: Nov 2026
- Advisories, 24 months: 0
- Licence: ISC
- GitHub: https://github.com/Psifi-Solutions/csrf-csrf
- npm: https://www.npmjs.com/package/csrf-csrf

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 22 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
