@lintsure/core 0.3.14 → 0.3.15
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 +18 -1
- package/dist/src/index.js +160 -16
- package/dist/src/knowledge/cra.js +2 -2
- package/dist/src/knowledge/gdpr.js +3 -3
- package/dist/src/knowledge/more.js +2 -2
- package/dist/src/knowledge/owasp-top10.js +1 -1
- package/dist/src/rules/cra.d.ts +4 -0
- package/dist/src/rules/cra.js +72 -2
- package/dist/src/rules/index.d.ts +1 -0
- package/dist/src/rules/index.js +37 -10
- package/dist/src/rules/more.d.ts +25 -0
- package/dist/src/rules/more.js +266 -4
- package/dist/src/rules/owasp.d.ts +5 -1
- package/dist/src/rules/owasp.js +67 -26
- package/dist/src/rules/stack.js +2 -1
- package/dist/src/rules/standards.js +11 -6
- package/docs/README.md +1 -1
- package/docs/agents.md +1 -1
- package/docs/frameworks.md +9 -9
- package/docs/rules.md +144 -3
- package/package.json +42 -42
package/dist/src/rules/owasp.js
CHANGED
|
@@ -2,7 +2,7 @@ const CODE = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py"];
|
|
|
2
2
|
const MARKUP = [...CODE, ".html", ".vue", ".svelte", ".astro", ".jinja", ".j2"];
|
|
3
3
|
const YAML = [".yml", ".yaml"];
|
|
4
4
|
// Files whose commands an agent or editor runs by itself: Claude Code settings, MCP server lists, Cursor, VS Code, Gemini CLI.
|
|
5
|
-
const AGENT_CONFIG = /(^|\/)(\.claude\/settings(\.local)?\.json|\.mcp\.json|\.cursor\/(mcp|hooks)\.json|\.vscode\/(tasks|mcp)\.json|\.gemini\/settings\.json)$/;
|
|
5
|
+
export const AGENT_CONFIG = /(^|\/)(\.claude\/settings(\.local)?\.json|\.mcp\.json|mcp\.json|claude_desktop_config\.json|\.windsurf\/mcp_config\.json|\.roo\/mcp\.json|\.cursor\/(mcp|hooks)\.json|\.vscode\/(tasks|mcp)\.json|\.gemini\/settings\.json)$/;
|
|
6
6
|
// Download-and-run shapes: piped into a shell, run from $( ), process substitution, base64 into a shell, encoded PowerShell,
|
|
7
7
|
// and download-then-execute chains.
|
|
8
8
|
const RUNS_REMOTE = new RegExp([
|
|
@@ -18,12 +18,30 @@ const AGENT_INSTRUCTIONS = /(^|\/)(SKILL\.md|AGENTS\.md|CLAUDE\.md|GEMINI\.md|\.
|
|
|
18
18
|
const OVERRIDE = /\b(ignore|disregard|forget|override)\s+(all\s+|any\s+)?(of\s+)?(your\s+|the\s+)?(previous|prior|above|earlier|system|original|user'?s?)\s+(instructions|rules|prompts?|messages|guidelines)\b/i;
|
|
19
19
|
const CONCEAL = /\b(do not|don'?t|never)\s+(tell|inform|mention|show|reveal|disclose)\s+(this\s+|it\s+|anything\s+)?(to\s+)?the\s+user\b|\bwithout\s+(telling|informing)\s+the\s+user\b/i;
|
|
20
20
|
// A line that says a download-and-run is blocked or forbidden describes a guard, it doesn't ask for one.
|
|
21
|
-
const FORBIDS = /\b(block(ed|s)?|forbid(den)?|never run|don'?t run|do not run|not allowed|denied)\b/i;
|
|
21
|
+
const FORBIDS = /\b(block(ed|s)?|forbid(den)?|never run|don'?t run|do not run|not allowed|denied|avoid|unsafe|dangerous|executes whatever)\b|\(via\s/i;
|
|
22
22
|
const EXFIL = /\b(curl|wget|Invoke-WebRequest|iwr|fetch)\b.*(\s-d\b|--data|--upload-file|\s-F\b|\s-T\b|-Method\s+Post|method:\s*["']POST).*(\.env\b|\.ssh|id_rsa|\.aws\/credentials|\$\{?[A-Z_]*(KEY|TOKEN|SECRET|PASSWORD)\b)/i;
|
|
23
23
|
// A line that names the attack to warn about it ("if a page says 'ignore previous instructions', don't follow it") is advice.
|
|
24
24
|
const WARNS = /["'`“”]|\b(if|when|e\.g\.|for example|such as|treat .* as data|never follow|don'?t follow|do not follow|watch out|be careful)\b/i;
|
|
25
|
-
|
|
25
|
+
// Text a person can't see but a model reads: Unicode tag characters, direction overrides, or a run of zero-width characters.
|
|
26
|
+
// One zero-width joiner inside an emoji is normal, and a flag emoji carries tag characters on purpose, so neither counts.
|
|
27
|
+
const HIDDEN = /[\u{E0020}-\u{E007F}]|[\u202A-\u202E\u2066-\u2069]|[\u200B-\u200D\u2060\uFEFF]{3,}/u;
|
|
28
|
+
/** True when a line carries text hidden from a human reader. Pure. */
|
|
29
|
+
export const hiddenText = (l) => HIDDEN.test(l.replace(/\u{1F3F4}[\u{E0020}-\u{E007F}]+/gu, ""));
|
|
30
|
+
/** Text inside an MCP server's source that talks to the model instead of describing a tool: an override, an order to keep
|
|
31
|
+
* something from the user, an <important> block, an order to read key files, or hidden characters. Pure. */
|
|
32
|
+
// Chat-template markers that only make sense to a model: <important>, <system>, [SYSTEM], [INST], <<SYS>>, <|im_start|>.
|
|
33
|
+
// The bracket forms count in capitals only: items[system] is ordinary code.
|
|
34
|
+
const MODEL_TAG = { test: (l) => /<\s*\/?\s*(important|system)\s*>|<\|(im_start|im_end|system)\|>/i.test(l) || /\[\/?(SYSTEM|INST)\]|<<\s*\/?SYS\s*>>/.test(l) };
|
|
35
|
+
// Prose telling the reader to fetch key material. The verb must be a word of its own, so open("~/.ssh/config") in code is not it.
|
|
36
|
+
// .env is left out: a dotenv tool honestly says it reads the .env file.
|
|
37
|
+
const KEY_FILE_ORDER = /\b(read|open|cat|send|pass|include|attach|load)\s+[^.\n]{0,60}(\.ssh\b|\bid_(rsa|ed25519|ecdsa)\b|\.aws\/credentials|\.npmrc\b|\.netrc\b|\.git-credentials|\.kube\/config|\bmcp\.json|claude_desktop_config\.json)/i;
|
|
38
|
+
export const poisonedDescription = (l) => hiddenText(l) || OVERRIDE.test(l) || CONCEAL.test(l) || MODEL_TAG.test(l) || KEY_FILE_ORDER.test(l);
|
|
39
|
+
/** Agent instruction line: Gap for override, concealment, hidden text or sending secrets out; Partial for download-and-run. Pure. */
|
|
26
40
|
export function instructionsUnsafe(l) {
|
|
41
|
+
if (hiddenText(l))
|
|
42
|
+
return true;
|
|
43
|
+
if (KEY_FILE_ORDER.test(l) && !/\b(never|do not|don'?t|must not|avoid|without)\b/i.test(l) && !WARNS.test(l.replace(/[`'"]/g, "")))
|
|
44
|
+
return true;
|
|
27
45
|
if (EXFIL.test(l))
|
|
28
46
|
return true;
|
|
29
47
|
if ((OVERRIDE.test(l) || CONCEAL.test(l)) && !WARNS.test(l))
|
|
@@ -83,6 +101,7 @@ export const owaspRules = [
|
|
|
83
101
|
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
102
|
note: "A path like ../../etc/passwd lets someone read or overwrite files outside the folder you meant (path traversal, CWE-22).", extensions: CODE,
|
|
85
103
|
test: (l) => /\b(fs\.(readFile|readFileSync|createReadStream|writeFile|writeFileSync|unlink|unlinkSync)|res\.(sendFile|download)|send_file|send_from_directory|(?<![.\w])open)\s*\(/.test(l) && USER_INPUT.test(l)
|
|
104
|
+
&& !/\bfs\.writeFile(Sync)?\s*\(\s*(?!(req|request|params|query|body|input|args|form|ctx|event|payload|searchParams|user_input)\b)\w+\s*,/.test(l)
|
|
86
105
|
// An in-memory file isn't a path: send_file(io.BytesIO(...), as_attachment=request...) (field-test review).
|
|
87
106
|
&& !/\b(send_file|sendFile|download)\s*\(\s*(io\.)?(BytesIO|StringIO)\s*\(|\b(send_file|sendFile)\s*\(\s*Buffer\./.test(l) ? true
|
|
88
107
|
// Unpacking an archive writes wherever its entry names point (zip slip), unless Python's filter= is set.
|
|
@@ -90,7 +109,7 @@ export const owaspRules = [
|
|
|
90
109
|
rule({ id: "redirect.open", title: "Redirect to a URL taken from the request", status: "gap", severity: "medium", controls: [A01],
|
|
91
110
|
fix: "Redirect only to paths on your own site, or check the target against a list of allowed hosts.",
|
|
92
111
|
note: "Attackers send people a link to your site that bounces them to a phishing page (open redirect, CWE-601).", extensions: CODE,
|
|
93
|
-
test: (l) => /\b(res\.redirect|redirect|HttpResponseRedirect|RedirectResponse)\s*\(\s*(req\.(query|body|params)|request\.(args|GET|query_params|form))/.test(l) }),
|
|
112
|
+
test: (l) => /\b(res\.redirect|redirect|HttpResponseRedirect|RedirectResponse)\s*\(\s*(?:\d{3}\s*,\s*)?(req\.(query|body|params)|request\.(args|GET|query_params|form))/.test(l) }),
|
|
94
113
|
rule({ id: "ssrf.user-url", title: "Server fetches a URL taken from the request", status: "gap", severity: "high", controls: [A01],
|
|
95
114
|
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.",
|
|
96
115
|
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,
|
|
@@ -101,8 +120,10 @@ export const owaspRules = [
|
|
|
101
120
|
test: (l) => /@csrf_exempt\b|WTF_CSRF_ENABLED\s*=\s*False|\bcsrf\s*:\s*false\b|csrf_protect\s*=\s*False/.test(l) }),
|
|
102
121
|
rule({ id: "fs.world-writable", title: "File made readable and writable by everyone", status: "gap", severity: "medium", controls: [A01],
|
|
103
122
|
fix: "Use the narrowest permissions that work, for example 0o600 for secrets and 0o644 or 0o755 for public files.",
|
|
104
|
-
note: "Any user or process on the machine can change the file (incorrect permissions, CWE-732).", extensions: CODE,
|
|
105
|
-
test: (l) => /\bchmod(Sync)?\s*\([^)]*\b0o?777\b/.test(l) && !/&\s*0o?777\b/.test(l)
|
|
123
|
+
note: "Any user or process on the machine can change the file (incorrect permissions, CWE-732).", extensions: [...CODE, ".sh", ".bash", ""],
|
|
124
|
+
test: (l) => (/\bchmod(Sync)?\s*\([^)]*\b0o?777\b/.test(l) && !/&\s*0o?777\b/.test(l)) || (/(^|[\s;&|])chmod\s+(-\w+\s+)*(0?777|a\+rwx)\b/.test(l) && !/^\s*#/.test(l)),
|
|
125
|
+
// Loosening a read-only file so it can be deleted (the rmtree error-handler idiom) leaves nothing behind (0.3.14 review).
|
|
126
|
+
unlessNear: /\brmtree\b|\bos\.(remove|unlink)\(|\bunlink(Sync)?\(/ }),
|
|
106
127
|
// A02 Security Misconfiguration
|
|
107
128
|
rule({ id: "config.allowed-hosts-any", title: "Django accepts any host name", status: "gap", severity: "medium", controls: [A02],
|
|
108
129
|
fix: "List your real domains in ALLOWED_HOSTS, ideally from an environment variable per environment.",
|
|
@@ -157,7 +178,7 @@ export const owaspRules = [
|
|
|
157
178
|
// script is acted on the next time any agent opens the repo (skill collections spread these widely).
|
|
158
179
|
rule({ id: "agent.instructions-unsafe", title: "Agent instructions that override, hide or download and run", status: "gap", severity: "high", controls: [A03, LLM01],
|
|
159
180
|
fix: "Remove the line, or rewrite it so the agent asks the user first. Install tools with a pinned, reviewed command instead of piping a download into a shell, and never tell an agent to keep something from the user.",
|
|
160
|
-
note: "Agents read these files as instructions and act on them with your permissions. Gap when the line overrides earlier instructions, hides something from the user or sends secrets out. Partial when it downloads and runs a script, which some setup guides do on purpose (CWE-829, OWASP LLM01).",
|
|
181
|
+
note: "Agents read these files as instructions and act on them with your permissions. Gap when the line overrides earlier instructions, hides something from the user, carries characters a person can't see, or sends secrets out. Partial when it downloads and runs a script, which some setup guides do on purpose (CWE-829, OWASP LLM01).",
|
|
161
182
|
extensions: [".md", ".mdc", ""], pathMatch: AGENT_INSTRUCTIONS,
|
|
162
183
|
unseen: "Lintsure reads the line, not who wrote it or whether the file came from a trusted skill. Check where this file came from before an agent uses it.",
|
|
163
184
|
test: instructionsUnsafe }),
|
|
@@ -188,21 +209,25 @@ export const owaspRules = [
|
|
|
188
209
|
test: (l) => /\bMath\.random\(\)|\brandom\.(random|randint|choice|choices|getrandbits)\(/.test(l) && /(token|secret|password|passwd|otp|nonce|session|api_?key|reset|invite|verification|code\b)/i.test(l) }),
|
|
189
210
|
rule({ id: "crypto.weak-cipher", title: "Weak or broken encryption", status: "gap", severity: "high", controls: [A04],
|
|
190
211
|
fix: "Use AES-256-GCM or ChaCha20-Poly1305 with a random nonce, through a maintained library. Replace createCipher with createCipheriv.",
|
|
191
|
-
note: "DES, RC4 and ECB mode can be broken or leak patterns in the data; createCipher derives a weak key and IV (CWE-327).", extensions: CODE,
|
|
212
|
+
note: "DES, RC4 and ECB mode can be broken or leak patterns in the data; createCipher derives a weak key and IV (CWE-327).", extensions: [...CODE, ".java", ".kt", ".swift", ".go", ".dart"],
|
|
192
213
|
// A quoted cipher name counts only on a line about encryption: "des" is also a German word (field test).
|
|
193
|
-
|
|
214
|
+
// Java and Kotlin: a bare "AES" means AES/ECB. Go, Swift (CommonCrypto), CryptoJS and Python's cryptography package.
|
|
215
|
+
test: (l) => /\bCipher\.getInstance\(\s*"(DES|DESede|RC4|ARCFOUR|Blowfish|AES|[A-Za-z0-9]+\/ECB\/[^"]*)"\s*[,)]|\b(des|rc4)\.NewCipher\(|\bdes\.NewTripleDESCipher\(|\bkCCAlgorithm(DES|3DES|RC4)\b|\bkCCOptionECBMode\b|\bCryptoJS\.(DES|RC4|TripleDES)\.|\bCryptoJS\.mode\.ECB\b|\bmodes\.ECB\(/.test(l)
|
|
216
|
+
|| /\bcreateCipher\s*\(|\bMODE_ECB\b|\b(DES3?|ARC4|Blowfish)\.new\s*\(/i.test(l)
|
|
194
217
|
|| (/["'](des|des-ede3?|des-ede3-cbc|rc4|aes-\d{3}-ecb)["']/i.test(l) && /cipher|crypt|algorithm/i.test(l)) }),
|
|
195
218
|
rule({ id: "jwt.unverified", title: "JWT accepted without checking its signature", status: "gap", severity: "high", controls: [A04, A07],
|
|
196
219
|
fix: "Verify tokens with jwt.verify (Node) or jwt.decode with a key and an explicit algorithms list (Python). Never allow the 'none' algorithm.",
|
|
197
220
|
note: "Without signature checks anyone can write their own token and claim to be any user (CWE-347).", extensions: CODE,
|
|
198
221
|
test: (l) => {
|
|
199
|
-
if (/verify_signature["']?\s*:\s*False|\bverify\s*=\s*False|algorithms\s*[:=]\s*\[[^\]]*["']none["']/i.test(l) && /jwt/i.test(l))
|
|
200
|
-
|
|
222
|
+
if (/verify_signature["']?\s*:\s*False|\bverify\s*=\s*False|algorithms\s*[:=]\s*\[[^\]]*["']none["']/i.test(l) && /jwt/i.test(l)) {
|
|
223
|
+
// Reading only the expiry straight off the decode is not accepting the token (0.3.14 review).
|
|
224
|
+
return !/\)\s*(\.get\(\s*|\[\s*)["']exp["']/.test(l);
|
|
225
|
+
}
|
|
201
226
|
return /\bjwt\.decode\(\s*[\w.]+\s*\)/.test(l) ? "partial" : false; // Node jwt.decode reads a token without verifying it
|
|
202
227
|
},
|
|
203
228
|
// Peeking at a claim before verifying it nearby is fine (field test, 139 repos).
|
|
204
229
|
// Python peek-then-verify: a second decode with a key and an algorithms list nearby (review P21).
|
|
205
|
-
unlessNear: /\bjwt\.verify\((?![^\n]*["']none["'])|\bjwtVerify\(|\bverify(Token|Jwt|JWT)\(|\bjwt\.decode\([^)]*\balgorithms\s
|
|
230
|
+
unlessNear: /\bjwt\.verify\((?![^\n]*["']none["'])|\bjwtVerify\(|\bverify(Token|Jwt|JWT)\(|\bjwt\.decode\([^)]*\balgorithms\s*=|\bget_signing_key(_from_jwt)?\(|\bPyJWKClient\(/ }),
|
|
206
231
|
// A05 Injection
|
|
207
232
|
rule({ id: "cmd.shell-built", title: "Shell command built from strings", status: "gap", severity: "high", controls: [A05],
|
|
208
233
|
fix: "Pass arguments as an array (execFile, spawn, subprocess.run([...])) instead of building a command string, and never use shell=True with outside input.",
|
|
@@ -215,8 +240,10 @@ export const owaspRules = [
|
|
|
215
240
|
// A method named eval is a definition, not a call (also TypeScript class methods, field test); $$eval is Playwright's;
|
|
216
241
|
// "eval" inside a string is text, also a string left open at the line end. A bare `eval(` ending the line is a
|
|
217
242
|
// wrapped call or method head: the joined statement decides (format robustness).
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
// Decoding text and running it straight away is how hidden code ships in a script: a Gap whatever the input is.
|
|
244
|
+
test: (l) => /\b(eval|exec|Function)\s*\(\s*(atob\s*\(|Buffer\.from\([^)]*base64|base64\.b64decode\(|bytes\.fromhex\(|codecs\.decode\()/.test(l) ? true
|
|
245
|
+
: /\b(def|function|async)\s+eval\s*\(|^\s*((public|private|protected|static|override)\s+)*eval\s*\([^)]*\)\s*(:[^{=]+)?\{\s*$|^\s*eval\s*\(\s*$/.test(l) ? false
|
|
246
|
+
: /(^|[^.\w$])eval\s*\(|\bnew Function\s*\(/.test(l.replace(/(["'])(?:\\.|(?!\1)[^\\])*\1/g, '""').replace(/(["'])(?:\\.|(?!\1)[^\\])*$/, '""')) ? byInput(l) : false }),
|
|
220
247
|
rule({ id: "xss.raw-html", title: "HTML inserted without escaping", status: "partial", severity: "medium", controls: [A05],
|
|
221
248
|
fix: "Set text with textContent, let your framework escape values, or sanitise with DOMPurify before inserting HTML.",
|
|
222
249
|
note: "If the HTML contains user input, attackers can run scripts in your users' browsers (cross-site scripting, CWE-79). Partial because fixed HTML from your own code is safe.", extensions: MARKUP,
|
|
@@ -228,11 +255,14 @@ export const owaspRules = [
|
|
|
228
255
|
rule({ id: "template.user-string", title: "Template built from request data", status: "gap", severity: "high", controls: [A05],
|
|
229
256
|
fix: "Render a fixed template file and pass user values as variables, never as part of the template text.",
|
|
230
257
|
note: "Template syntax in user input runs on your server (server-side template injection, CWE-94).", extensions: CODE,
|
|
231
|
-
test: (l) => /\brender_template_string\(\s*(request\.|f["'])|\bTemplate\(\s*request\./.test(l)
|
|
258
|
+
test: (l) => /\brender_template_string\(\s*(request\.|f["'])|\bTemplate\(\s*request\.|\.from_string\(\s*request\./.test(l)
|
|
259
|
+
|| /\b(ejs\.render|Handlebars\.compile|nunjucks\.renderString|pug\.(render|compile)|_\.template)\(\s*req\.(body|query|params)\b/.test(l) }),
|
|
232
260
|
rule({ id: "nosql.operator-input", title: "Database query object taken straight from the request", status: "partial", severity: "high", controls: [A05],
|
|
233
261
|
fix: "Build the query from the specific fields you expect, and convert them to the expected types, so operators like $ne or $gt can't be injected.",
|
|
234
262
|
note: "A body such as {\"password\": {\"$ne\": null}} can match any record (NoSQL injection, CWE-943).", extensions: CODE,
|
|
235
|
-
|
|
263
|
+
// Also a lookup that takes a secret field straight from the request: { password: req.body.password } accepts {"$ne": null}.
|
|
264
|
+
test: (l) => /\.(find|findOne|updateOne|updateMany|deleteOne|deleteMany|countDocuments)\(\s*req\.(body|query)\s*\)|\$where\b/.test(l)
|
|
265
|
+
|| /\.(find|findOne|findOneAndUpdate|countDocuments)\(\s*\{[^}]*\b(password|passwd|token|otp|code|secret|apiKey|api_key)\s*:\s*req\.(body|query)\.\w+\s*[,}]/.test(l) }),
|
|
236
266
|
// A06 Insecure Design
|
|
237
267
|
rule({ id: "upload.unrestricted", title: "File upload with no type or size limit", status: "partial", severity: "medium", controls: [A06],
|
|
238
268
|
fix: "Set limits.fileSize and a fileFilter that allows only the types you need, store uploads outside the web root, and give them new names.",
|
|
@@ -241,23 +271,34 @@ export const owaspRules = [
|
|
|
241
271
|
rule({ id: "mass-assignment", title: "Whole request body saved to a model", status: "partial", severity: "medium", controls: [A06, A08],
|
|
242
272
|
fix: "Copy only the fields a user may change, for example with a schema (zod, pydantic) that lists them.",
|
|
243
273
|
note: "Users can set fields you didn't expect, such as role or isAdmin (mass assignment, CWE-915).", extensions: CODE,
|
|
244
|
-
|
|
274
|
+
// Also the body as the second argument of an update, as Prisma's `data`, or passed to a model constructor.
|
|
275
|
+
test: (l) => /\.(create|update|insert|build|insertOne|updateOne)\(\s*req\.body\s*[),]|\bObject\.assign\(\s*\w+\s*,\s*req\.body\s*\)|\(\s*\*\*request\.(json|form|data)\b/.test(l)
|
|
276
|
+
|| /\.(findByIdAndUpdate|findOneAndUpdate|updateOne|updateMany)\(\s*[^,()]+,\s*req\.body\s*[),]/.test(l)
|
|
277
|
+
|| (/\.(create|update|upsert|createMany|updateMany)\(/.test(l) && /\bdata\s*:\s*req\.body\s*[,}]/.test(l))
|
|
278
|
+
|| /\bnew\s+(?!URLSearchParams|FormData|Map|Set|Error|Date|URL|Blob|Uint8Array)[A-Z]\w*\(\s*req\.body\s*\)/.test(l) }),
|
|
245
279
|
// A07 Authentication Failures
|
|
246
280
|
rule({ id: "auth.hardcoded-password", title: "Password written in the code", status: "partial", severity: "high", controls: [A07],
|
|
247
281
|
fix: "Load passwords from environment variables or a secret manager, and rotate any that were committed.",
|
|
248
282
|
note: "Anyone with the code has the password, and it can't be changed without a release (CWE-259, CWE-798).", extensions: CODE,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
283
|
+
// The word "password" in other languages; and example, sample and browser-test code, whose logins are placeholders by
|
|
284
|
+
// design. Only for this rule: a folder named playwright can also be product code (a plugin), so it is not skipped everywhere.
|
|
285
|
+
unlessPath: /(^|\/)(locales?|i18n|lang|langs|translations?|examples?|samples?|playwright|cypress)\//i,
|
|
286
|
+
// A password used when the environment variable is missing ships with the code just the same. Partial: it may be a
|
|
287
|
+
// local-only default.
|
|
288
|
+
test: (l) => (/\b(os\.environ\.get|os\.getenv)\(\s*["'][A-Z_]*(PASSWORD|PASSWD)["']\s*,\s*["'][^"'\s]{4,}["']\s*\)|\bprocess\.env\.[A-Z_]*(PASSWORD|PASSWD)\s*(\|\||\?\?)\s*["'][^"'\s]{4,}["']/.test(l)
|
|
289
|
+
&& !/example|placeholder|changeme|change[_-]me|your[_-]|xxx|\*\*\*|</i.test(l)) ? "partial"
|
|
290
|
+
: /\b(password|passwd|pwd|db_pass)\s*[:=]\s*["'][^"'\s]{4,}["']/i.test(l) && !/(example|placeholder|changeme|your[_-]|xxx|\*\*\*|<|process\.env|os\.environ|getenv|type\s*[:=]|label|autocomplete)/i.test(l)
|
|
291
|
+
// Translations ("Парола", "Passwort") and obvious stand-ins ("new-password", "hashed-password", "hunter2") are not credentials (field test).
|
|
292
|
+
&& !/[:=]\s*["'][^"']*(passw|hash|redact|hidden|\bhunter2\b|[^\x00-\x7F])/i.test(l)
|
|
293
|
+
// Validation messages and schema types ({ password: "Required" }, { password: "string" }) are not credentials (field test).
|
|
294
|
+
&& !/[:=]\s*["'](required|string|text|str|number|optional|invalid[^"']*|[A-Z][a-z]+ [^"']*)["']/.test(l)
|
|
295
|
+
// Column types and ALL-CAPS labels (`password: 'String'`, `PASSWORD: "SECRET"`) aren't credentials (review P20).
|
|
296
|
+
&& !/[:=]\s*["'](String|Number|Boolean|Text|varchar(\(\d+\))?|VARCHAR(\(\d+\))?|[A-Z][A-Z_]*)["']/.test(l) }),
|
|
257
297
|
rule({ id: "jwt.no-expiry", title: "JWT signed without an expiry", status: "partial", severity: "medium", controls: [A07],
|
|
258
298
|
fix: "Add expiresIn (Node) or an exp claim (Python), and keep access tokens short-lived.",
|
|
259
299
|
note: "A stolen token without an expiry works forever (insufficient session expiration, CWE-613). Partial because the expiry may be set in a payload built elsewhere.", extensions: CODE,
|
|
260
|
-
|
|
300
|
+
// Also a check that is told to ignore the expiry.
|
|
301
|
+
test: (l) => (/\bignoreExpiration\s*:\s*true\b|["']verify_exp["']\s*:\s*False\b/.test(l) && !/verify_signature["']?\s*:\s*False/.test(l)) || (/\bjwt\.(sign|encode)\(/.test(l) && !/expiresIn|\bexp\b/.test(l)), unlessNear: /expiresIn|["']exp["']|\bexp\s*[:=]/ }),
|
|
261
302
|
// A08 Software or Data Integrity Failures
|
|
262
303
|
rule({ id: "deserialize.unsafe", title: "Unsafe deserialisation", status: "gap", severity: "high", controls: [A08],
|
|
263
304
|
fix: "Use JSON for data from outside. In Python use yaml.safe_load, never pickle or marshal on untrusted data.",
|
package/dist/src/rules/stack.js
CHANGED
|
@@ -110,7 +110,8 @@ export const stackRules = [
|
|
|
110
110
|
if (!/\b(using|with\s+check)\s*\(\s*true\s*\)/i.test(l))
|
|
111
111
|
return [];
|
|
112
112
|
const start = lines.slice(Math.max(0, i - 8), i + 1).join(" ");
|
|
113
|
-
|
|
113
|
+
// A policy for service_role alone changes nothing: that role skips row level security anyway (0.3.14 review).
|
|
114
|
+
return /\bfor\s+select\b|\bto\s+service_role\s*(using|with|;|$)/i.test(start.slice(start.toLowerCase().lastIndexOf("create policy"))) ? [] : [i + 1];
|
|
114
115
|
}) }),
|
|
115
116
|
rule({ id: "supabase.function-no-auth", title: "Supabase Edge Function anyone can call", status: "partial", severity: "high", controls: [GDPR32, A01],
|
|
116
117
|
fix: "Keep verify_jwt on for this function, or check the caller yourself at the top of the handler: supabase.auth.getUser() for users, or the provider's signature for a webhook.",
|
|
@@ -32,7 +32,7 @@ const MODEL_OUTPUT = /\b(completion|response|result|output|reply|answer|generati
|
|
|
32
32
|
const SINKS = /\b(eval|exec|execSync|spawn|new Function)\s*\(|\.innerHTML\s*=|dangerouslySetInnerHTML|\.(query|execute|raw)\s*\(|\bsubprocess\.|\bos\.system\(/;
|
|
33
33
|
// User input inside a system prompt: the model can't tell the app's instructions from the user's text.
|
|
34
34
|
// An error's own text (`${error.message}`) is the app's, not the user's (vercel/ai study).
|
|
35
|
-
const USER_TEXT = /\$\{(?![^}]*\b(err|error|e|ex|exception)\.message\b)[^}]*\b(req\.(body|query|params)|request\.(json|form|args)|input|userInput|message|prompt|query|body)\b[^}]*\}|\{(user_input|user_message|query|message)\}/;
|
|
35
|
+
const USER_TEXT = /\$\{(?!\s*body\s*\})(?![^}]*\b(err|error|e|ex|exception)\.message\b)[^}]*\b(req\.(body|query|params)|request\.(json|form|args)|input|userInput|message|prompt|query|body)\b[^}]*\}|\{(user_input|user_message|query|message)\}/;
|
|
36
36
|
const rule = (r) => ({ ...r, ...DRAFT });
|
|
37
37
|
export const standardsRules = [
|
|
38
38
|
// OWASP Top 10 for LLM Applications
|
|
@@ -40,7 +40,10 @@ export const standardsRules = [
|
|
|
40
40
|
fix: "Keep the system prompt fixed. Send what the user typed as a separate user message, and never put it inside the system instructions.",
|
|
41
41
|
note: "Text in the system prompt is treated as the app's own instructions. If user text goes there, a user can rewrite the rules the AI follows (prompt injection). Marked Partial: the inserted value may be safe text your app controls.",
|
|
42
42
|
extensions: CODE,
|
|
43
|
-
test: (l) => /\b(role\s*:\s*["']system["']|system(Prompt|_prompt|Message|_message|Instruction)?\s*[:=]|["']system["']\s*,)/.test(l)
|
|
43
|
+
test: (l) => /\b(role\s*:\s*["']system["']|system(Prompt|_prompt|Message|_message|Instruction)?\s*[:=]|["']system["']\s*,)/.test(l)
|
|
44
|
+
// Not user text in the instructions: `system: undefined` next to a prompt, and a helper that picks a fixed system
|
|
45
|
+
// message from its arguments, getSystemMessage(input.locale) (0.3.14 review: 3 of 3 shown findings).
|
|
46
|
+
&& !/\bsystem\s*:\s*(undefined|null)\b/.test(l) && USER_TEXT.test(l.replace(/\bget\w*System\w*\([^()]*\)/g, "fixed")) }),
|
|
44
47
|
rule({ id: "llm.output-to-sink", title: "AI output run as code, a command, a query or page HTML", status: "gap", severity: "high", controls: [LLM10],
|
|
45
48
|
fix: "Treat model output like input from a stranger: validate it against what you expect, escape it for HTML, and never run it as code, a shell command or SQL.",
|
|
46
49
|
note: "A model's reply can be steered by anyone who can influence its input. Passing it straight to eval, a shell, a database query or innerHTML lets them run code or change data.",
|
|
@@ -71,8 +74,8 @@ export const standardsRules = [
|
|
|
71
74
|
rule({ id: "mobile.token-in-plain-storage", title: "Token or password saved in the phone's plain storage", status: "gap", severity: "high", controls: [GDPR32, A04],
|
|
72
75
|
fix: "Store tokens and passwords in the platform's secure storage: expo-secure-store, react-native-keychain, the Android Keystore or the iOS Keychain.",
|
|
73
76
|
note: "AsyncStorage and SharedPreferences aren't encrypted. Other apps on a rooted phone, or a device backup, can read what's saved there.",
|
|
74
|
-
extensions: [".ts", ".tsx", ".js", ".jsx", ".kt", ".java"],
|
|
75
|
-
test: (l) => /\b(AsyncStorage\.(setItem|multiSet)|MMKV\(\)\.set|\.putString)\s*\(/.test(l) && /token|password|secret|session|jwt|api_?key/i.test(l) }),
|
|
77
|
+
extensions: [".ts", ".tsx", ".js", ".jsx", ".kt", ".java", ".swift"],
|
|
78
|
+
test: (l) => /\b(AsyncStorage\.(setItem|multiSet)|MMKV\(\)\.set|\.putString|UserDefaults\.standard\.set(?:Value)?)\s*\(/.test(l) && /token|password|secret|session|jwt|api_?key/i.test(l) }),
|
|
76
79
|
rule({ id: "mobile.cleartext-traffic", title: "App allows unencrypted network traffic", status: "gap", severity: "high", controls: [GDPR32, A04],
|
|
77
80
|
fix: "Turn off cleartext traffic (usesCleartextTraffic false on Android, no NSAllowsArbitraryLoads on iOS) and use HTTPS everywhere. Allow exceptions per domain only if you must.",
|
|
78
81
|
note: "With cleartext allowed, anyone on the same Wi-Fi can read and change what the app sends and receives.",
|
|
@@ -88,6 +91,8 @@ export const standardsRules = [
|
|
|
88
91
|
rule({ id: "mobile.webview-any-origin", title: "In-app browser that loads any website", status: "partial", severity: "medium", controls: [A06],
|
|
89
92
|
fix: "List only the sites the WebView should open in originWhitelist, and open other links in the phone's browser.",
|
|
90
93
|
note: "A WebView that accepts any origin can be sent to a page that abuses the bridge between the web page and your app. Marked Partial: it may only ever load your own content.",
|
|
91
|
-
extensions: [".tsx", ".jsx", ".ts", ".js"],
|
|
92
|
-
test: (l) => /originWhitelist\s*=\s*\{\s*\[\s*["']\*["']\s*\]\s*\}/.test(l)
|
|
94
|
+
extensions: [".tsx", ".jsx", ".ts", ".js", ".kt", ".java"],
|
|
95
|
+
test: (l) => /originWhitelist\s*=\s*\{\s*\[\s*["']\*["']\s*\]\s*\}/.test(l)
|
|
96
|
+
// Android: a page loaded from a file may read any other local file or any site.
|
|
97
|
+
|| /\bsetAllow(UniversalAccess|FileAccess)FromFileURLs\(\s*true\s*\)|\ballow(UniversalAccess|FileAccess)FromFileURLs\s*=\s*true\b/.test(l) }),
|
|
93
98
|
];
|
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.15 by scripts/build-docs.mjs. -->
|
|
2
2
|
# Frameworks
|
|
3
3
|
|
|
4
4
|
## EU AI Act (`eu-ai-act`)
|
|
@@ -40,15 +40,15 @@ Applies to: Any organization that handles personal data while based in the EU, o
|
|
|
40
40
|
|
|
41
41
|
- Art. 5 Core principles [partly in code]: Use data fairly and openly, only for clear purposes, collect the minimum, keep it accurate, don't keep it longer than needed, and keep it secure. Rules: pii.to-analytics, pii.logged.
|
|
42
42
|
- Art. 6 A lawful reason [outside code]: Every use of personal data needs one of six legal bases, such as consent, a contract, or legitimate interests weighed against people's rights.
|
|
43
|
-
- Art. 7 Consent done right [partly in code]: If you rely on consent, it must be freely given, specific, informed and as easy to withdraw as to give. No pre-ticked boxes.
|
|
44
|
-
- Art. 9 Sensitive data [partly in code]: Health, biometric, ethnic, religious, political, sexual and union data is off-limits unless a specific exception applies. Rules: ai.emotion-or-biometric.
|
|
43
|
+
- Art. 7 Consent done right [partly in code]: If you rely on consent, it must be freely given, specific, informed and as easy to withdraw as to give. No pre-ticked boxes. Rules: privacy.consent-preticked.
|
|
44
|
+
- Art. 9 Sensitive data [partly in code]: Health, biometric, ethnic, religious, political, sexual and union data is off-limits unless a specific exception applies. Rules: ai.emotion-or-biometric, privacy.special-category-field.
|
|
45
45
|
- Art. 12–15 Transparency and access [outside code]: Tell people clearly what you collect and why, and give them a copy of their data when they ask.
|
|
46
46
|
- Art. 17 Right to erasure [partly in code]: When someone asks, and no exception applies, delete their data everywhere you hold it, including backups on rotation and third-party tools.
|
|
47
47
|
- Art. 22 Automated decisions [partly in code]: People have the right not to be subject to fully automated decisions with legal or similarly big effects, unless an exception applies and safeguards like human review are in place. Rules: ai.automated-decision.
|
|
48
48
|
- Art. 25 Privacy by design and default [partly in code]: Build privacy in from the start, and make the most private setting the default. Rules: pii.in-url, pii.to-analytics.
|
|
49
49
|
- Art. 28 Processors [partly in code]: Vendors that handle personal data for you need a contract with specific data protection terms. Rules: pii.to-analytics.
|
|
50
50
|
- Art. 30 Records of processing [outside code]: Keep a list of what personal data you process, why, with whom you share it and how long you keep it.
|
|
51
|
-
- Art. 32 Security of processing [checked in code]: Protect personal data with security that fits the risk: encryption, access control, testing and the ability to recover. Rules: pii.logged, secret.in-source, transport.plain-http, transport.tls-verify-off, crypto.weak-password-hash, sql.string-built, pii.in-url, supabase.rls-disabled, supabase.policy-allows-all, supabase.service-key-in-client, supabase.function-no-auth, secret.public-env, mobile.token-in-plain-storage, mobile.cleartext-traffic, mobile.backup-allowed.
|
|
51
|
+
- Art. 32 Security of processing [checked in code]: Protect personal data with security that fits the risk: encryption, access control, testing and the ability to recover. Rules: crypto.static-iv, crypto.weak-parameters, mobile.debuggable-build, payment.card-code-stored, pii.logged, secret.in-source, transport.plain-http, transport.tls-verify-off, crypto.weak-password-hash, sql.string-built, pii.in-url, supabase.rls-disabled, supabase.policy-allows-all, supabase.service-key-in-client, supabase.function-no-auth, secret.public-env, mobile.token-in-plain-storage, mobile.cleartext-traffic, mobile.backup-allowed.
|
|
52
52
|
- Art. 33–34 Breach notification [outside code]: Tell the regulator within 72 hours of learning about a risky breach, and tell affected people when the risk to them is high.
|
|
53
53
|
- Art. 35 Impact assessment (DPIA) [outside code]: Before risky processing, such as large-scale profiling or new AI uses on personal data, assess and reduce the risks.
|
|
54
54
|
- Art. 44–49 Transfers outside the EU [partly in code]: Sending personal data outside the EU needs an approved route, such as an adequacy decision or standard contract clauses.
|
|
@@ -62,7 +62,7 @@ Applies to: Any team building a web application or API. It's voluntary, but ofte
|
|
|
62
62
|
|
|
63
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, k8s.privileged, docker.socket-mounted, graphql.introspection.
|
|
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: cloud.database-public, cloud.network-open, cloud.iam-allow-all, cloud.function-url-no-auth, docker.runs-as-root, docker.image-unpinned, docker.secret-in-build, 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, docker.socket-mounted, 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.
|
|
@@ -99,9 +99,9 @@ Applies to: Businesses that make, import or sell software or connected hardware
|
|
|
99
99
|
- Annex I Part I (2)(j) Limited attack surface [partly in code]: Fewer ways in: no open redirects, no server requests to any address a user picks, limits on uploads, and errors that don't reveal internals. Rules: ssrf.user-url, redirect.open, upload.unrestricted, error.stack-to-client.
|
|
100
100
|
- Annex I Part I (2)(l) Security logging [partly in code]: Security-relevant activity is recorded so problems can be spotted, without putting secrets in the logs or letting entries be forged. Users should be able to opt out where it fits. Rules: log.secret, log.injection.
|
|
101
101
|
- Annex I Part I (2)(a) No known exploitable vulnerabilities [outside code]: Nothing ships with a vulnerability that's already public and exploitable, including in dependencies. This needs advisory data, which Lintsure doesn't download, so use a dependency scanner alongside it.
|
|
102
|
-
- Annex I Part II (1) Components identified, including an SBOM [partly in code]: You know what's in your product: pinned dependencies, no unexplained compiled files, and a machine-readable software bill of materials (SBOM) covering at least the top-level components. Rules: repo.no-sbom, repo.binary-committed, deps.unpinned-version, deps.install-script.
|
|
102
|
+
- Annex I Part II (1) Components identified, including an SBOM [partly in code]: You know what's in your product: pinned dependencies, no unexplained compiled files, and a machine-readable software bill of materials (SBOM) covering at least the top-level components. Rules: repo.no-sbom, repo.binary-committed, deps.unpinned-version, deps.install-script, deps.unsafe-source.
|
|
103
103
|
- Annex I Part II (5) Coordinated vulnerability disclosure policy [partly in code]: A published way for anyone to report a vulnerability to you, and a process for handling reports. Rules: repo.no-security-policy.
|
|
104
|
-
- Annex I Part II (7) Updates distributed securely [partly in code]: Builds and updates can't be swapped or tampered with: pinned CI steps, workflow tokens limited to what they need, untrusted pull requests and issue text kept away from secrets and commands, and nothing run straight from a download without a check. Rules: update.unverified-download, ci.action-unpinned, ci.prt-checkout-head, ci.write-all-permissions, ci.script-injection.
|
|
104
|
+
- Annex I Part II (7) Updates distributed securely [partly in code]: Builds and updates can't be swapped or tampered with: pinned CI steps, workflow tokens limited to what they need, untrusted pull requests and issue text kept away from secrets and commands, and nothing run straight from a download without a check. Rules: update.unverified-download, ci.action-unpinned, ci.prt-checkout-head, ci.write-all-permissions, ci.script-injection, ci.scan-cannot-fail.
|
|
105
105
|
- Annex I Part II (2) Vulnerabilities fixed without delay [partly in code]: When a component you use gets a security fix, it reaches your product quickly. Automated update pull requests are the usual way to make that happen. Rules: repo.no-dependency-updates.
|
|
106
106
|
- Annex I Part II (2), (8) Free security updates for the support period [outside code]: Vulnerabilities are fixed without delay and security updates are free for the support period, which is at least five years unless the product is expected to be used for less, and stated when it's sold (Art. 13(8)).
|
|
107
107
|
- Art. 13(2) Cybersecurity risk assessment [outside code]: A documented assessment of the product's security risks, kept up to date and used to decide which requirements apply and how.
|
|
@@ -115,10 +115,10 @@ The ten most serious security risks in apps built on large language models: prom
|
|
|
115
115
|
|
|
116
116
|
Applies to: Any team that builds a feature on an AI model: chatbots, assistants, agents, retrieval (RAG) and AI features inside other apps.
|
|
117
117
|
|
|
118
|
-
- LLM01:2026 Prompt Injection [partly in code]: User text, web pages or files can carry instructions that change what the model does. Keep instructions and user content apart, and limit what the model can do. Rules: llm.user-input-in-system-prompt, agent.instructions-unsafe, llm.client-controls-system.
|
|
118
|
+
- LLM01:2026 Prompt Injection [partly in code]: User text, web pages or files can carry instructions that change what the model does. Keep instructions and user content apart, and limit what the model can do. Rules: llm.user-input-in-system-prompt, agent.instructions-unsafe, llm.client-controls-system, mcp.tool-description-poisoned.
|
|
119
119
|
- LLM02:2026 Sensitive Information Disclosure [partly in code]: Keys, personal data and internal details must not reach the model, its logs or its answers unless they're meant to. Rules: secret.in-source, secret.public-env, pii.logged, log.secret.
|
|
120
120
|
- LLM03:2026 Excessive Agency [partly in code]: Tools and permissions given to an agent should be the minimum it needs, with a person approving anything risky. Rules: agent.permissions-allow-all, mcp.tool-runs-shell, mcp.tool-uses-secret.
|
|
121
|
-
- LLM04:2026 Supply Chain [partly in code]: Models, datasets, plugins and packages come from others. Pin and check them like any dependency. Rules: deps.unpinned-version, deps.install-script, agent.config-runs-remote-code, ml.unsafe-model-load.
|
|
121
|
+
- LLM04:2026 Supply Chain [partly in code]: Models, datasets, plugins and packages come from others. Pin and check them like any dependency. Rules: deps.unpinned-version, deps.install-script, agent.config-runs-remote-code, ml.unsafe-model-load, mcp.config-unsafe-server.
|
|
122
122
|
- LLM05:2026 Data and Model Poisoning [outside code]: Training, fine-tuning or retrieval data can be tampered with to change the model's behaviour.
|
|
123
123
|
- LLM06:2026 Unbounded Consumption [partly in code]: Limit output size, request rate and cost per user, so one person can't run up a bill or take the service down. Rules: llm.no-output-limit, ai.call-not-logged, llm.unbounded-agent-loop.
|
|
124
124
|
- LLM07:2026 Misinformation [outside code]: Models state wrong things confidently. Show sources, say it's AI and keep a person in the loop where it matters.
|
package/docs/rules.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<!-- Generated from Lintsure 0.3.
|
|
2
|
-
# Lintsure rules (
|
|
1
|
+
<!-- Generated from Lintsure 0.3.15 by scripts/build-docs.mjs. -->
|
|
2
|
+
# Lintsure rules (106)
|
|
3
3
|
|
|
4
4
|
## pii.logged
|
|
5
5
|
**Personal data written to logs** · status when found: gap · risk: high
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
|
|
224
224
|
- Controls: owasp-top10 A03:2025 (Software Supply Chain Failures); owasp-llm LLM01:2026 (Prompt Injection)
|
|
225
225
|
- Fix: Remove the line, or rewrite it so the agent asks the user first. Install tools with a pinned, reviewed command instead of piping a download into a shell, and never tell an agent to keep something from the user.
|
|
226
|
-
- Note: Agents read these files as instructions and act on them with your permissions. Gap when the line overrides earlier instructions, hides something from the user or sends secrets out. Partial when it downloads and runs a script, which some setup guides do on purpose (CWE-829, OWASP LLM01).
|
|
226
|
+
- Note: Agents read these files as instructions and act on them with your permissions. Gap when the line overrides earlier instructions, hides something from the user, carries characters a person can't see, or sends secrets out. Partial when it downloads and runs a script, which some setup guides do on purpose (CWE-829, OWASP LLM01).
|
|
227
227
|
- When Partial, Lintsure can't see: Lintsure reads the line, not who wrote it or whether the file came from a trusted skill. Check where this file came from before an agent uses it.
|
|
228
228
|
- Page: https://lintsure.com/rules/agent-instructions-unsafe
|
|
229
229
|
|
|
@@ -404,6 +404,131 @@
|
|
|
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
|
+
## crypto.static-iv
|
|
408
|
+
**Encryption with a fixed IV or nonce** · status when found: gap · risk: medium
|
|
409
|
+
|
|
410
|
+
- Controls: owasp-top10 A04:2025 (Cryptographic Failures); gdpr Art. 32 (Security of processing)
|
|
411
|
+
- Fix: Make a new random IV for every message (crypto.randomBytes, os.urandom, SecureRandom) and store it next to the ciphertext. It doesn't need to be secret, only never reused.
|
|
412
|
+
- Note: With the same key and the same IV, two messages can be compared and partly recovered. In AES-GCM a repeated nonce lets an attacker forge messages (CWE-329, CWE-323).
|
|
413
|
+
- Page: https://lintsure.com/rules/crypto-static-iv
|
|
414
|
+
|
|
415
|
+
## crypto.weak-parameters
|
|
416
|
+
**Key size or work factor too low** · status when found: gap · risk: medium
|
|
417
|
+
|
|
418
|
+
- Controls: owasp-top10 A04:2025 (Cryptographic Failures); gdpr Art. 32 (Security of processing)
|
|
419
|
+
- Fix: Use RSA keys of 2048 bits or more, bcrypt with 10 rounds or more, and PBKDF2 with the iteration count current guidance gives (600,000 for SHA-256), or switch to Argon2.
|
|
420
|
+
- Note: Short keys can be factored and low work factors make stolen password hashes cheap to crack on ordinary hardware (CWE-326, CWE-916).
|
|
421
|
+
- Page: https://lintsure.com/rules/crypto-weak-parameters
|
|
422
|
+
|
|
423
|
+
## mobile.debuggable-build
|
|
424
|
+
**Android release build that can be debugged** · status when found: gap · risk: medium
|
|
425
|
+
|
|
426
|
+
- Controls: owasp-top10 A02:2025 (Security Misconfiguration); gdpr Art. 32 (Security of processing)
|
|
427
|
+
- Fix: Remove android:debuggable from the manifest and keep debuggable false in the release build type. The build tools set it for debug builds on their own.
|
|
428
|
+
- Note: A debuggable app lets anyone with the phone attach a debugger, read its private files and change what it does (CWE-489).
|
|
429
|
+
- Page: https://lintsure.com/rules/mobile-debuggable-build
|
|
430
|
+
|
|
431
|
+
## privacy.consent-preticked
|
|
432
|
+
**Consent box that starts ticked** · status when found: gap · risk: medium
|
|
433
|
+
|
|
434
|
+
- Controls: gdpr Art. 7 (Conditions for consent)
|
|
435
|
+
- Fix: Start the box empty and let the person tick it. Store when they did and the wording they saw.
|
|
436
|
+
- Note: Consent has to be an active choice. A box that is ticked for the person is not consent under the GDPR, so anything sent on that basis has no legal ground (Art. 7, recital 32).
|
|
437
|
+
- When Partial, Lintsure can't see: Lintsure can't tell whether this box is the legal basis for anything. A ticked box for a setting the person already chose earlier is fine.
|
|
438
|
+
- Page: https://lintsure.com/rules/privacy-consent-preticked
|
|
439
|
+
|
|
440
|
+
## privacy.special-category-field
|
|
441
|
+
**Sensitive category of personal data stored** · status when found: partial · risk: medium
|
|
442
|
+
|
|
443
|
+
- Controls: gdpr Art. 9 (Special categories of personal data)
|
|
444
|
+
- Fix: Check that you need this field at all. If you do, write down the Art. 9 exception you rely on, usually explicit consent, and limit who can read it.
|
|
445
|
+
- Note: Religion, ethnicity, sexual orientation, political views, union membership, health and genetic data may not be processed unless a specific exception applies. Marked Partial: the exception is a decision outside the code.
|
|
446
|
+
- Page: https://lintsure.com/rules/privacy-special-category-field
|
|
447
|
+
|
|
448
|
+
## payment.card-code-stored
|
|
449
|
+
**Card security code stored** · status when found: gap · risk: high
|
|
450
|
+
|
|
451
|
+
- Controls: gdpr Art. 32 (Security of processing); owasp-top10 A02:2025 (Security Misconfiguration)
|
|
452
|
+
- Fix: Never store the card security code. Send the card straight to your payment provider and keep only the token it gives back.
|
|
453
|
+
- Note: The three or four digit code exists to prove the card is in the buyer's hand. Card scheme rules (PCI DSS 3.3.1) forbid keeping it after authorisation, even encrypted, and a leak makes every stored card usable.
|
|
454
|
+
- Page: https://lintsure.com/rules/payment-card-code-stored
|
|
455
|
+
|
|
456
|
+
## cloud.database-public
|
|
457
|
+
**Database reachable from the internet** · status when found: gap · risk: high
|
|
458
|
+
|
|
459
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control); owasp-top10 A02:2025 (Security Misconfiguration)
|
|
460
|
+
- Fix: Set publicly_accessible to false, put the database in a private subnet, and reach it through the app, a bastion or a VPN.
|
|
461
|
+
- Note: A database with a public address is one leaked or guessed password away from a full data breach, and it is found by scanners within hours (CWE-284).
|
|
462
|
+
- Page: https://lintsure.com/rules/cloud-database-public
|
|
463
|
+
|
|
464
|
+
## cloud.network-open
|
|
465
|
+
**Admin or database port open to the whole internet** · status when found: gap · risk: high
|
|
466
|
+
|
|
467
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control); owasp-top10 A02:2025 (Security Misconfiguration)
|
|
468
|
+
- Fix: Limit the rule to the addresses that need it (your office, a VPN, a bastion), or remove it and use a session manager.
|
|
469
|
+
- Note: Remote login and database ports that accept connections from 0.0.0.0/0 are scanned and attacked all day (CWE-284).
|
|
470
|
+
- When Partial, Lintsure can't see: Lintsure reads this file only. It can't see a network ACL or a firewall in front that narrows the rule.
|
|
471
|
+
- Page: https://lintsure.com/rules/cloud-network-open
|
|
472
|
+
|
|
473
|
+
## cloud.iam-allow-all
|
|
474
|
+
**Policy that allows every action on every resource** · status when found: gap · risk: high
|
|
475
|
+
|
|
476
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control); owasp-top10 A02:2025 (Security Misconfiguration)
|
|
477
|
+
- Fix: List the actions and resources the role really needs. Start from what it calls today and add as you go.
|
|
478
|
+
- Note: Whoever gets this role's credentials, through a leaked key or a compromised service, controls the whole account (CWE-732).
|
|
479
|
+
- Page: https://lintsure.com/rules/cloud-iam-allow-all
|
|
480
|
+
|
|
481
|
+
## cloud.function-url-no-auth
|
|
482
|
+
**Function URL that anyone can call** · status when found: partial · risk: medium
|
|
483
|
+
|
|
484
|
+
- Controls: owasp-top10 A01:2025 (Broken Access Control); owasp-top10 A07:2025 (Authentication Failures)
|
|
485
|
+
- Fix: Use AWS_IAM as the authorization type, or check a signature or token in the function before doing anything.
|
|
486
|
+
- Note: With authorization set to NONE the function runs for anyone who has the URL. Marked Partial: public webhooks do this on purpose and check a signature in code.
|
|
487
|
+
- Page: https://lintsure.com/rules/cloud-function-url-no-auth
|
|
488
|
+
|
|
489
|
+
## docker.runs-as-root
|
|
490
|
+
**Container image that runs as root** · status when found: partial · risk: low
|
|
491
|
+
|
|
492
|
+
- Controls: owasp-top10 A02:2025 (Security Misconfiguration)
|
|
493
|
+
- Fix: Add a user and switch to it in the last stage, for example `RUN adduser -D app` then `USER app`, or use a base image built to run without root.
|
|
494
|
+
- Note: With no USER line the app runs as root inside the container. A bug that lets someone run code then starts with full rights in the container, which makes breaking out to the host much easier (CWE-250). Marked Partial: the platform may set the user when it starts the container.
|
|
495
|
+
- When Partial, Lintsure can't see: Lintsure can't see a user set at run time (Kubernetes runAsUser, docker run --user) or one the base image already sets.
|
|
496
|
+
- Page: https://lintsure.com/rules/docker-runs-as-root
|
|
497
|
+
|
|
498
|
+
## docker.image-unpinned
|
|
499
|
+
**Base image with no fixed version** · status when found: partial · risk: low
|
|
500
|
+
|
|
501
|
+
- Controls: owasp-top10 A08:2025 (Software or Data Integrity Failures)
|
|
502
|
+
- Fix: Name a version, for example `FROM node:22.11-slim`, and update it on purpose. Pin a digest for anything you ship to others.
|
|
503
|
+
- Note: With no tag, or `latest`, every build can pull a different image, so a broken or tampered release reaches you without any change in your repo (CWE-829).
|
|
504
|
+
- Page: https://lintsure.com/rules/docker-image-unpinned
|
|
505
|
+
|
|
506
|
+
## docker.secret-in-build
|
|
507
|
+
**Secret given a value in a Dockerfile** · status when found: gap · risk: high
|
|
508
|
+
|
|
509
|
+
- Controls: owasp-top10 A02:2025 (Security Misconfiguration); owasp-top10 A08:2025 (Software or Data Integrity Failures)
|
|
510
|
+
- Fix: Pass the secret when the container starts (an environment variable or a mounted secret), or use `RUN --mount=type=secret` for build steps. Rotate the value: it is in every image built so far.
|
|
511
|
+
- Note: ENV and ARG values are stored in the image. Anyone who can pull the image, or read its build history, can read the secret (CWE-798).
|
|
512
|
+
- Page: https://lintsure.com/rules/docker-secret-in-build
|
|
513
|
+
|
|
514
|
+
## mcp.config-unsafe-server
|
|
515
|
+
**MCP server run from a moving version or over plain HTTP** · status when found: partial · risk: medium
|
|
516
|
+
|
|
517
|
+
- Controls: owasp-llm LLM04:2026 (Supply Chain); owasp-top10 A08:2025 (Software or Data Integrity Failures)
|
|
518
|
+
- Fix: Pin the server to an exact version you have looked at, for example some-server@1.4.2, and update it on purpose. Use https for a remote server.
|
|
519
|
+
- Note: An agent trusts the tools this server offers. With no version, or @latest, the next start can load different code and different tool descriptions than the ones you approved. Over plain HTTP anyone on the network path can change them (OWASP LLM04, CWE-829).
|
|
520
|
+
- When Partial, Lintsure can't see: Lintsure can't see whether a lockfile or a private registry pins this package somewhere else.
|
|
521
|
+
- Page: https://lintsure.com/rules/mcp-config-unsafe-server
|
|
522
|
+
|
|
523
|
+
## mcp.tool-description-poisoned
|
|
524
|
+
**MCP tool description that gives the agent orders** · status when found: gap · risk: high
|
|
525
|
+
|
|
526
|
+
- Controls: owasp-llm LLM01:2026 (Prompt Injection); owasp-llm LLM04:2026 (Supply Chain)
|
|
527
|
+
- Fix: Rewrite the description so it only says what the tool does and what it takes. Remove anything that tells the agent to ignore instructions, keep something from the user or read other files, and delete any invisible characters.
|
|
528
|
+
- Note: An agent reads tool descriptions as part of its instructions. A description that says to hide a step, ignore earlier rules or read key files can take over every agent that connects to this server (OWASP LLM01, CWE-1427).
|
|
529
|
+
- When Partial, Lintsure can't see: Lintsure reads this server's source, not the servers it connects to. It can't tell a real attack from a security tool that lists these phrases to detect them.
|
|
530
|
+
- Page: https://lintsure.com/rules/mcp-tool-description-poisoned
|
|
531
|
+
|
|
407
532
|
## mcp.tool-runs-shell
|
|
408
533
|
**MCP tool that runs shell commands** · status when found: partial · risk: high
|
|
409
534
|
|
|
@@ -597,6 +722,22 @@
|
|
|
597
722
|
- When Partial, Lintsure can't see: Lintsure looked for a rate limiter in this file, middleware and package.json. It can't see limits set in a firewall, gateway or hosting dashboard.
|
|
598
723
|
- Page: https://lintsure.com/rules/auth-no-rate-limit
|
|
599
724
|
|
|
725
|
+
## ci.scan-cannot-fail
|
|
726
|
+
**Security scan in CI that can never fail the build** · status when found: partial · risk: low
|
|
727
|
+
|
|
728
|
+
- Controls: cra Annex I Part II (7) (Updates distributed securely); owasp-top10 A03:2025 (Software Supply Chain Failures)
|
|
729
|
+
- Fix: Let the scan fail the job. If it is too noisy, limit it to high severity or to new findings instead of ignoring its result.
|
|
730
|
+
- Note: With `|| true`, a soft-fail flag or continue-on-error, the scan runs and reports but nothing stops a build that has findings, so it gives a sense of safety it doesn't deliver. Marked Partial: some teams read the report by hand on purpose.
|
|
731
|
+
- Page: https://lintsure.com/rules/ci-scan-cannot-fail
|
|
732
|
+
|
|
733
|
+
## deps.unsafe-source
|
|
734
|
+
**Packages fetched from a source that can be swapped** · status when found: gap · risk: medium
|
|
735
|
+
|
|
736
|
+
- Controls: cra Annex I Part II (1) (Components identified, including an SBOM); owasp-top10 A03:2025 (Software Supply Chain Failures); owasp-top10 A08:2025 (Software or Data Integrity Failures)
|
|
737
|
+
- Fix: Use one index or registry over https. For private packages, point only their scope or name at the private registry (npm: @scope:registry=..., pip: --index-url with a proxy that serves both) instead of adding a second index.
|
|
738
|
+
- Note: Over plain HTTP, or with certificate checks off, anyone on the network path can serve a different package. With a second pip index, a public package that takes an internal name with a higher version is installed instead (dependency confusion, CWE-829). Partial for the second-index case: your internal names may already be reserved.
|
|
739
|
+
- Page: https://lintsure.com/rules/deps-unsafe-source
|
|
740
|
+
|
|
600
741
|
## repo.no-security-policy
|
|
601
742
|
**No way for people to report a vulnerability** · status when found: partial · risk: medium
|
|
602
743
|
|