@lintsure/core 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.js +79 -4
- package/dist/src/knowledge/owasp-top10.js +6 -6
- package/dist/src/review.js +3 -2
- package/dist/src/rules/index.js +2 -0
- package/dist/src/rules/more.d.ts +4 -0
- package/dist/src/rules/more.js +70 -0
- package/dist/src/rules/owasp.js +6 -4
- package/docs/README.md +1 -1
- package/docs/agents.md +1 -1
- package/docs/frameworks.md +7 -7
- package/docs/rules.md +84 -2
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { toAssessmentHtml } from "./assessment.js";
|
|
|
13
13
|
export * from "./knowledge/index.js";
|
|
14
14
|
export { loadPacks, registerPack, type Pack } from "./packs.js";
|
|
15
15
|
export { checksFor } from "./plan.js";
|
|
16
|
-
export declare const RULES_VERSION = "0.3.
|
|
16
|
+
export declare const RULES_VERSION = "0.3.12";
|
|
17
17
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
18
18
|
export declare const DISCLAIMER: string;
|
|
19
19
|
/** What a report must never be read as. Used in the report and by the MCP server. */
|
|
@@ -59,6 +59,10 @@ export declare const NON_SHIPPING: RegExp;
|
|
|
59
59
|
export declare function isNonShipping(file: string): boolean;
|
|
60
60
|
/** The JSON object key that opens the block a line sits in, e.g. "peerDependencies". Pure. */
|
|
61
61
|
export declare function enclosingKey(lines: string[], i: number): string;
|
|
62
|
+
export declare function exampleLines(lines: string[], ext: string): boolean[];
|
|
63
|
+
export declare function taintedNames(lines: string[]): Map<string, number>;
|
|
64
|
+
export declare function hopLine(lines: string[], i: number, names: Map<string, number>): string | null;
|
|
65
|
+
export declare const blankStrings: (l: string) => string;
|
|
62
66
|
export interface Statement {
|
|
63
67
|
start: number;
|
|
64
68
|
end: number;
|
package/dist/src/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { loadPacks, registerPack } from "./packs.js";
|
|
|
22
22
|
export { checksFor } from "./plan.js";
|
|
23
23
|
import { configPacks, loadPacks, packFrameworks, packsLoaded } from "./packs.js";
|
|
24
24
|
import { buildGraph, declaredEntries, reachOf } from "./reach.js";
|
|
25
|
-
export const RULES_VERSION = "0.3.
|
|
25
|
+
export const RULES_VERSION = "0.3.12";
|
|
26
26
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
27
27
|
export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
|
|
28
28
|
"Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
|
|
@@ -222,6 +222,64 @@ export function enclosingKey(lines, i) {
|
|
|
222
222
|
}
|
|
223
223
|
return "";
|
|
224
224
|
}
|
|
225
|
+
// Example code that shows a pattern instead of running it (benchmark "fp" cases, self-scan 2026-11-19): a fenced block
|
|
226
|
+
// in a doc, a value under an example-style key in JSON data. Only secret rules still look, and only for a real-looking key.
|
|
227
|
+
const EXAMPLE_KEY = /^(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)$/i;
|
|
228
|
+
const EXAMPLE_KEY_ON_LINE = /"(?:examples?|code|snippets?|samples?|bad|good|before|after|demo|patch|diff|dont|do)"\s*:/i;
|
|
229
|
+
export function exampleLines(lines, ext) {
|
|
230
|
+
if (ext === ".md" || ext === ".mdx") {
|
|
231
|
+
let fence = false;
|
|
232
|
+
return lines.map((l) => { if (/^\s*(```|~~~)/.test(l)) {
|
|
233
|
+
fence = !fence;
|
|
234
|
+
return true;
|
|
235
|
+
} return fence; });
|
|
236
|
+
}
|
|
237
|
+
if (ext === ".json")
|
|
238
|
+
return lines.map((l, i) => EXAMPLE_KEY_ON_LINE.test(l) || EXAMPLE_KEY.test(enclosingKey(lines, i)));
|
|
239
|
+
return lines.map(() => false);
|
|
240
|
+
}
|
|
241
|
+
// Call-sink rules whose match must come from code, not from text inside a '...' or "..." string (a demo diff stored as
|
|
242
|
+
// data). Template literals are left alone: `exec(\`zip ${req.body.f}\`)` is real code.
|
|
243
|
+
// One hop of request data (benchmark "hop" cases): a request value saved in `target`, then `target` passed to a URL call. Variables assigned from
|
|
244
|
+
// the request are found per file, and a later line is reread with the request value written in place. A variable that is
|
|
245
|
+
// checked before use (startsWith, includes, a comparison, a test) is left alone. Hits are Partial: the hop is a guess.
|
|
246
|
+
// shortcut: one assignment hop inside one file, no reassignment or function-argument flow; upgrade to a real data-flow pass if recall stays low.
|
|
247
|
+
const HOP_RULES = new Set(["ssrf.user-url", "redirect.open", "path.user-input"]);
|
|
248
|
+
const REQ_VALUE = /\b(?:req\.(?:body|query|params|headers|cookies)|request\.(?:args|form|json|data|GET|POST|query_params|files)|ctx\.query|event\.(?:body|queryStringParameters)|searchParams\.get)\b/;
|
|
249
|
+
export function taintedNames(lines) {
|
|
250
|
+
const out = new Map();
|
|
251
|
+
lines.forEach((l, i) => {
|
|
252
|
+
if (!REQ_VALUE.test(l) && ![...out.keys()].some((n) => new RegExp(`\\b${n}\\b`).test(l.split("=").slice(1).join("="))))
|
|
253
|
+
return;
|
|
254
|
+
const m = l.match(/^\s*(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::[^=]+)?=(?!=)/) ?? l.match(/^\s*(\w+)\s*=(?!=)/);
|
|
255
|
+
const d = l.match(/^\s*(?:const|let|var)\s*\{([^}]+)\}\s*=/);
|
|
256
|
+
if (m)
|
|
257
|
+
out.set(m[1], i);
|
|
258
|
+
if (d)
|
|
259
|
+
for (const n of d[1].split(",")) {
|
|
260
|
+
const k = n.split(":").pop().split("=")[0].trim();
|
|
261
|
+
if (/^\w+$/.test(k))
|
|
262
|
+
out.set(k, i);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return out;
|
|
266
|
+
}
|
|
267
|
+
export function hopLine(lines, i, names) {
|
|
268
|
+
let t = lines[i], changed = false;
|
|
269
|
+
for (const [n, at] of names) {
|
|
270
|
+
if (at >= i || !new RegExp(`\\b${n}\\b`).test(t))
|
|
271
|
+
continue;
|
|
272
|
+
const checked = lines.slice(at + 1, i).some((l) => new RegExp(`\\b${n}\\s*(?:\\.(?:startsWith|endsWith|includes|match|test)\\(|[!=]==?)|\\b(?:allow\\w*|isValid\\w*|is_safe\\w*|validate\\w*)\\(\\s*${n}\\b|\\.(?:has|includes|test)\\(\\s*${n}\\b`).test(l));
|
|
273
|
+
if (checked)
|
|
274
|
+
continue;
|
|
275
|
+
t = t.replace(new RegExp(`(?<![.\\w])${n}\\b`, "g"), "req.query." + n);
|
|
276
|
+
changed = true;
|
|
277
|
+
}
|
|
278
|
+
return changed ? t : null;
|
|
279
|
+
}
|
|
280
|
+
const PROMPT_DOC = /(^|\/)(?:prompts?|personas?|instructions?|system)(?:\/|[._-])|(^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL|SYSTEM|PROMPT)\.mdx?$|\.prompt\.mdx?$|(^|\/)\.(?:github|cursor|claude)\//i;
|
|
281
|
+
const SINK_RULES = new Set(["path.user-input", "ssrf.user-url", "redirect.open", "code.eval", "cmd.shell-built", "deserialize.unsafe"]);
|
|
282
|
+
export const blankStrings = (l) => l.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, (m) => m[0] + m[0]);
|
|
225
283
|
const HASH_COMMENTS = new Set([".py", ".rb", ".sh", ".yml", ".yaml", ".toml", ".env"]);
|
|
226
284
|
const C_LIKE = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".java", ".kt", ".swift", ".go", ".css", ".scss"]);
|
|
227
285
|
// Statement window (review step A): formatters split one call over several lines, and a rule that reads one line
|
|
@@ -234,7 +292,9 @@ const JOIN_RULES = new Set(["pii.logged", "pii.to-analytics", "log.injection", "
|
|
|
234
292
|
"ssrf.user-url", "path.user-input", "redirect.open", "nosql.operator-input", "template.user-string", "error.stack-to-client",
|
|
235
293
|
// Narrow call-plus-value patterns, where unrelated parts of a statement rarely complete a match.
|
|
236
294
|
"transport.plain-http", "transport.tls-verify-off", "jwt.unverified", "crypto.weak-cipher", "fs.world-writable",
|
|
237
|
-
"mobile.token-in-plain-storage", "config.debug-on", "cookie.trusted-role", "code.eval"
|
|
295
|
+
"mobile.token-in-plain-storage", "config.debug-on", "cookie.trusted-role", "code.eval",
|
|
296
|
+
// Added with rules/more.ts: call-plus-argument shapes, measured on the robustness check only (not yet on the 139 repos).
|
|
297
|
+
"authz.no-owner-check", "jwt.weak-secret", "jwt.no-algorithm-pin", "proto.pollution"]);
|
|
238
298
|
const MAX_JOIN_LINES = 25, MAX_JOIN_CHARS = 2000;
|
|
239
299
|
/** Groups lines into statements: lines join while a ( or [ or a template literal is open. Joining stops at a function
|
|
240
300
|
* body (`=> {`, `) {`), so a handler passed as an argument stays line by line. `prose` marks a multi-line template
|
|
@@ -488,7 +548,8 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
|
|
|
488
548
|
const inTests = isNonShipping(file);
|
|
489
549
|
if (inTests)
|
|
490
550
|
nonShipping++;
|
|
491
|
-
const comment = commentLines(lines, ext);
|
|
551
|
+
const comment = commentLines(lines, ext), example = exampleLines(lines, ext);
|
|
552
|
+
let tainted;
|
|
492
553
|
// Statements are worked out once per file, on lines with comments blanked.
|
|
493
554
|
const stmts = JOINABLE.has(ext) ? statements(lines.map((l, i) => (comment[i] ? "" : l)), ext === ".py") : [];
|
|
494
555
|
const multi = stmts.filter((s) => s.end > s.start);
|
|
@@ -498,6 +559,9 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
|
|
|
498
559
|
for (let i = s.start; i <= s.end; i++)
|
|
499
560
|
prose[i] = true;
|
|
500
561
|
for (const r of relevant) {
|
|
562
|
+
// A markdown page that explains the rule quotes the bad prompt; only prompt files hold real prompts.
|
|
563
|
+
if (r.id === "ai.hides-being-ai" && (ext === ".md" || ext === ".mdx") && !PROMPT_DOC.test(file))
|
|
564
|
+
continue;
|
|
501
565
|
const secret = SECRET_RULES.has(r.id);
|
|
502
566
|
if (inTests && !secret && !TOOLING_RULES.has(r.id))
|
|
503
567
|
continue;
|
|
@@ -515,7 +579,18 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
|
|
|
515
579
|
lines.forEach((text, i) => {
|
|
516
580
|
if (skip?.[i] || (prose[i] && !readsText))
|
|
517
581
|
return;
|
|
518
|
-
|
|
582
|
+
if (example[i] && !(secret && !PLACEHOLDER.test(text)))
|
|
583
|
+
return;
|
|
584
|
+
let hit = r.test(text), probe = text;
|
|
585
|
+
if (!hit && HOP_RULES.has(r.id)) {
|
|
586
|
+
const h = hopLine(lines, i, (tainted ??= taintedNames(lines)));
|
|
587
|
+
if (h && r.test(h)) {
|
|
588
|
+
hit = "partial";
|
|
589
|
+
probe = h;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (hit && SINK_RULES.has(r.id) && !r.test(blankStrings(probe)))
|
|
593
|
+
return;
|
|
519
594
|
if (!hit || (r.unlessNear && lines.slice(Math.max(0, i - 8), i + 4).some((l) => r.unlessNear.test(l))))
|
|
520
595
|
return;
|
|
521
596
|
if (r.unlessInKey && r.unlessInKey.test(enclosingKey(lines, i)))
|
|
@@ -16,14 +16,14 @@ export const owaspTop10 = {
|
|
|
16
16
|
},
|
|
17
17
|
obligations: [
|
|
18
18
|
{ ref: "A01:2025", title: "Broken Access Control", inCode: "partly",
|
|
19
|
-
rules: ["path.user-input", "redirect.open", "ssrf.user-url", "csrf.disabled", "fs.world-writable", "cors.any-origin", "cookie.trusted-role", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth"],
|
|
19
|
+
rules: ["path.user-input", "redirect.open", "ssrf.user-url", "csrf.disabled", "fs.world-writable", "cors.any-origin", "cookie.trusted-role", "supabase.rls-disabled", "supabase.policy-allows-all", "supabase.service-key-in-client", "supabase.function-no-auth", "authz.no-owner-check", "ws.no-origin-check", "cloud.public-bucket"],
|
|
20
20
|
plain: "People must only reach the data and actions meant for them. This covers file paths, redirects, requests your server makes on a user's behalf (SSRF), forged requests from other sites, and permissions kept where users can change them.",
|
|
21
21
|
evidence: "A list of roles and what each may do, and tests showing one user can't read or change another user's data." },
|
|
22
22
|
{ ref: "A01:2025 (ownership checks)", title: "Every record is checked against the signed-in user", inCode: "no",
|
|
23
23
|
plain: "Whether each endpoint checks that the record belongs to the person asking (often called IDOR). A line-by-line code check can't tell; it needs design review and testing with two accounts.",
|
|
24
24
|
evidence: "Access control tests per role, or a penetration test report." },
|
|
25
25
|
{ ref: "A02:2025", title: "Security Misconfiguration", inCode: "partly",
|
|
26
|
-
rules: ["config.debug-on", "agent.permissions-allow-all", "config.allowed-hosts-any", "config.default-secret-key", "xml.external-entities", "cors.any-origin", "session.cookie-insecure", "error.stack-to-client", "build.sourcemaps-public", "release.env-not-ignored"],
|
|
26
|
+
rules: ["config.debug-on", "agent.permissions-allow-all", "config.allowed-hosts-any", "config.default-secret-key", "xml.external-entities", "cors.any-origin", "session.cookie-insecure", "error.stack-to-client", "build.sourcemaps-public", "release.env-not-ignored", "k8s.privileged", "graphql.introspection"],
|
|
27
27
|
plain: "Safe settings by default: debug off, real host names, strong secret keys, cookies marked secure, XML parsers that don't load outside files, and errors that don't reveal internals.",
|
|
28
28
|
evidence: "Production configuration and a hardening checklist." },
|
|
29
29
|
{ ref: "A02:2025 (deployed settings)", title: "Server, cloud and header configuration in production", inCode: "no",
|
|
@@ -37,7 +37,7 @@ export const owaspTop10 = {
|
|
|
37
37
|
plain: "Whether any dependency version has a published vulnerability, and whether it's maintained. This needs vulnerability advisory data, which Lintsure doesn't download, so use a dependency scanner alongside it.",
|
|
38
38
|
evidence: "Dependency scanner results (for example npm audit, OSV-Scanner or Dependabot) and how alerts are handled." },
|
|
39
39
|
{ ref: "A04:2025", title: "Cryptographic Failures", inCode: "yes",
|
|
40
|
-
rules: ["crypto.weak-password-hash", "crypto.weak-random-token", "crypto.weak-cipher", "jwt.unverified", "transport.plain-http", "transport.tls-verify-off", "secret.in-source", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic"],
|
|
40
|
+
rules: ["crypto.weak-password-hash", "crypto.weak-random-token", "crypto.weak-cipher", "jwt.unverified", "transport.plain-http", "transport.tls-verify-off", "secret.in-source", "secret.public-env", "mobile.token-in-plain-storage", "mobile.cleartext-traffic", "jwt.weak-secret", "crypto.unsafe-compare"],
|
|
41
41
|
plain: "Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code.",
|
|
42
42
|
evidence: "Where data is encrypted in transit and at rest, and how keys are stored and rotated." },
|
|
43
43
|
{ ref: "A04:2025 (key management)", title: "Key management and encryption at rest", inCode: "no",
|
|
@@ -48,21 +48,21 @@ export const owaspTop10 = {
|
|
|
48
48
|
plain: "Keep data and code apart, so input can't become part of a SQL query, a shell command, a template, HTML on the page or code that gets run.",
|
|
49
49
|
evidence: "Use of parameterised queries, output escaping, and code review practice." },
|
|
50
50
|
{ ref: "A06:2025", title: "Insecure Design", inCode: "partly",
|
|
51
|
-
rules: ["upload.unrestricted", "mass-assignment", "pii.in-url", "mobile.webview-any-origin"],
|
|
51
|
+
rules: ["upload.unrestricted", "mass-assignment", "pii.in-url", "mobile.webview-any-origin", "html.tabnabbing"],
|
|
52
52
|
plain: "Security planned in from the start: limits on uploads, only the fields users may change, sensitive data kept out of URLs. Most of this category is about design, not individual lines.",
|
|
53
53
|
evidence: "Design notes for sensitive features." },
|
|
54
54
|
{ ref: "A06:2025 (threat modelling)", title: "Threat modelling and abuse cases", inCode: "no",
|
|
55
55
|
plain: "Thinking through how a feature could be misused before building it: rate limits, business rule abuse, trust boundaries. Code checks can't show whether this happened.",
|
|
56
56
|
evidence: "Threat models or security design reviews for key features." },
|
|
57
57
|
{ ref: "A07:2025", title: "Authentication Failures", inCode: "partly",
|
|
58
|
-
rules: ["auth.hardcoded-password", "jwt.no-expiry", "jwt.unverified", "config.default-secret-key", "session.cookie-insecure", "secret.in-source", "transport.tls-verify-off", "auth.no-rate-limit"],
|
|
58
|
+
rules: ["auth.hardcoded-password", "jwt.no-expiry", "jwt.unverified", "config.default-secret-key", "session.cookie-insecure", "secret.in-source", "transport.tls-verify-off", "auth.no-rate-limit", "jwt.no-algorithm-pin", "jwt.weak-secret"],
|
|
59
59
|
plain: "Logins and sessions that hold up: no passwords in code, strong secrets, tokens that expire and are verified, and session cookies protected from scripts and plain HTTP.",
|
|
60
60
|
evidence: "Login, session and token settings." },
|
|
61
61
|
{ ref: "A07:2025 (login protections)", title: "Brute-force protection, MFA and account recovery", inCode: "no",
|
|
62
62
|
plain: "Rate limiting and lockout on login, multi-factor authentication, and safe password reset flows. These need testing against the running app.",
|
|
63
63
|
evidence: "Login rate limit settings, MFA options, and password reset flow tests." },
|
|
64
64
|
{ ref: "A08:2025", title: "Software or Data Integrity Failures", inCode: "partly",
|
|
65
|
-
rules: ["deserialize.unsafe", "html.script-no-sri", "mass-assignment", "cookie.trusted-role", "ci.prt-checkout-head"],
|
|
65
|
+
rules: ["deserialize.unsafe", "html.script-no-sri", "mass-assignment", "cookie.trusted-role", "ci.prt-checkout-head", "proto.pollution"],
|
|
66
66
|
plain: "Don't trust code or data you haven't checked: no unsafe deserialisation, integrity checks on third-party scripts, and no trust in values users can change.",
|
|
67
67
|
evidence: "How third-party scripts are loaded and how incoming data is parsed." },
|
|
68
68
|
{ ref: "A08:2025 (signed releases)", title: "Signed builds and updates", inCode: "no",
|
package/dist/src/review.js
CHANGED
|
@@ -18,8 +18,9 @@ export function toBaseline(r, created) {
|
|
|
18
18
|
export function parseAccepted(text) {
|
|
19
19
|
const out = [];
|
|
20
20
|
for (const raw of text.split(/\r?\n/)) {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const hash = raw.search(/(^|\s)#/); // linear: a long run of spaces can't make it backtrack
|
|
22
|
+
const line = hash < 0 ? raw : raw.slice(0, hash);
|
|
23
|
+
const m = line.match(/^([ \t]*)(-[ \t]+)?([a-z_]+)[ \t]*:(.*)$/);
|
|
23
24
|
if (!m)
|
|
24
25
|
continue;
|
|
25
26
|
if (m[2])
|
package/dist/src/rules/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { owaspForExisting, owaspRules } from "./owasp.js";
|
|
2
2
|
import { stackRules } from "./stack.js";
|
|
3
|
+
import { moreRules } from "./more.js";
|
|
3
4
|
import { craForExisting, craRules } from "./cra.js";
|
|
4
5
|
import { standardsForExisting, standardsRules } from "./standards.js";
|
|
5
6
|
const CODE = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py"];
|
|
@@ -390,6 +391,7 @@ rules.push({
|
|
|
390
391
|
for (const r of rules)
|
|
391
392
|
r.controls.push(...(owaspForExisting[r.id] ?? []));
|
|
392
393
|
rules.push(...owaspRules);
|
|
394
|
+
rules.push(...moreRules);
|
|
393
395
|
// Supabase, Next.js and Vite: open databases and secrets reaching the browser.
|
|
394
396
|
rules.push(...stackRules);
|
|
395
397
|
for (const r of rules)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Rule } from "../types.js";
|
|
2
|
+
/** Lines that start a web-socket server in a file with no origin check (verifyClient, an origin test, allowRequest). Pure. */
|
|
3
|
+
export declare function wsNoOrigin(lines: string[]): number[];
|
|
4
|
+
export declare const moreRules: Rule[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const CODE = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py"];
|
|
2
|
+
const JS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
3
|
+
const MARKUP = [...CODE, ".html", ".vue", ".svelte", ".astro"];
|
|
4
|
+
const DRAFT = { mappedBy: "beta", reviewedAt: "pending" };
|
|
5
|
+
const A = (n, title) => ({ framework: "owasp-top10", id: `A${n}:2025`, title });
|
|
6
|
+
const A01 = A("01", "Broken Access Control"), A02 = A("02", "Security Misconfiguration"), A04 = A("04", "Cryptographic Failures"), A06 = A("06", "Insecure Design"), A07 = A("07", "Authentication Failures"), A08 = A("08", "Software or Data Integrity Failures");
|
|
7
|
+
const rule = (r) => ({ ...r, ...DRAFT });
|
|
8
|
+
// A record looked up by an id from the request, with nothing on or near the line that ties it to the signed-in user.
|
|
9
|
+
const BY_REQUEST_ID = /\b(findUnique|findUniqueOrThrow|findFirst|findById|findByPk|findOne|findOneBy|get_object_or_404)\s*\([^;]*\b(req\.(params|query|body)|request\.(args|view_args|json)|params)\b[^;]*\bid\b|\.objects\.get\([^)]*\b(id|pk)\s*=\s*request\./;
|
|
10
|
+
const OWNER = /\b(userId|user_id|ownerId|owner_id|owner|tenantId|tenant_id|orgId|org_id|accountId|account_id|req\.user|request\.user|session\.user|currentUser|authorize|can\(|policy|permission)\b/;
|
|
11
|
+
// A web-socket server that never looks at where the connection came from.
|
|
12
|
+
const WS_SERVER = /\bnew\s+(WebSocketServer|WebSocket\.Server|WSServer)\s*\(|\bnew\s+Server\s*\([^)]*\bcors\b|\bio\s*=\s*new\s+Server\s*\(/;
|
|
13
|
+
/** Lines that start a web-socket server in a file with no origin check (verifyClient, an origin test, allowRequest). Pure. */
|
|
14
|
+
export function wsNoOrigin(lines) {
|
|
15
|
+
const text = lines.join("\n");
|
|
16
|
+
if (/\bverifyClient\b|\borigin\b|\ballowRequest\b|\bnoServer\s*:\s*true/.test(text))
|
|
17
|
+
return [];
|
|
18
|
+
return lines.flatMap((l, i) => (WS_SERVER.test(l) ? [i + 1] : []));
|
|
19
|
+
}
|
|
20
|
+
// Both sides of a comparison look like a secret value: a signature, token or key against an expected one.
|
|
21
|
+
const SECRETISH = String.raw `[\w.$\[\]"'-]*(?:signature|token|secret|hmac|digest|api_?key|apikey|password_hash)[\w.\[\]"'-]*`;
|
|
22
|
+
const UNSAFE_COMPARE = new RegExp(String.raw `(?<![\w.])${SECRETISH}\s*(?:===?|!==?)\s*${SECRETISH}`, "i");
|
|
23
|
+
export const moreRules = [
|
|
24
|
+
rule({ id: "authz.no-owner-check", title: "Record loaded by an id from the request, with no owner check", status: "partial", severity: "high", controls: [A01],
|
|
25
|
+
fix: "Look the record up by its id and the signed-in user (or tenant) together, for example where: { id, userId: req.user.id }, or check the owner before returning it.",
|
|
26
|
+
note: "Anyone who changes the id in the URL can read or change someone else's record (insecure direct object reference, CWE-639).", extensions: CODE,
|
|
27
|
+
unseen: "Lintsure can't see checks done in middleware or another function, so the owner may already be verified.",
|
|
28
|
+
confidence: "medium",
|
|
29
|
+
test: (l) => BY_REQUEST_ID.test(l) && !OWNER.test(l),
|
|
30
|
+
unlessNear: OWNER }),
|
|
31
|
+
rule({ id: "jwt.no-algorithm-pin", title: "Token verified without saying which algorithm is allowed", status: "partial", severity: "medium", controls: [A07],
|
|
32
|
+
fix: "Pass the algorithm you sign with, for example jwt.verify(token, key, { algorithms: [\"RS256\"] }), or algorithms=[\"HS256\"] in PyJWT.",
|
|
33
|
+
note: "Without a fixed list, some library versions accept a token signed with a different algorithm than you meant, for example one signed with your public key (CWE-347).", extensions: CODE,
|
|
34
|
+
test: (l) => /\bjwt\.verify\(\s*[^,()]+,\s*[^,()]+\)/.test(l) || /\bjwt\.decode\(\s*[\w.]+\s*,\s*[\w."']+\s*\)/.test(l) }),
|
|
35
|
+
rule({ id: "jwt.weak-secret", title: "Token signed with a short secret written in the code", status: "gap", severity: "high", controls: [A04, A07],
|
|
36
|
+
fix: "Read the signing key from the environment or a secret store, and make it at least 32 random bytes.",
|
|
37
|
+
note: "Anyone who reads the code, or guesses a short key, can sign their own login tokens (CWE-798, CWE-521).", extensions: CODE,
|
|
38
|
+
test: (l) => /\bjwt\.(sign|verify|encode|decode)\(\s*(?:\{[^{}]*\}|[^,(){}]+)\s*,\s*["'][^"']{1,31}["']/.test(l) }),
|
|
39
|
+
rule({ id: "proto.pollution", title: "Request data deep-merged into an object", status: "gap", severity: "high", controls: [A08],
|
|
40
|
+
fix: "Copy only the fields you expect, or validate the body with a schema first. If you must merge, drop __proto__, constructor and prototype keys.",
|
|
41
|
+
note: "A body like {\"__proto__\": {\"isAdmin\": true}} can change every object in the app (prototype pollution, CWE-1321).", extensions: JS,
|
|
42
|
+
test: (l) => /(?:\b(?:_\.merge|_\.mergeWith|_\.defaultsDeep|deepmerge|deepMerge|mergeDeep|merge)\s*\(|\$\.extend\(\s*true\s*,)[^;]*\b(req\.(body|query)|request\.(body|json))/.test(l) }),
|
|
43
|
+
rule({ id: "html.tabnabbing", title: "Link opens a new tab without rel=\"noopener\"", status: "partial", severity: "low", controls: [A06],
|
|
44
|
+
fix: "Add rel=\"noopener noreferrer\" to links with target=\"_blank\".",
|
|
45
|
+
note: "Current browsers already treat target=\"_blank\" as noopener, so this matters mainly for older browsers and webviews: the opened page could redirect your tab (CWE-1022).", extensions: MARKUP,
|
|
46
|
+
test: (l) => /\btarget\s*=\s*\{?\s*["']_blank["']/.test(l) && !/\brel\s*=\s*\{?\s*["'][^"']*\bno(opener|referrer)\b/.test(l) }),
|
|
47
|
+
rule({ id: "ws.no-origin-check", title: "Web-socket server with no origin check", status: "partial", severity: "medium", controls: [A01],
|
|
48
|
+
fix: "Check the Origin header when a connection opens (verifyClient in ws, cors.origin or allowRequest in socket.io) and allow only your own sites.",
|
|
49
|
+
note: "Browsers don't stop other sites opening a web socket to you, so a page on any site can use a signed-in visitor's cookies against it (cross-site WebSocket hijacking, CWE-1385).", extensions: JS,
|
|
50
|
+
unseen: "Lintsure can't see an origin check done in a proxy or an upgrade handler in another file.",
|
|
51
|
+
fileTest: wsNoOrigin }),
|
|
52
|
+
rule({ id: "k8s.privileged", title: "Container runs privileged or shares the host", status: "gap", severity: "high", controls: [A02],
|
|
53
|
+
fix: "Remove privileged, hostNetwork, hostPID and hostIPC, set allowPrivilegeEscalation: false, and run as a non-root user.",
|
|
54
|
+
note: "A privileged container, or one sharing the host's network or processes, can take over the machine it runs on if it is broken into (CWE-250).", extensions: [".yml", ".yaml"],
|
|
55
|
+
test: (l) => /^\s*-?\s*(privileged|allowPrivilegeEscalation|hostNetwork|hostPID|hostIPC)\s*:\s*true\b/.test(l) || /^\s*-?\s*runAsUser\s*:\s*0\s*$/.test(l) }),
|
|
56
|
+
rule({ id: "cloud.public-bucket", title: "Storage bucket open to the public", status: "gap", severity: "high", controls: [A01],
|
|
57
|
+
fix: "Keep the bucket private and block public access. Share single files with short-lived signed URLs instead.",
|
|
58
|
+
note: "Anyone on the internet can list or download what's in a public bucket, and with write access, replace it (CWE-284).", extensions: [".tf", ".json", ".yml", ".yaml", ...CODE],
|
|
59
|
+
test: (l) => /\bacl\s*[:=]\s*["']public-read(-write)?["']/i.test(l) || /\bblock_?public_?(acls|policy)\s*[:=]\s*false\b/i.test(l) || /\bpublicReadAccess\s*:\s*true\b/.test(l) || /"Principal"\s*:\s*"\*"/.test(l) && /s3:|"Effect"\s*:\s*"Allow"/.test(l) }),
|
|
60
|
+
rule({ id: "crypto.unsafe-compare", title: "Secret compared with == instead of a constant-time check", status: "partial", severity: "medium", controls: [A04],
|
|
61
|
+
fix: "Use crypto.timingSafeEqual (Node) or hmac.compare_digest (Python) to compare signatures, tokens and keys.",
|
|
62
|
+
note: "A plain comparison stops at the first wrong character, so response times can leak the secret bit by bit (timing attack, CWE-208).", extensions: CODE,
|
|
63
|
+
confidence: "medium",
|
|
64
|
+
test: (l) => UNSAFE_COMPARE.test(l) && !/\b(null|undefined|typeof|length)\b|["']\s*\)?\s*$/.test(l.replace(/\/\/.*$/, "").split(/===?|!==?/)[1] ?? ""),
|
|
65
|
+
unlessNear: /timingSafeEqual|compare_digest|safeCompare|constantTime|secureCompare/ }),
|
|
66
|
+
rule({ id: "graphql.introspection", title: "GraphQL introspection switched on", status: "partial", severity: "low", controls: [A02],
|
|
67
|
+
fix: "Turn introspection off in production, for example introspection: process.env.NODE_ENV !== \"production\".",
|
|
68
|
+
note: "Introspection hands anyone a full map of your API, including fields you never meant to advertise (CWE-200).", extensions: CODE,
|
|
69
|
+
test: (l) => /\bintrospection\s*:\s*true\b/.test(l) }),
|
|
70
|
+
];
|
package/dist/src/rules/owasp.js
CHANGED
|
@@ -82,7 +82,9 @@ export const owaspRules = [
|
|
|
82
82
|
rule({ id: "path.user-input", title: "File path built from request data", status: "gap", severity: "high", controls: [A01],
|
|
83
83
|
fix: "Don't pass request values into file paths. Map the request to a known file name, or use path.basename and check the result stays inside the allowed folder.",
|
|
84
84
|
note: "A path like ../../etc/passwd lets someone read or overwrite files outside the folder you meant (path traversal, CWE-22).", extensions: CODE,
|
|
85
|
-
test: (l) => /\b(fs\.(readFile|readFileSync|createReadStream|writeFile|writeFileSync|unlink|unlinkSync)|res\.(sendFile|download)|send_file|send_from_directory|open)\s*\(/.test(l) && USER_INPUT.test(l)
|
|
85
|
+
test: (l) => /\b(fs\.(readFile|readFileSync|createReadStream|writeFile|writeFileSync|unlink|unlinkSync)|res\.(sendFile|download)|send_file|send_from_directory|open)\s*\(/.test(l) && USER_INPUT.test(l) ? true
|
|
86
|
+
// Unpacking an archive writes wherever its entry names point (zip slip), unless Python's filter= is set.
|
|
87
|
+
: /\.extractall\((?![^)]*\bfilter\s*=)|\.extractAllTo\(/.test(l) ? "partial" : false }),
|
|
86
88
|
rule({ id: "redirect.open", title: "Redirect to a URL taken from the request", status: "gap", severity: "medium", controls: [A01],
|
|
87
89
|
fix: "Redirect only to paths on your own site, or check the target against a list of allowed hosts.",
|
|
88
90
|
note: "Attackers send people a link to your site that bounces them to a phishing page (open redirect, CWE-601).", extensions: CODE,
|
|
@@ -90,7 +92,7 @@ export const owaspRules = [
|
|
|
90
92
|
rule({ id: "ssrf.user-url", title: "Server fetches a URL taken from the request", status: "gap", severity: "high", controls: [A01],
|
|
91
93
|
fix: "Don't let users choose the full URL your server calls. Allow only known hosts, and block internal addresses such as 169.254.169.254 and localhost.",
|
|
92
94
|
note: "Your server can be made to call internal services or cloud metadata on an attacker's behalf (server-side request forgery, CWE-918).", extensions: CODE,
|
|
93
|
-
test: (l) => /\b(fetch|axios(\.(get|post|request))?|got|requests\.(get|post|request)|httpx\.(get|post)|urlopen)\s*\(\s*(req\.(body|query|params)|request\.(args|json|form|GET|data))/.test(l) }),
|
|
95
|
+
test: (l) => /\b(fetch|axios(\.(get|post|request))?|got|requests\.(get|post|request)|httpx\.(get|post)|urlopen)\s*\(\s*(`\$\{\s*)?(req\.(body|query|params)|request\.(args|json|form|GET|data))/.test(l) }),
|
|
94
96
|
rule({ id: "csrf.disabled", title: "CSRF protection switched off", status: "partial", severity: "medium", controls: [A01],
|
|
95
97
|
fix: "Keep CSRF protection on for routes that use cookies. Turning it off is only safe for APIs that authenticate with a token header, not cookies.",
|
|
96
98
|
note: "Another site can make a logged-in user's browser submit forms to your app (cross-site request forgery, CWE-352).", extensions: CODE,
|
|
@@ -190,13 +192,13 @@ export const owaspRules = [
|
|
|
190
192
|
fix: "Verify tokens with jwt.verify (Node) or jwt.decode with a key and an explicit algorithms list (Python). Never allow the 'none' algorithm.",
|
|
191
193
|
note: "Without signature checks anyone can write their own token and claim to be any user (CWE-347).", extensions: CODE,
|
|
192
194
|
test: (l) => {
|
|
193
|
-
if (/verify_signature["']?\s*:\s*False|\bverify\s*=\s*False|algorithms\s*[:=]\s*\[
|
|
195
|
+
if (/verify_signature["']?\s*:\s*False|\bverify\s*=\s*False|algorithms\s*[:=]\s*\[[^\]]*["']none["']/i.test(l) && /jwt/i.test(l))
|
|
194
196
|
return true;
|
|
195
197
|
return /\bjwt\.decode\(\s*[\w.]+\s*\)/.test(l) ? "partial" : false; // Node jwt.decode reads a token without verifying it
|
|
196
198
|
},
|
|
197
199
|
// Peeking at a claim before verifying it nearby is fine (field test, 139 repos).
|
|
198
200
|
// Python peek-then-verify: a second decode with a key and an algorithms list nearby (review P21).
|
|
199
|
-
unlessNear: /\bjwt\.verify\(|\bjwtVerify\(|\bverify(Token|Jwt|JWT)\(|\bjwt\.decode\([^)]*\balgorithms\s*=/ }),
|
|
201
|
+
unlessNear: /\bjwt\.verify\((?![^\n]*["']none["'])|\bjwtVerify\(|\bverify(Token|Jwt|JWT)\(|\bjwt\.decode\([^)]*\balgorithms\s*=/ }),
|
|
200
202
|
// A05 Injection
|
|
201
203
|
rule({ id: "cmd.shell-built", title: "Shell command built from strings", status: "gap", severity: "high", controls: [A05],
|
|
202
204
|
fix: "Pass arguments as an array (execFile, spawn, subprocess.run([...])) instead of building a command string, and never use shell=True with outside input.",
|
package/docs/README.md
CHANGED
package/docs/agents.md
CHANGED
package/docs/frameworks.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- Generated from Lintsure 0.3.
|
|
1
|
+
<!-- Generated from Lintsure 0.3.12 by scripts/build-docs.mjs. -->
|
|
2
2
|
# Frameworks
|
|
3
3
|
|
|
4
4
|
## EU AI Act (`eu-ai-act`)
|
|
@@ -60,20 +60,20 @@ The OWASP Top 10 is a widely used awareness list of the ten most serious kinds o
|
|
|
60
60
|
|
|
61
61
|
Applies to: Any team building a web application or API. It's voluntary, but often expected by business customers and referenced in security reviews.
|
|
62
62
|
|
|
63
|
-
- A01:2025 Broken Access Control [partly in code]: People must only reach the data and actions meant for them. This covers file paths, redirects, requests your server makes on a user's behalf (SSRF), forged requests from other sites, and permissions kept where users can change them. Rules: path.user-input, redirect.open, ssrf.user-url, csrf.disabled, fs.world-writable, cors.any-origin, cookie.trusted-role, supabase.rls-disabled, supabase.policy-allows-all, supabase.service-key-in-client, supabase.function-no-auth.
|
|
63
|
+
- A01:2025 Broken Access Control [partly in code]: People must only reach the data and actions meant for them. This covers file paths, redirects, requests your server makes on a user's behalf (SSRF), forged requests from other sites, and permissions kept where users can change them. Rules: path.user-input, redirect.open, ssrf.user-url, csrf.disabled, fs.world-writable, cors.any-origin, cookie.trusted-role, supabase.rls-disabled, supabase.policy-allows-all, supabase.service-key-in-client, supabase.function-no-auth, authz.no-owner-check, ws.no-origin-check, cloud.public-bucket.
|
|
64
64
|
- A01:2025 (ownership checks) Every record is checked against the signed-in user [outside code]: Whether each endpoint checks that the record belongs to the person asking (often called IDOR). A line-by-line code check can't tell; it needs design review and testing with two accounts.
|
|
65
|
-
- A02:2025 Security Misconfiguration [partly in code]: Safe settings by default: debug off, real host names, strong secret keys, cookies marked secure, XML parsers that don't load outside files, and errors that don't reveal internals. Rules: config.debug-on, agent.permissions-allow-all, config.allowed-hosts-any, config.default-secret-key, xml.external-entities, cors.any-origin, session.cookie-insecure, error.stack-to-client, build.sourcemaps-public, release.env-not-ignored.
|
|
65
|
+
- A02:2025 Security Misconfiguration [partly in code]: Safe settings by default: debug off, real host names, strong secret keys, cookies marked secure, XML parsers that don't load outside files, and errors that don't reveal internals. Rules: config.debug-on, agent.permissions-allow-all, config.allowed-hosts-any, config.default-secret-key, xml.external-entities, cors.any-origin, session.cookie-insecure, error.stack-to-client, build.sourcemaps-public, release.env-not-ignored, k8s.privileged, graphql.introspection.
|
|
66
66
|
- A02:2025 (deployed settings) Server, cloud and header configuration in production [outside code]: What is actually running: server and cloud settings, open ports, default accounts, security headers on real responses. These need a scan of the deployed system.
|
|
67
67
|
- A03:2025 Software Supply Chain Failures [partly in code]: The code you didn't write: dependencies, build tools and CI. Versions should be pinned, install scripts shouldn't fetch code, CI actions should be pinned, untrusted pull requests must not run with your secrets, and text from issues or pull requests must never become part of a CI command. Rules: deps.unpinned-version, deps.install-script, agent.config-runs-remote-code, agent.instructions-unsafe, ci.action-unpinned, ci.prt-checkout-head, ci.write-all-permissions, ci.script-injection, update.unverified-download.
|
|
68
68
|
- A03:2025 (known vulnerabilities) Dependencies with known vulnerabilities [outside code]: Whether any dependency version has a published vulnerability, and whether it's maintained. This needs vulnerability advisory data, which Lintsure doesn't download, so use a dependency scanner alongside it.
|
|
69
|
-
- A04:2025 Cryptographic Failures [checked in code]: Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code. Rules: crypto.weak-password-hash, crypto.weak-random-token, crypto.weak-cipher, jwt.unverified, transport.plain-http, transport.tls-verify-off, secret.in-source, secret.public-env, mobile.token-in-plain-storage, mobile.cleartext-traffic.
|
|
69
|
+
- A04:2025 Cryptographic Failures [checked in code]: Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code. Rules: crypto.weak-password-hash, crypto.weak-random-token, crypto.weak-cipher, jwt.unverified, transport.plain-http, transport.tls-verify-off, secret.in-source, secret.public-env, mobile.token-in-plain-storage, mobile.cleartext-traffic, jwt.weak-secret, crypto.unsafe-compare.
|
|
70
70
|
- A04:2025 (key management) Key management and encryption at rest [outside code]: How encryption keys are created, stored, rotated and retired, and whether databases and backups are encrypted. These live in your infrastructure, not your code.
|
|
71
71
|
- A05:2025 Injection [checked in code]: Keep data and code apart, so input can't become part of a SQL query, a shell command, a template, HTML on the page or code that gets run. Rules: sql.string-built, cmd.shell-built, code.eval, xss.raw-html, template.user-string, nosql.operator-input.
|
|
72
|
-
- A06:2025 Insecure Design [partly in code]: Security planned in from the start: limits on uploads, only the fields users may change, sensitive data kept out of URLs. Most of this category is about design, not individual lines. Rules: upload.unrestricted, mass-assignment, pii.in-url, mobile.webview-any-origin.
|
|
72
|
+
- A06:2025 Insecure Design [partly in code]: Security planned in from the start: limits on uploads, only the fields users may change, sensitive data kept out of URLs. Most of this category is about design, not individual lines. Rules: upload.unrestricted, mass-assignment, pii.in-url, mobile.webview-any-origin, html.tabnabbing.
|
|
73
73
|
- A06:2025 (threat modelling) Threat modelling and abuse cases [outside code]: Thinking through how a feature could be misused before building it: rate limits, business rule abuse, trust boundaries. Code checks can't show whether this happened.
|
|
74
|
-
- A07:2025 Authentication Failures [partly in code]: Logins and sessions that hold up: no passwords in code, strong secrets, tokens that expire and are verified, and session cookies protected from scripts and plain HTTP. Rules: auth.hardcoded-password, jwt.no-expiry, jwt.unverified, config.default-secret-key, session.cookie-insecure, secret.in-source, transport.tls-verify-off, auth.no-rate-limit.
|
|
74
|
+
- A07:2025 Authentication Failures [partly in code]: Logins and sessions that hold up: no passwords in code, strong secrets, tokens that expire and are verified, and session cookies protected from scripts and plain HTTP. Rules: auth.hardcoded-password, jwt.no-expiry, jwt.unverified, config.default-secret-key, session.cookie-insecure, secret.in-source, transport.tls-verify-off, auth.no-rate-limit, jwt.no-algorithm-pin, jwt.weak-secret.
|
|
75
75
|
- A07:2025 (login protections) Brute-force protection, MFA and account recovery [outside code]: Rate limiting and lockout on login, multi-factor authentication, and safe password reset flows. These need testing against the running app.
|
|
76
|
-
- A08:2025 Software or Data Integrity Failures [partly in code]: Don't trust code or data you haven't checked: no unsafe deserialisation, integrity checks on third-party scripts, and no trust in values users can change. Rules: deserialize.unsafe, html.script-no-sri, mass-assignment, cookie.trusted-role, ci.prt-checkout-head.
|
|
76
|
+
- A08:2025 Software or Data Integrity Failures [partly in code]: Don't trust code or data you haven't checked: no unsafe deserialisation, integrity checks on third-party scripts, and no trust in values users can change. Rules: deserialize.unsafe, html.script-no-sri, mass-assignment, cookie.trusted-role, ci.prt-checkout-head, proto.pollution.
|
|
77
77
|
- A08:2025 (signed releases) Signed builds and updates [outside code]: Whether builds, packages and updates are signed and verified from source to release.
|
|
78
78
|
- A09:2025 Security Logging and Alerting Failures [partly in code]: Logs that help instead of hurt: no secrets or personal data in them, no way to forge entries, and records of important events. Rules: log.secret, log.injection, pii.logged, ai.call-not-logged.
|
|
79
79
|
- A09:2025 (alerting) Monitoring, alerting and incident response [outside code]: Whether anyone is alerted when something suspicious happens, how long logs are kept, and how incidents are handled.
|
package/docs/rules.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<!-- Generated from Lintsure 0.3.
|
|
2
|
-
# Lintsure rules (
|
|
1
|
+
<!-- Generated from Lintsure 0.3.12 by scripts/build-docs.mjs. -->
|
|
2
|
+
# Lintsure rules (84)
|
|
3
3
|
|
|
4
4
|
## pii.logged
|
|
5
5
|
**Personal data written to logs** · status when found: gap · risk: high
|
|
@@ -404,6 +404,88 @@
|
|
|
404
404
|
- Note: Stack traces show file paths, library versions and sometimes data, which helps attackers (CWE-209).
|
|
405
405
|
- Page: https://lintsure.com/rules/error-stack-to-client
|
|
406
406
|
|
|
407
|
+
## authz.no-owner-check
|
|
408
|
+
**Record loaded by an id from the request, with no owner check** · status when found: partial · risk: high · medium confidence (shown with --all)
|
|
409
|
+
|
|
410
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control)
|
|
411
|
+
- Fix: Look the record up by its id and the signed-in user (or tenant) together, for example where: { id, userId: req.user.id }, or check the owner before returning it.
|
|
412
|
+
- Note: Anyone who changes the id in the URL can read or change someone else's record (insecure direct object reference, CWE-639).
|
|
413
|
+
- When Partial, Lintsure can't see: Lintsure can't see checks done in middleware or another function, so the owner may already be verified.
|
|
414
|
+
- Page: https://lintsure.com/rules/authz-no-owner-check
|
|
415
|
+
|
|
416
|
+
## jwt.no-algorithm-pin
|
|
417
|
+
**Token verified without saying which algorithm is allowed** · status when found: partial · risk: medium
|
|
418
|
+
|
|
419
|
+
- Controls: owasp-top10 A07:2025 (Authentication Failures)
|
|
420
|
+
- Fix: Pass the algorithm you sign with, for example jwt.verify(token, key, { algorithms: ["RS256"] }), or algorithms=["HS256"] in PyJWT.
|
|
421
|
+
- Note: Without a fixed list, some library versions accept a token signed with a different algorithm than you meant, for example one signed with your public key (CWE-347).
|
|
422
|
+
- Page: https://lintsure.com/rules/jwt-no-algorithm-pin
|
|
423
|
+
|
|
424
|
+
## jwt.weak-secret
|
|
425
|
+
**Token signed with a short secret written in the code** · status when found: gap · risk: high
|
|
426
|
+
|
|
427
|
+
- Controls: owasp-top10 A04:2025 (Cryptographic Failures); owasp-top10 A07:2025 (Authentication Failures)
|
|
428
|
+
- Fix: Read the signing key from the environment or a secret store, and make it at least 32 random bytes.
|
|
429
|
+
- Note: Anyone who reads the code, or guesses a short key, can sign their own login tokens (CWE-798, CWE-521).
|
|
430
|
+
- Page: https://lintsure.com/rules/jwt-weak-secret
|
|
431
|
+
|
|
432
|
+
## proto.pollution
|
|
433
|
+
**Request data deep-merged into an object** · status when found: gap · risk: high
|
|
434
|
+
|
|
435
|
+
- Controls: owasp-top10 A08:2025 (Software or Data Integrity Failures)
|
|
436
|
+
- Fix: Copy only the fields you expect, or validate the body with a schema first. If you must merge, drop __proto__, constructor and prototype keys.
|
|
437
|
+
- Note: A body like {"__proto__": {"isAdmin": true}} can change every object in the app (prototype pollution, CWE-1321).
|
|
438
|
+
- Page: https://lintsure.com/rules/proto-pollution
|
|
439
|
+
|
|
440
|
+
## html.tabnabbing
|
|
441
|
+
**Link opens a new tab without rel="noopener"** · status when found: partial · risk: low
|
|
442
|
+
|
|
443
|
+
- Controls: owasp-top10 A06:2025 (Insecure Design)
|
|
444
|
+
- Fix: Add rel="noopener noreferrer" to links with target="_blank".
|
|
445
|
+
- Note: Current browsers already treat target="_blank" as noopener, so this matters mainly for older browsers and webviews: the opened page could redirect your tab (CWE-1022).
|
|
446
|
+
- Page: https://lintsure.com/rules/html-tabnabbing
|
|
447
|
+
|
|
448
|
+
## ws.no-origin-check
|
|
449
|
+
**Web-socket server with no origin check** · status when found: partial · risk: medium
|
|
450
|
+
|
|
451
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control)
|
|
452
|
+
- Fix: Check the Origin header when a connection opens (verifyClient in ws, cors.origin or allowRequest in socket.io) and allow only your own sites.
|
|
453
|
+
- Note: Browsers don't stop other sites opening a web socket to you, so a page on any site can use a signed-in visitor's cookies against it (cross-site WebSocket hijacking, CWE-1385).
|
|
454
|
+
- When Partial, Lintsure can't see: Lintsure can't see an origin check done in a proxy or an upgrade handler in another file.
|
|
455
|
+
- Page: https://lintsure.com/rules/ws-no-origin-check
|
|
456
|
+
|
|
457
|
+
## k8s.privileged
|
|
458
|
+
**Container runs privileged or shares the host** · status when found: gap · risk: high
|
|
459
|
+
|
|
460
|
+
- Controls: owasp-top10 A02:2025 (Security Misconfiguration)
|
|
461
|
+
- Fix: Remove privileged, hostNetwork, hostPID and hostIPC, set allowPrivilegeEscalation: false, and run as a non-root user.
|
|
462
|
+
- Note: A privileged container, or one sharing the host's network or processes, can take over the machine it runs on if it is broken into (CWE-250).
|
|
463
|
+
- Page: https://lintsure.com/rules/k8s-privileged
|
|
464
|
+
|
|
465
|
+
## cloud.public-bucket
|
|
466
|
+
**Storage bucket open to the public** · status when found: gap · risk: high
|
|
467
|
+
|
|
468
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control)
|
|
469
|
+
- Fix: Keep the bucket private and block public access. Share single files with short-lived signed URLs instead.
|
|
470
|
+
- Note: Anyone on the internet can list or download what's in a public bucket, and with write access, replace it (CWE-284).
|
|
471
|
+
- Page: https://lintsure.com/rules/cloud-public-bucket
|
|
472
|
+
|
|
473
|
+
## crypto.unsafe-compare
|
|
474
|
+
**Secret compared with == instead of a constant-time check** · status when found: partial · risk: medium · medium confidence (shown with --all)
|
|
475
|
+
|
|
476
|
+
- Controls: owasp-top10 A04:2025 (Cryptographic Failures)
|
|
477
|
+
- Fix: Use crypto.timingSafeEqual (Node) or hmac.compare_digest (Python) to compare signatures, tokens and keys.
|
|
478
|
+
- Note: A plain comparison stops at the first wrong character, so response times can leak the secret bit by bit (timing attack, CWE-208).
|
|
479
|
+
- Page: https://lintsure.com/rules/crypto-unsafe-compare
|
|
480
|
+
|
|
481
|
+
## graphql.introspection
|
|
482
|
+
**GraphQL introspection switched on** · status when found: partial · risk: low
|
|
483
|
+
|
|
484
|
+
- Controls: owasp-top10 A02:2025 (Security Misconfiguration)
|
|
485
|
+
- Fix: Turn introspection off in production, for example introspection: process.env.NODE_ENV !== "production".
|
|
486
|
+
- Note: Introspection hands anyone a full map of your API, including fields you never meant to advertise (CWE-200).
|
|
487
|
+
- Page: https://lintsure.com/rules/graphql-introspection
|
|
488
|
+
|
|
407
489
|
## supabase.rls-disabled
|
|
408
490
|
**Database table without row level security** · status when found: partial · risk: high
|
|
409
491
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lintsure/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "Lintsure engine: rules, framework knowledge and reports for readiness checks of AI-written code. Not an audit or legal advice.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|