csrf-csrf
Reasonable, with limits. 8th of 10 web security libraries.
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
Overall6.1
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 5.5, likely 4.5 to 6.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.
- github commitsLastYear: Low activity
- github.com/Psifi-Solutions/csrf-csrf: Careful design and docs for the double-submit pattern
- safeguard.sh/resources/blog/nodejs-csrf-protection-guide: Calls SameSite a complementary layer next to token-based protection
GPT-6.2 Sol: 6.6, likely 5.3 to 7.8
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.
- docs.nestjs.com/security/csrf: Shows where the package fits alongside framework-provided protection.
- github.com/Psifi-Solutions/csrf-csrf/issues/126: Express 5 TypeScript compatibility remains open.
- npm.versionsLastYear, github.commitsLastYear, peers: One npm update and three commits, with far higher activity and adoption for Helmet and DOMPurify.
Needed by many3.4
How many developers need a tool for this job?
Claude Opus 5.5: 3.5, likely 2.5 to 5.0
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.
- github description: Stateless CSRF protection with the double-submit cookie pattern, for Express
- github.com/Psifi-Solutions/csrf-csrf/issues: Open issue #67 asks for support of Express-like frameworks
- expressjs.com/en/blog/2025-05-16-express-cleanup-legacy-packages: Express says CSRF protection is now better handled by frameworks or custom code
GPT-6.2 Sol: 3.3, likely 2.2 to 4.5
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.
- 2025.stateofjs.com/en-US/libraries/back-end-frameworks: Express leads backend framework usage among survey respondents.
- cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html: OWASP distinguishes stateless tokens, server-side session tokens and framework protection.
- github.com/Psifi-Solutions/csrf-csrf/blob/main/FAQ.md: The package targets stateless cookie authentication on Express.
Helps a lot6.6
How well does it do the job for those who need it?
Claude Opus 5.5: 6.0, likely 5.0 to 7.5
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.
- github.com/Psifi-Solutions/csrf-csrf: README covers v4 features, secret rotation and warnings against unsafe token lookups
- technetexperts.com/configuring-csrf-csrf-express-cookie-session: Third-party guide shows a common insecure getSessionIdentifier setup
- veracode.com/blog/research/analysis-and-remediation-guidance-csrf-vulnerability-csurf-expressjs-middleware: Shows why naive double-submit cookies in csurf were bypassable
- npm hasTypes: Ships its own TypeScript types
GPT-6.2 Sol: 7.2, likely 6.0 to 8.3
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.
- cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html: Recommends signed double-submit tokens bound to the user's session.
- github.com/Psifi-Solutions/csrf-csrf/blob/main/CHANGELOG.md: Version 4.1.0 added timing-safe comparison.
- github.com/Psifi-Solutions/csrf-csrf/issues/126: A user reported incompatible Express 5 request types.
- github.com/Psifi-Solutions/csrf-csrf/blob/main/package.json: Version 4.1.0 still builds against Express 4 types.
- reddit.com/r/node/comments/180dwag/how_to_use_csrfcsrf_package: Users reported setup friction, including a missing cookie parser.
- github.com/semgrep/skills/blob/main/skills/code-security/rules/csrf.md: The Express example still uses the version 3 token generator.
Holds up over time4.7
Will it still be a good choice in two years?
Claude Opus 5.5: 4.5, likely 3.0 to 6.0
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.
- github commitsLastYear: 3 commits in the last year
- npm latestPublishedAt: 4.1.0 published 2026-11-01, the only version in a year
- github.com/Psifi-Solutions/csrf-csrf/issues: Express 5 types issue open since Feb 2026; oldest open issue from 2024
- unpkg.com/csrf-csrf@4.0.3/README.md: v4 made getSessionIdentifier mandatory and changed the token format
GPT-6.2 Sol: 4.8, likely 3.3 to 6.3
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.
- github.commitsLastYear: Three commits in the past year.
- peers: Helmet had 72 commits and express-rate-limit had 136.
- github.com/Psifi-Solutions/csrf-csrf/blob/main/CHANGELOG.md: The previous npm release was in May 2025.
- summary.ecosyste.ms/projects/383366: One maintainer is listed for the npm package.
- github.com/Psifi-Solutions/csrf-csrf/issues/126: The maintainer discussed future Express 5 support in an open issue.
- github.com/Psifi-Solutions/csrf-csrf/blob/main/UPGRADING.md: The version 4 upgrade changed the API and token format.
- docs.nestjs.com/security/csrf: NestJS 12.1 introduced built-in header-based CSRF protection.
Used widely3.9
How many use it, and is that growing?
Claude Opus 5.5: 4.5, likely 3.5 to 5.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.
- npm downloadsLast4Weeks: 1.13M now vs 270k a year ago, a ratio of 4.18 against a median of 4.1
- dependents: 217 repos and 7 packages, low next to its peers
- bluesky posts: 0 posts; the one HN match is about Gorilla/CSRF, not this project
GPT-6.2 Sol: 3.2, likely 2.0 to 4.5
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.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio: Downloads grew just faster than the catalog baseline.
- dependents: ecosyste.ms indexed 217 repositories and seven packages.
- peers: The lowest reported peer repository count is 2,053.
- github.stars, bluesky.posts: 197 stars and zero tracked Bluesky posts.
Vouched for4.5
Who stands behind it being good?
Claude Opus 5.5: 3.0, likely 2.0 to 4.5
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.
- npmjs.com/package/csrf-sync: Sister package from the same author points to csrf-csrf for stateless use
- expressjs.com/en/blog/2025-05-16-express-cleanup-legacy-packages: Express deprecates csurf without naming a replacement
- hackerNews stories: No relevant discussion
GPT-6.2 Sol: 6.0, likely 4.7 to 7.3
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.
- docs.nestjs.com/security/csrf: NestJS names it for Express apps that need token-based protection.
- github.com/Ride-The-Lightning/RTL/releases/tag/v0.15.9: Ride The Lightning shipped a migration to session-bound csrf-csrf tokens.
- github.com/expressjs/express/discussions/5491: An adopter reported a working migration and described the configuration changes.
Safe7.2
How safe is it to depend on?
Claude Opus 5.5: 7.0, likely 5.5 to 8.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.
- advisories: 1 low-severity advisory in 2022, none in the last 24 months
- npm dependencies: 1 runtime dependency
- scorecard: No OpenSSF Scorecard data
- npm license: ISC on npm; the GitHub licence field is null
GPT-6.2 Sol: 7.3, likely 5.9 to 8.5
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.
- npm.dependencies, npm.license: One direct runtime dependency and an ISC license.
- github.com/advisories/GHSA-jjmg-x456-w976: Documents the low-severity issue and its patch.
- github.com/Psifi-Solutions/csrf-csrf/pull/128: The timing-safe change passed four checks and had no listed review.
- advisories.last24Months, scorecard: Zero advisories in the past two years and no Scorecard result.
- summary.ecosyste.ms/projects/383366: One npm maintainer is listed.
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
- npm downloads, 4 weeks
- 1.1M ×4.2 in a year
- GitHub stars
- 197
- Commits, 12 months
- 3
- npm version
- 4.1.0 Nov 2026
- Versions, 12 months
- 1
- Advisories, 24 months
- 0 of 1 ever
- OpenSSF Scorecard
- None
- Licence
- ISC
Read on 21 November 2026 from GitHub (Psifi-Solutions/csrf-csrf), npm (csrf-csrf), OSV and the OpenSSF Scorecard.
Web security libraries
- 8.7DOMPurify
- 8.2Helmet
- 7.9express-rate-limit
- 7.6cors
- 7.4rate-limiter-flexible
- 7.0Upstash Ratelimit
- 6.8sanitize-html
- 6.1csrf-csrf
- 5.7Arcjet
- 5.0js-xss