Skip to main content
← SproulTech

How to find every RSA use in a JS/TS codebase

Run npx github:1Aa1k/cupel --check --forbid-rsa from the repo root. Cupel is a free, open-source scanner for JavaScript/TypeScript, Python, Go and Java that lists every RSA form it knows, here shown for JS/TS: rsa-sha256, RS256, PS256, rsa-oaep, rsa-pss, sha256WithRSAEncryption, publicEncrypt and privateDecrypt. It exits 1 on a hit, so it also works as a CI gate.

By Nate Sproul, software engineer · Updated December 2, 2026

What does the command catch?

Cupel walks your source tree and lists each place that hashes, signs, verifies, encrypts, exchanges keys or derives keys. The flag --forbid-rsa makes --check fail on any RSA form, which a plain --forbid rsa would not, because that only matches the exact string rsa.

  • rsa-sha256 and other RSA signing algorithms passed to Node's createSign.
  • RS256 and PS256 in jose and jsonwebtoken calls.
  • rsa-oaep, rsa-pss and sha256WithRSAEncryption.
  • publicEncrypt and privateDecrypt, which imply RSA.
  • Run it from the root of the code you want to scan, or pass paths. Add --json for machine-readable output, or --report for a summary grouped by risk family.

How do you run it in CI?

Add one step to a GitHub Actions job. Because it exits 1 when it finds a forbidden call, the job fails and RSA cannot return unnoticed after you remove it.

  • - uses: actions/setup-node@v4 with node-version: 20.
  • - run: npx github:1Aa1k/cupel --check --forbid-rsa. This is the README's CI step with the RSA flag added.
  • To keep all algorithm choices in one helper module, allow it with --allow src/crypto (or allowDirs in cupel.config.json) and plain --check fails on a crypto call anywhere else.

What does a line-based scan miss?

Cupel is line-based pattern matching, not a parser. It does not build a syntax tree or follow data flow. Treat a pass as no known pattern found, not as proof that no RSA exists. The README lists these limits:

  • A match inside a comment or a string literal counts as a finding.
  • The algorithm argument is only looked for in the few lines after the opening parenthesis, so a call split oddly across lines can be missed or misread.
  • An algorithm built from strings or passed through a variable is reported as dynamic, never resolved.
  • Aliased imports are only followed for node:crypto named imports and requires. A function re-exported or wrapped by another module is not seen.
  • crypto.sign and crypto.verify take their algorithm from the key, so they read dynamic.
  • JWT algorithms are only read from alg, algorithm and algorithms string literals near jose and jsonwebtoken calls.
  • Files with a NUL byte, files over 2 MB and files with a line over 20,000 characters (minified bundles) are skipped and listed as skipped. Symlinks are not followed. node_modules, dist, build, coverage and .next are not scanned.
  • JavaScript and TypeScript files are read (.ts, .tsx, .js, .jsx, .mjs, .cjs, .mts and .cts), along with .py, .go and .java files. This guide covers the JS/TS patterns; for Python, Go and Java see the Cupel README.

Where does RSA hide outside the code?

A source scan cannot see keys and certificates that live outside your repo. Check these separately; the RSA exit plan gives a way to find each.

  • TLS certificates, including internal services.
  • SSH keys of type ssh-rsa.
  • Your JWKS endpoint: any key with kty RSA. To replace those tokens, follow How to replace RS256 JWTs.
  • DNSSEC zones signed with RSA.
  • Recorded TLS sessions that used RSA key exchange.

What happens after you have the list?

Route every hit through one helper, swap each use to what fits what it protects, and keep the CI step so it stays that way. SproulTech did this on its own site; the write-up is the crypto agility case study.

The scanner is MIT licensed and public, so you can read it before you run it: Cupel on GitHub. If you want the swap done for you, the fix sprint is $2,500 per repo for up to 25 RSA call sites, plus $75 for each site after that. Details on the RSA exit page.

Questions

Does a clean Cupel run prove my code has no RSA?
No. It is line-based pattern matching, so a clean run means no known pattern was found. Dynamic algorithm names, wrapped functions and skipped files can hide RSA from it.
Why --forbid-rsa and not --forbid rsa?
--forbid rsa only matches the exact string rsa. --forbid-rsa catches rsa, rsa-sha256, RS256 and PS256, rsa-oaep, rsa-pss, sha256WithRSAEncryption, and publicEncrypt and privateDecrypt.
Does Cupel send my code anywhere?
No. It runs on your machine and reads files from disk. The source is public, so you can read it first.

Send a few lines about the codebase and where it hashes, signs or encrypts things. The reply comes from the engineer who would do the work.

nate@sproultech.com