[Security 9/9] Backend ESLint security rules, tiered to stay credible - #252
Open
amal66 wants to merge 1 commit into
Open
[Security 9/9] Backend ESLint security rules, tiered to stay credible#252amal66 wants to merge 1 commit into
amal66 wants to merge 1 commit into
Conversation
eslint-plugin-security in a flat config over backend/src. Rules that only fire on genuinely unsafe APIs are errors (CI-blocking via the security-lint workflow); heuristic detectors stay warnings. Currently 0 errors / 131 warnings on main. Lockfile regenerated on current main. Adapted-from: Open-Legal-Products#227 (16ad9ac, 46eefc2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[Security 9/9] Backend ESLint security rules, tiered so the gate stays credible
TL;DR
Add
eslint-plugin-securityin a flat config overbackend/src, wired to a CI job. Rules that only fire on genuinely unsafe APIs (evalwith an expression,new Buffer,pseudoRandomBytes, buffernoassert) are errors that block CI; heuristic detectors (object injection, non-literalfs/regex, timing attacks) are warnings that inform review. Currently 0 errors / 131 warnings onmain.Risk to user data
Severity: preventive. Static analysis doesn't fix a live breach; it stops whole classes of the bugs the other eight PRs fix by hand from being reintroduced.
pseudoRandomBytesfor a token,evalon user input, an unauthenticatednew Buffer(n)— these are the raw material of the SSRF, crypto, and injection issues addressed elsewhere in this split. A gate catches them at PR time instead of in production.Flows affected
.github/workflows/security-lint.yml,npm run lint).Attack precedent — on the process
The failure mode here isn't an exploit, it's alert fatigue: a linter that cries wolf gets ignored, then disabled, then catches nothing. The security detectors are heuristic and false-positive on legitimate code (e.g.
detect-object-injectionfires on anyobj[variable]). A gate that's 90% noise trains reviewers to rubber-stamp.Possible fixes, and what we chose
eval-on-expression sails through. Rejected.flowchart TD R["eslint-plugin-security rule fires"] --> P{fires only on a<br/>genuinely unsafe API?} P -- "yes<br/>(eval-expr, new Buffer,<br/>pseudoRandomBytes, noassert)" --> E["ERROR → fails CI"] P -- "no<br/>(heuristic: object injection,<br/>non-literal fs/regex, timing)" --> W["warning → informs review,<br/>never blocks"]The principle generalizes past linters: a security gate's credibility is a resource you can spend, and a noisy blocking gate spends it to zero. Precision-tier before you make anything blocking.
What's in this PR
backend/eslint.config.mjs— flat config, tiered rules (new).backend/package.json+ lockfile — eslint toolchain (lockfile regenerated on currentmain)..github/workflows/security-lint.yml— CI job runningnpm run lint.Reading
eslint-plugin-security · OWASP: static analysis (SAST)