@lintsure/core 0.3.15 → 0.3.16

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.
@@ -10,7 +10,7 @@ export const owaspLlm = {
10
10
  return null;
11
11
  },
12
12
  obligations: [
13
- { ref: "LLM01:2026", title: "Prompt Injection", inCode: "partly", rules: ["llm.user-input-in-system-prompt", "agent.instructions-unsafe", "llm.client-controls-system", "mcp.tool-description-poisoned"],
13
+ { ref: "LLM01:2026", title: "Prompt Injection", inCode: "partly", rules: ["llm.user-input-in-system-prompt", "llm.retrieved-text-in-system-prompt", "agent.instructions-unsafe", "llm.client-controls-system", "mcp.tool-description-poisoned"],
14
14
  plain: "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.",
15
15
  evidence: "How prompts are built, and tests with hostile input." },
16
16
  { ref: "LLM02:2026", title: "Sensitive Information Disclosure", inCode: "partly", rules: ["secret.in-source", "secret.public-env", "pii.logged", "log.secret"],
@@ -64,3 +64,89 @@ export const cweTop25 = {
64
64
  watchOut: ["The list ranks weaknesses by data from published vulnerabilities; it changes a little each year.", "Seven of the 25 are memory-safety weaknesses that don't apply to JavaScript, TypeScript or Python code."],
65
65
  checkedOn: "2026-11-09",
66
66
  };
67
+ // The list is an OWASP incubator project, version 1.0 (2026), in public review when this was written. Ids and names only.
68
+ export const owaspAst = {
69
+ id: "owasp-ast", name: "OWASP Agentic Skills Top 10", kind: "standard",
70
+ summary: "Ten risks in the skills, instruction files and tool servers that AI coding agents load: malicious skills, a poisoned supply chain, too many permissions, misleading metadata, instructions fetched at run time, weak isolation, silent updates, weak scanning, no inventory and reuse across platforms. It's a young awareness list, still in public review, not a law or certification.",
71
+ whoItAppliesTo: "Any team whose developers or products use an AI agent that loads skills, instruction files or MCP servers.",
72
+ applies(p) {
73
+ // The profile describes the product, not the team's tools, so this follows the same signal as the LLM list.
74
+ return p.usesAI && (p.generativeAI || p.interactsWithPeople) ? "Agents load skills, instruction files and tool servers as instructions, so what is in them is part of your supply chain." : null;
75
+ },
76
+ obligations: [
77
+ { ref: "AST01", title: "Malicious Skills", inCode: "partly", rules: ["agent.instructions-unsafe", "skill.writes-agent-memory"],
78
+ plain: "A skill can look useful and still tell the agent to hide a step, send secrets out or change its own instructions. Read a skill's text like code before an agent uses it.",
79
+ evidence: "Where each installed skill came from, and who read it before it was added." },
80
+ { ref: "AST02", title: "Supply Chain Compromise", inCode: "partly", rules: ["agent.config-runs-remote-code", "mcp.config-unsafe-server"],
81
+ plain: "Skills, hooks and tool servers come from others. Pin them to a version you have read, and treat config files an agent runs by itself as code.",
82
+ evidence: "A list of installed skills and servers with their versions and sources." },
83
+ { ref: "AST03", title: "Over-Privileged Skills", inCode: "partly", rules: ["agent.permissions-allow-all", "skill.unrestricted-shell"],
84
+ plain: "A skill should get only the tools, files and network access its job needs. Open shell access makes every other limit moot.",
85
+ evidence: "The permissions each skill declares, and why it needs them." },
86
+ { ref: "AST04", title: "Insecure Metadata", inCode: "partly", rules: ["agent.instructions-unsafe"],
87
+ plain: "A skill's description and front matter are read by the agent too. They must match what the skill does and carry no hidden characters.",
88
+ evidence: "A check that each skill's description matches its behaviour." },
89
+ { ref: "AST05", title: "Untrusted External Instructions", inCode: "partly", rules: ["skill.fetches-remote-instructions"],
90
+ plain: "A skill that tells the agent to fetch a page and follow it hands control to whoever owns that page tomorrow. Keep the instructions inside the skill, or pin what is fetched.",
91
+ evidence: "Every outside page or file a skill reads at run time." },
92
+ { ref: "AST06", title: "Weak Isolation", inCode: "partly", rules: ["mcp.server-binds-all-interfaces"],
93
+ plain: "Skills and tool servers should run boxed in: local interfaces only, with sign-in, and limited to the files they declare.",
94
+ evidence: "How each tool server is started, where it listens and who can reach it." },
95
+ { ref: "AST07", title: "Update Drift", inCode: "partly", rules: ["mcp.config-unsafe-server"],
96
+ plain: "A skill or server that updates by itself can change after you approved it. Pin versions and look again on every update.",
97
+ evidence: "How updates to skills and servers are approved." },
98
+ { ref: "AST08", title: "Poor Scanning", inCode: "no",
99
+ plain: "A pattern scanner reads code well and prose badly, and a skill is mostly prose. Use more than one kind of check, and never rely on a scanner that is itself a skill.",
100
+ evidence: "Which checks run on a skill before it is installed, and what they cannot see." },
101
+ { ref: "AST09", title: "No Governance", inCode: "no",
102
+ plain: "Someone should know which skills are installed, who approved each one and how to remove one fast.",
103
+ evidence: "A skill inventory with an owner, an approval and a review date for each entry." },
104
+ { ref: "AST10", title: "Cross-Platform Reuse", inCode: "no",
105
+ plain: "A skill moved from one agent to another can lose its limits on the way, because each agent enforces different things. Check it again on each one.",
106
+ evidence: "For a skill used on several agents, what each agent enforces." },
107
+ ],
108
+ watchOut: ["The list is version 1.0 from an OWASP incubator project and was in public review when we mapped it, so ids and names may change.", "Lintsure reads a skill one line at a time. It can't judge whether a skill's description matches what it does, and it doesn't run the skill."],
109
+ checkedOn: "2026-11-23",
110
+ };
111
+ export const owaspApi = {
112
+ id: "owasp-api", name: "OWASP API Security Top 10 2023", kind: "standard",
113
+ summary: "The ten most serious security risks in APIs: reaching other people's records, weak sign-in, changing fields you shouldn't, no limits on use, calling functions meant for others, abusing business flows, server-side request forgery, misconfiguration, forgotten API versions and trusting other APIs too much. It's an awareness list, not a law or certification.",
114
+ whoItAppliesTo: "Any team whose product has an API: a backend for a web or mobile app, a public API, or endpoints called by other services.",
115
+ applies(p) {
116
+ return p.personalData || p.cardPayments ? "Personal and payment data usually travels through your API, and most API breaches are access-control failures." : null;
117
+ },
118
+ obligations: [
119
+ { ref: "API1:2023", title: "Broken Object Level Authorization", inCode: "partly", rules: ["authz.no-owner-check", "supabase.rls-disabled", "supabase.policy-allows-all"],
120
+ plain: "Every request for a record by id must check that this caller may see that record. A valid sign-in is not enough.",
121
+ evidence: "Tests that sign in as one user and ask for another user's records." },
122
+ { ref: "API2:2023", title: "Broken Authentication", inCode: "partly", rules: ["auth.hardcoded-password", "jwt.unverified", "jwt.no-expiry", "jwt.no-algorithm-pin", "jwt.weak-secret", "crypto.weak-password-hash", "session.cookie-insecure", "auth.no-rate-limit"],
123
+ plain: "Sign-in, tokens and password resets must resist guessing, forgery and theft: verified tokens that expire, strong password hashing and limits on attempts.",
124
+ evidence: "How tokens are issued, checked and revoked, and the limits on sign-in attempts." },
125
+ { ref: "API3:2023", title: "Broken Object Property Level Authorization", inCode: "partly", rules: ["mass-assignment"],
126
+ plain: "A caller should only read and change the fields meant for them. Don't save a whole request body, and don't return whole records.",
127
+ evidence: "For each endpoint, the fields a caller may read and the fields they may change." },
128
+ { ref: "API4:2023", title: "Unrestricted Resource Consumption", inCode: "partly", rules: ["auth.no-rate-limit", "llm.no-output-limit", "llm.unbounded-agent-loop", "upload.unrestricted"],
129
+ plain: "Limit how often, how much and how long: request rates, page sizes, upload sizes, and anything you pay for per call.",
130
+ evidence: "The limits in code and at the gateway, and spending caps with providers." },
131
+ { ref: "API5:2023", title: "Broken Function Level Authorization", inCode: "partly", rules: ["authz.admin-route-no-check", "cookie.trusted-role", "supabase.function-no-auth", "cloud.function-url-no-auth"],
132
+ plain: "Admin and other privileged endpoints must check the caller's role on the server. Hiding the button in the app does not protect the endpoint.",
133
+ evidence: "A list of privileged endpoints and where each one checks the role." },
134
+ { ref: "API6:2023", title: "Unrestricted Access to Sensitive Business Flows", inCode: "no",
135
+ plain: "A flow such as buying, booking or signing up can be abused when it is run at scale by a script, even if every single call is allowed.",
136
+ evidence: "Which flows could hurt the business if automated, and what slows automation down." },
137
+ { ref: "API7:2023", title: "Server Side Request Forgery", inCode: "partly", rules: ["ssrf.user-url"],
138
+ plain: "When the server fetches an address a caller supplied, check it against an allow-list first, or it can be pointed at your own internal systems.",
139
+ evidence: "Every place the server fetches a caller-supplied address, and the allow-list for each." },
140
+ { ref: "API8:2023", title: "Security Misconfiguration", inCode: "partly", rules: ["cors.any-origin", "config.debug-on", "error.stack-to-client", "graphql.introspection", "config.allowed-hosts-any", "transport.tls-verify-off"],
141
+ plain: "Open CORS, debug mode, detailed errors and switched-off checks give attackers a head start. Ship with them closed.",
142
+ evidence: "The production configuration, and who can change it." },
143
+ { ref: "API9:2023", title: "Improper Inventory Management", inCode: "no",
144
+ plain: "Old versions, test hosts and undocumented endpoints stay reachable long after everyone forgot them, usually with weaker protection.",
145
+ evidence: "A current list of API hosts and versions, and when each old one is switched off." },
146
+ { ref: "API10:2023", title: "Unsafe Consumption of APIs", inCode: "partly", rules: ["transport.tls-verify-off", "transport.plain-http"],
147
+ plain: "Data from another company's API is input like any other. Reach it over verified TLS, validate what comes back, and don't follow its redirects blindly.",
148
+ evidence: "The third-party APIs you call, and how each response is validated." },
149
+ ],
150
+ watchOut: ["Most API breaches are logic flaws: the code works as written and still lets the wrong person in. A pattern check sees only part of that.", "Lintsure reads one file at a time, with the project's middleware. A check that lives in a gateway or a shared wrapper may not be seen."],
151
+ checkedOn: "2026-11-23",
152
+ };
@@ -23,7 +23,7 @@ export const owaspTop10 = {
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: ["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"],
26
+ 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", "docker.copies-everything", "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"],
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",
@@ -1,6 +1,7 @@
1
1
  import type { Finding, Report } from "./types.js";
2
2
  export declare const BASELINE_FILE = ".lintsure/baseline.json";
3
3
  export declare const ACCEPTED_FILE = ".lintsure/accepted.yaml";
4
+ export declare const CONFIRMED_FILE = ".lintsure/confirmed.yaml";
4
5
  /** A short one-way hash of the rule, file and the flagged line with spacing normalised. Moving the line keeps it; editing it changes it. */
5
6
  export declare function fingerprint(ruleId: string, file: string, lineText: string): string;
6
7
  export interface Baseline {
@@ -25,6 +26,15 @@ export interface AcceptedEntry {
25
26
  export declare function toBaseline(r: Report, created: string): Baseline;
26
27
  /** Reads the simple list form of accepted.yaml: "- key: value" items with indented "key: value" lines. */
27
28
  export declare function parseAccepted(text: string): AcceptedEntry[];
29
+ /** confirmed.yaml: the same list form as accepted.yaml. Each entry needs rule, fingerprint and confirmed_by; date and
30
+ * note are optional. Pure. */
31
+ export declare function parseConfirmed(text: string): {
32
+ rule: string;
33
+ fingerprint: string;
34
+ confirmed_by: string;
35
+ date?: string;
36
+ note?: string;
37
+ }[];
28
38
  /** Adds acceptances, new/unchanged marks and the list of fixed findings, from the repo's .lintsure/ files. */
29
39
  export declare function applyReview(r: Report, root: string, today: string): Promise<Report>;
30
40
  /** Findings still needing a decision: not accepted, or accepted but past the review date. */
@@ -6,6 +6,9 @@ import { readFile } from "node:fs/promises";
6
6
  import { join } from "node:path";
7
7
  export const BASELINE_FILE = ".lintsure/baseline.json";
8
8
  export const ACCEPTED_FILE = ".lintsure/accepted.yaml";
9
+ // Findings a reviewer read against the code and found real. Same list form as accepted.yaml, so a verdict is not lost
10
+ // when the conversation that reached it ends.
11
+ export const CONFIRMED_FILE = ".lintsure/confirmed.yaml";
9
12
  /** A short one-way hash of the rule, file and the flagged line with spacing normalised. Moving the line keeps it; editing it changes it. */
10
13
  export function fingerprint(ruleId, file, lineText) {
11
14
  return createHash("sha256").update(`${ruleId}\n${file}\n${lineText.trim().replace(/\s+/g, " ")}`).digest("hex").slice(0, 16);
@@ -31,6 +34,22 @@ export function parseAccepted(text) {
31
34
  }
32
35
  return out.filter((e) => e.rule && e.fingerprint && e.reason && e.accepted_by);
33
36
  }
37
+ /** confirmed.yaml: the same list form as accepted.yaml. Each entry needs rule, fingerprint and confirmed_by; date and
38
+ * note are optional. Pure. */
39
+ export function parseConfirmed(text) {
40
+ const out = [];
41
+ for (const raw of text.split(/\r?\n/)) {
42
+ const hash = raw.search(/(^|\s)#/);
43
+ const m = (hash < 0 ? raw : raw.slice(0, hash)).match(/^([ \t]*)(-[ \t]+)?([a-z_]+)[ \t]*:(.*)$/);
44
+ if (!m)
45
+ continue;
46
+ if (m[2])
47
+ out.push({});
48
+ if (out.length)
49
+ out[out.length - 1][m[3]] = m[4].trim().replace(/^["']|["']$/g, "");
50
+ }
51
+ return out.filter((e) => e.rule && e.fingerprint && e.confirmed_by);
52
+ }
34
53
  async function readText(path) { try {
35
54
  return await readFile(path, "utf8");
36
55
  }
@@ -46,6 +65,12 @@ export async function applyReview(r, root, today) {
46
65
  if (a)
47
66
  f.accepted = { reason: a.reason, by: a.accepted_by, date: a.date, reviewBy: a.review_by, expired: !!a.review_by && a.review_by < today };
48
67
  }
68
+ const confirmedText = await readText(join(root, CONFIRMED_FILE));
69
+ for (const c of confirmedText ? parseConfirmed(confirmedText) : []) {
70
+ const f = r.findings.find((x) => x.ruleId === c.rule && x.fingerprint === c.fingerprint);
71
+ if (f)
72
+ f.confirmed = { by: c.confirmed_by, date: c.date ?? "", ...(c.note ? { note: c.note } : {}) };
73
+ }
49
74
  const baseText = await readText(join(root, BASELINE_FILE));
50
75
  if (baseText) {
51
76
  let base = null;
@@ -0,0 +1,10 @@
1
+ import type { Control, Rule } from "../types.js";
2
+ /** Rules that already exist and say something about an API risk. */
3
+ export declare const apiForExisting: Record<string, Control[]>;
4
+ /** An admin endpoint whose file shows no sign of checking who is calling, in a project whose middleware has no check
5
+ * either or lets API paths through. Line of the first handler, or nothing. Pure. */
6
+ export declare function adminRouteNoCheck(lines: string[], _shared?: string, files?: Record<string, string>): Array<{
7
+ line: number;
8
+ status: "partial";
9
+ }>;
10
+ export declare const apiRules: Rule[];
@@ -0,0 +1,43 @@
1
+ const DRAFT = { mappedBy: "beta", reviewedAt: "pending" };
2
+ const API = (n, title) => ({ framework: "owasp-api", id: `API${n}:2023`, title });
3
+ const API1 = API(1, "Broken Object Level Authorization"), API2 = API(2, "Broken Authentication"), API3 = API(3, "Broken Object Property Level Authorization"), API4 = API(4, "Unrestricted Resource Consumption"), API5 = API(5, "Broken Function Level Authorization"), API7 = API(7, "Server Side Request Forgery"), API8 = API(8, "Security Misconfiguration"), API10 = API(10, "Unsafe Consumption of APIs");
4
+ /** Rules that already exist and say something about an API risk. */
5
+ export const apiForExisting = {
6
+ "authz.no-owner-check": [API1], "supabase.rls-disabled": [API1], "supabase.policy-allows-all": [API1],
7
+ "auth.hardcoded-password": [API2], "jwt.unverified": [API2], "jwt.no-expiry": [API2], "jwt.no-algorithm-pin": [API2],
8
+ "jwt.weak-secret": [API2], "crypto.weak-password-hash": [API2], "session.cookie-insecure": [API2],
9
+ "auth.no-rate-limit": [API2, API4],
10
+ "mass-assignment": [API3],
11
+ "llm.no-output-limit": [API4], "llm.unbounded-agent-loop": [API4], "upload.unrestricted": [API4],
12
+ "cookie.trusted-role": [API5], "supabase.function-no-auth": [API5], "cloud.function-url-no-auth": [API5],
13
+ "ssrf.user-url": [API7],
14
+ "cors.any-origin": [API8], "config.debug-on": [API8], "error.stack-to-client": [API8], "graphql.introspection": [API8],
15
+ "config.allowed-hosts-any": [API8],
16
+ "transport.tls-verify-off": [API8, API10], "transport.plain-http": [API10],
17
+ };
18
+ // A route file that is its own endpoint (Next.js route handlers and API pages, Nuxt server routes, SvelteKit endpoints),
19
+ // with "admin" as a part of its path. Frameworks that mount routers elsewhere are left out: the check may sit in the
20
+ // file that mounts them.
21
+ const ADMIN_ENDPOINT = /^(?=.*(^|\/)admin[\/.-])(?=.*(^|\/)(app\/.*\/route|pages\/api\/.+|server\/api\/.+|routes\/.*\+server)\.[cm]?[jt]s$)/i;
22
+ const HANDLER = /export\s+(async\s+)?(function|const)\s+(GET|POST|PUT|PATCH|DELETE)\b|export\s+default\s+(async\s+)?function|export\s+default\s+defineEventHandler|export\s*\{[^}]*\b(GET|POST|PUT|PATCH|DELETE)\b/;
23
+ // Anything that looks like the caller is being identified or checked. "admin" alone is not it: the path already says that.
24
+ const ACCESS_CHECK = /\b(role|roles|isAdmin|is_admin|requireAdmin|adminOnly|assertAdmin|permission\w*|authori[sz]\w*|getServerSession|getSession|auth\s*\(|getUser|currentUser|session|verify\w*|clerk\w*|getToken|jwt|requireAuth|withAuth|protect\w*|guard\w*|api[-_]?key|bearer|unauthori[sz]ed|forbidden|40[13])\b|\b\w*(require|ensure|assert|check|verify|with|is)\w*Admin\w*\s*\(|\badmin(Handler|Guard|Auth|Only|Route|Middleware)\w*\s*\(/i;
25
+ // Middleware that lets every API path through unchecked: an early return for /api, or a matcher that leaves api out.
26
+ const SKIPS_API = /startsWith\(\s*["'\x60]\/api\/?["'\x60]\s*\)\s*\)?\s*\{?\s*return\s+(true|NextResponse\.next|next\()|\(\?![^)\n]*\bapi\b/;
27
+ /** An admin endpoint whose file shows no sign of checking who is calling, in a project whose middleware has no check
28
+ * either or lets API paths through. Line of the first handler, or nothing. Pure. */
29
+ export function adminRouteNoCheck(lines, _shared, files = {}) {
30
+ if (ACCESS_CHECK.test(lines.join("\n")) || Object.values(files).some((t) => ACCESS_CHECK.test(t) && !SKIPS_API.test(t)))
31
+ return [];
32
+ const i = lines.findIndex((l) => HANDLER.test(l));
33
+ return i < 0 ? [] : [{ line: i + 1, status: "partial" }];
34
+ }
35
+ export const apiRules = [
36
+ { id: "authz.admin-route-no-check", title: "Admin endpoint with no access check in sight", status: "partial", severity: "high", controls: [API5, { framework: "owasp-top10", id: "A01:2025", title: "Broken Access Control" }],
37
+ fix: "Check the caller's role at the top of the handler and return 403 when it is not an admin. Do it on the server: hiding the admin page in the browser does not protect the endpoint behind it.",
38
+ note: "Anyone who knows or guesses the address can call an endpoint. An admin endpoint that never looks at who is calling gives every visitor admin actions (CWE-862, CWE-285).",
39
+ unseen: "Lintsure looked for a role, session or token check in this file and in the project's middleware. It can't see a check in a gateway, a reverse proxy or a wrapper it doesn't recognise.",
40
+ extensions: [".ts", ".js", ".mjs", ".cjs"], pathMatch: ADMIN_ENDPOINT, unlessPath: /\.(test|spec)\.[cm]?[jt]s$/,
41
+ sharedFiles: /(^|\/)(middleware|proxy|hooks\.server)\.[cm]?[jt]s$/,
42
+ fileTest: adminRouteNoCheck, ...DRAFT },
43
+ ];
@@ -3,6 +3,7 @@ import { stackRules } from "./stack.js";
3
3
  import { moreRules } from "./more.js";
4
4
  import { craForExisting, craRules } from "./cra.js";
5
5
  import { standardsForExisting, standardsRules } from "./standards.js";
6
+ import { apiForExisting, apiRules } from "./api.js";
6
7
  const CODE = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py"];
7
8
  // Beta: mapped by us from our own reading of the public texts.
8
9
  const DRAFT = { mappedBy: "beta", reviewedAt: "pending" };
@@ -340,6 +341,10 @@ const AI_CALL = new RegExp([
340
341
  /\bnew\s+(ToolLoopAgent|Experimental_Agent)\s*\(/.source,
341
342
  /\b(model|clf|classifier|pipeline)\.(predict|predict_proba|invoke|generate)\s*\(/.source,
342
343
  /\b(chain|llm|chatModel|agent|runnable)\w*\.(invoke|stream|batch)\s*\(/.source,
344
+ // Other common shapes, each in the SDK's own form so an app's own run() or chat() helper doesn't count: LiteLLM,
345
+ // Ollama, the Python Gemini SDK, Mistral, Bedrock, and a generator component run on its own.
346
+ /\blitellm\.a?completion\s*\(|\bollama\.(chat|generate)\s*\(|\.generate_content(_stream|_async)?\s*\(|\.chat\.complete(_async)?\s*\(/.source,
347
+ /\.invoke_model(_with_response_stream)?\s*\(|\bbedrock\w*\.converse(_stream)?\s*\(|\b(chat_)?generator\.run\s*\(/.source,
343
348
  // A provider URL counts only inside a request call, not where it's stored in a constant.
344
349
  /\b(fetch|axios(\.\w+)?|requests\.\w+|httpx\.\w+|ky(\.\w+)?)\s*\(\s*[`"'][^`"']*(api\.openai\.com\/v1\/(chat|responses|completions|images|audio)|api\.anthropic\.com\/v1\/messages|generativelanguage\.googleapis\.com|openrouter\.ai\/api|api\.groq\.com|api\.mistral\.ai|api\.deepseek\.com)/.source,
345
350
  ].join("|"), "i");
@@ -444,6 +449,10 @@ rules.push(...standardsRules);
444
449
  // After the push, so the new LLM rules also get their CWE tags.
445
450
  for (const r of rules)
446
451
  r.controls.push(...(standardsForExisting[r.id] ?? []));
452
+ // OWASP API Security Top 10: one rule of its own, then tags on the rules above.
453
+ rules.push(...apiRules);
454
+ for (const r of rules)
455
+ r.controls.push(...(apiForExisting[r.id] ?? []));
447
456
  // Measured on 270 findings reviewed one by one from 139 public repositories (0.3.9). These rules were real in fewer than
448
457
  // half of their sampled findings, so they are held back unless --all (show: all) is set, and the report says how many.
449
458
  // A rule moves back to high confidence when a fresh labelled sample shows it is real in most findings.
@@ -3,6 +3,10 @@ import type { Rule } from "../types.js";
3
3
  export declare function wsNoOrigin(lines: string[]): number[];
4
4
  /** Lines matching re in a file that registers MCP tools; nothing in other files. Pure. */
5
5
  export declare function inMcpServer(lines: string[], re: RegExp): number[];
6
+ /** A skill line that sends the agent to a page on the internet for its next instructions. Pure. */
7
+ export declare const followsRemote: (l: string) => boolean;
8
+ /** A skill line that has the agent change its own standing instructions or settings. Pure. */
9
+ export declare const writesMemory: (l: string) => boolean;
6
10
  /** MCP config: a server run from a version that can change after you approved it (Partial), or reached over plain HTTP (Gap). Pure.
7
11
  * shortcut: reads npx-style args only ("-y", "pkg"); add uvx and docker image tags when a field test shows them. */
8
12
  export declare function mcpConfigUnsafe(lines: string[]): Array<{
@@ -1,4 +1,4 @@
1
- import { AGENT_CONFIG, poisonedDescription } from "./owasp.js";
1
+ import { AGENT_CONFIG, AGENT_DIRS, AST, poisonedDescription } from "./owasp.js";
2
2
  const CODE = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py"];
3
3
  const JS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
4
4
  const MARKUP = [...CODE, ".html", ".vue", ".svelte", ".astro"];
@@ -35,6 +35,30 @@ export function inMcpServer(lines, re) {
35
35
  const LLM03 = { framework: "owasp-llm", id: "LLM03:2026", title: "Excessive Agency" };
36
36
  const LLM04 = { framework: "owasp-llm", id: "LLM04:2026", title: "Supply Chain" };
37
37
  const LLM01 = { framework: "owasp-llm", id: "LLM01:2026", title: "Prompt Injection" };
38
+ // Files an agent loads as a skill or a command: a SKILL.md anywhere, or a file in an agent's skills, commands or agents folder.
39
+ // AGENTS.md and CLAUDE.md are left out: a project telling its own agent to keep its notes up to date is ordinary.
40
+ const SKILL_FILE = new RegExp(String.raw `(^|\/)SKILL\.md$|(^|\/)${AGENT_DIRS}\/(skills|commands|agents)\/.+\.md$`, "i");
41
+ // A line that forbids the thing describes a guard, it doesn't ask for it.
42
+ const FORBIDDEN = /\b(never|do not|don'?t|must not|avoid|refuse)\b/i;
43
+ // "Follow the instructions at <url>", or "fetch <url> and follow it": what the agent does next is decided by that page.
44
+ const FOLLOW_REMOTE = new RegExp([
45
+ String.raw `\b(follow|obey|execute|carry out|apply|act on|do what)\b[^.\n]{0,60}\b(instructions?|steps|commands?|rules|guidance|prompts?)\b[^.\n]{0,40}\b(at|from|in|on)\s+[<(\x60]?https?:\/\/`,
46
+ String.raw `\b(fetch|download|curl|wget|retrieve|load|read|open|visit|get)\b[^.\n]{0,60}https?:\/\/\S+[^.\n]{0,80}\b(and|then)\s+(follow|execute|run|apply|obey|do what)\b`,
47
+ ].join("|"), "i");
48
+ /** A skill line that sends the agent to a page on the internet for its next instructions. Pure. */
49
+ export const followsRemote = (l) => FOLLOW_REMOTE.test(l) && !FORBIDDEN.test(l) && !/https?:\/\/(localhost|127\.|\[::1\])/i.test(l);
50
+ // The files an agent reads as its own standing instructions or settings.
51
+ const MEMORY_FILE = String.raw `(AGENTS\.md|CLAUDE\.md|GEMINI\.md|SOUL\.md|MEMORY\.md|\.cursorrules|\.windsurfrules|copilot-instructions\.md|\.claude\/settings(\.local)?\.json)`;
52
+ const WRITES_MEMORY = new RegExp(String.raw `\b(append|add|adds|write|writes|insert|modify|update|edit|overwrite|save|persist|put)\b[^.\n]{0,70}\b(to|into|in)\s+[\x60"'*]*(the\s+|your\s+)?[\x60"'*]*(?:[\w~.-]+\/)*` + MEMORY_FILE, "i");
53
+ /** A skill line that has the agent change its own standing instructions or settings. Pure. */
54
+ export const writesMemory = (l) => WRITES_MEMORY.test(l) && !FORBIDDEN.test(l);
55
+ // Front matter that hands a skill the whole shell: Bash with no command limit, every tool, or shell: true.
56
+ const OPEN_SHELL = /^\s*allowed[-_]tools\s*:.*(?<![\w-])Bash(?!\s*\()(?![\w-])|^\s*allowed[-_]tools\s*:\s*["']?\*["']?\s*$|^\s*shell\s*:\s*true\b/i;
57
+ // A server told to listen on every network interface.
58
+ // A list of allowed values in a type ("127.0.0.1" | "0.0.0.0") names the address without listening on it.
59
+ // The address must be what the server listens on: a listen call, or a host or bind setting. In a list of address
60
+ // ranges to refuse it is the opposite of a risk (check on the reference MCP servers: 1 of 1 was such a list).
61
+ const ALL_INTERFACES = { test: (l) => /(\blisten\s*\(|\bhost(name)?\s*[:=]|\bbind\w*\s*[:=(]|--host\b)[^\n]*["'\x60]0\.0\.0\.0["'\x60]/i.test(l) && !/["'\x60]\s*\|\s*["'\x60]/.test(l) };
38
62
  /** MCP config: a server run from a version that can change after you approved it (Partial), or reached over plain HTTP (Gap). Pure.
39
63
  * shortcut: reads npx-style args only ("-y", "pkg"); add uvx and docker image tags when a field test shows them. */
40
64
  export function mcpConfigUnsafe(lines) {
@@ -251,11 +275,40 @@ export const moreRules = [
251
275
  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.",
252
276
  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).",
253
277
  extensions: [""], fileName: DOCKERFILE, fileTest: dockerImageUnpinned }),
278
+ // `COPY . .` takes everything the build can see: .env files, the .git folder, and the folders coding agents keep their
279
+ // settings and notes in. A firewall rule set we studied blocks requests for those folders because they get deployed
280
+ // by accident this way. Reported once per Dockerfile, and only when no .dockerignore keeps .env out.
281
+ rule({ id: "docker.copies-everything", title: "Whole project copied into the image with nothing kept out", status: "partial", severity: "low", controls: [A02, A08],
282
+ fix: "Add a .dockerignore next to the Dockerfile that lists .env files, .git and agent folders such as .claude and .cursor, or copy only the folders the app needs.",
283
+ note: "Whatever is copied stays in the image, where anyone who can pull it can read it. Local settings, keys in .env, git history and an agent's notes about the project are not meant to ship (CWE-538).",
284
+ unseen: "Lintsure looked for a .dockerignore that mentions .env. It can't see what is on the build machine, or a build context that is narrower than the project.",
285
+ extensions: [""], fileName: DOCKERFILE, sharedFiles: /(^|\/)\.dockerignore$/,
286
+ fileTest: (lines, _shared, files = {}) => {
287
+ if (Object.values(files).some((t) => /^\s*(\*\*\/)?\.env\b/m.test(t)))
288
+ return [];
289
+ const i = lines.findIndex((l) => /^\s*(COPY|ADD)\s+(--\S+\s+)*\.\/?\s+\S/i.test(l));
290
+ return i < 0 ? [] : [i + 1];
291
+ } }),
292
+ // A memory layer keeps what users tell an agent, across sessions. That is personal data with a long life, and people
293
+ // have the right to have it removed. A file that only ever adds to memory is where that right usually gets lost.
294
+ rule({ id: "privacy.memory-no-delete", title: "Agent memory that is written but never deleted", status: "partial", severity: "low", controls: [GDPR("Art. 17", "Right to erasure"), GDPR("Art. 5(1)(e)", "Storage limitation")],
295
+ fix: "Give users a way to see and delete what the agent remembers about them, and set how long memories are kept. Most memory libraries have a delete call per user: wire it to account deletion.",
296
+ note: "Memories are built from what people say, so they hold names, contacts, health and other personal details. Kept for good with no delete path, they can't be removed when a user asks or leaves (GDPR Art. 17).",
297
+ unseen: "Lintsure looked in this file only. A delete call may live in another file, or the memory service may expire entries by itself.",
298
+ extensions: CODE,
299
+ fileTest: (lines) => {
300
+ const text = lines.join("\n");
301
+ if (!/\b(mem0|mem0ai|zep_cloud|zep_python|langmem|letta)\b|@mem0\/|@getzep\//.test(text) || /\.(delete|delete_all|delete_memory|delete_user|forget|reset)\s*\(|\bttl\b|expir/i.test(text))
302
+ return [];
303
+ // The call must be on the memory object or name whose memory it is: `updated_keys.add(x)` is a set (field check).
304
+ const i = lines.findIndex((l) => /\b\w*(mem|zep|letta)\w*(\.\w+)*\.(add|add_memory|aadd)\s*\(|\.save_context\s*\(|\.(add|aadd)\s*\([^)]*\b(user_?id|session_?id|agent_?id)\b/i.test(l) && !/^\s*(\/\/|#)/.test(l));
305
+ return i < 0 ? [] : [i + 1];
306
+ } }),
254
307
  rule({ id: "docker.secret-in-build", title: "Secret given a value in a Dockerfile", status: "gap", severity: "high", controls: [A02, A08],
255
308
  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.",
256
309
  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).",
257
310
  extensions: [""], fileName: DOCKERFILE, test: (l) => BUILD_SECRET.test(l) }),
258
- rule({ id: "mcp.config-unsafe-server", title: "MCP server run from a moving version or over plain HTTP", status: "partial", severity: "medium", controls: [LLM04, A08],
311
+ rule({ id: "mcp.config-unsafe-server", title: "MCP server run from a moving version or over plain HTTP", status: "partial", severity: "medium", controls: [LLM04, A08, AST("02", "Supply Chain Compromise"), AST("07", "Update Drift")],
259
312
  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.",
260
313
  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).",
261
314
  extensions: [".json"], pathMatch: AGENT_CONFIG,
@@ -270,12 +323,40 @@ export const moreRules = [
270
323
  // A scanner that lists these phrases to catch them is not an attack: lines that build a pattern or name an attempt are
271
324
  // skipped, and in a JSON manifest only "description" values are read (field test: 6 of 6 new findings were detectors).
272
325
  fileTest: (lines) => {
273
- const code = lines.some((l) => MCP_TOOL.test(l));
326
+ // A JSON file is data: only its "description" values are read, even when it quotes code that registers a tool.
327
+ const code = !/^\s*[\[{]/.test(lines.find((l) => l.trim()) ?? "") && lines.some((l) => MCP_TOOL.test(l));
274
328
  if (!code && !lines.some((l) => /"inputSchema"\s*:/.test(l)))
275
329
  return [];
276
330
  return lines.flatMap((l, i) => (poisonedDescription(l) && !/^\s*(\/\/|#)/.test(l) && (code || /"description"\s*:/.test(l))
277
331
  && !/re\.compile\(|new RegExp\(|\(\?i\)|\b(attempt|detect\w*|patterns?|injection)\b/i.test(l) ? [i + 1] : []));
278
332
  } }),
333
+ // Skills are prose an agent follows. These three read a skill the way a reviewer would: where its next instructions
334
+ // come from, whether it rewrites the agent's own standing instructions, and how much of the machine it asks for.
335
+ rule({ id: "skill.fetches-remote-instructions", title: "Skill tells the agent to follow a page on the internet", status: "partial", severity: "medium", controls: [AST("05", "Untrusted External Instructions"), LLM01],
336
+ fix: "Put the steps in the skill itself, or keep a reviewed copy in the repo and point to that. If the page must be fetched, tell the agent to treat it as reference text and to ask before acting on it.",
337
+ note: "The skill was reviewed once, but the page can change at any time, and whoever controls it then decides what the agent does with your permissions (CWE-829).",
338
+ extensions: [".md", ".mdc"], pathMatch: SKILL_FILE,
339
+ unseen: "Lintsure can't see what the page says today or who controls it, and it can't tell reference reading from instructions the agent will act on.",
340
+ test: followsRemote }),
341
+ rule({ id: "skill.writes-agent-memory", title: "Skill changes the agent's own instructions or settings", status: "partial", severity: "medium", controls: [AST("01", "Malicious Skills"), AST("03", "Over-Privileged Skills")],
342
+ fix: "Have the skill show the change and ask the user before writing to these files. If writing them is not the skill's stated job, remove the line.",
343
+ note: "AGENTS.md, CLAUDE.md, memory files and agent settings are read at the start of every later session. A skill that writes to them keeps its influence after it has finished, and can loosen limits for everything that follows.",
344
+ extensions: [".md", ".mdc"], pathMatch: SKILL_FILE,
345
+ unseen: "Lintsure can't tell a skill whose stated job is to manage these files, with the user's agreement, from one that changes them on the quiet.",
346
+ test: writesMemory }),
347
+ rule({ id: "skill.unrestricted-shell", title: "Skill is allowed any shell command", status: "partial", severity: "low", controls: [AST("03", "Over-Privileged Skills"), LLM03],
348
+ fix: "List the commands the skill needs, for example `Bash(npm run test:*)`, and leave the rest to the agent's normal permission prompts.",
349
+ note: "With the whole shell allowed, the skill's other limits mean little: any file can be read or changed and anything can be sent out through a command. One poisoned input to the skill then reaches the whole machine.",
350
+ extensions: [".md", ".mdc"], pathMatch: SKILL_FILE,
351
+ unlessPath: /(^|\/)evals?\//, // an eval's own settings file sits in the skill folder and is not a skill
352
+ // shortcut: reads allowed-tools on one line; a YAML list spread over several lines is not read. Upgrade when one is seen in the field.
353
+ unseen: "Lintsure can't see the agent's own settings, which may still ask before each command.",
354
+ test: (l) => OPEN_SHELL.test(l) }),
355
+ rule({ id: "mcp.server-binds-all-interfaces", title: "MCP server listens on every network interface", status: "partial", severity: "medium", controls: [AST("06", "Weak Isolation"), A02],
356
+ fix: "Listen on 127.0.0.1 unless other machines must reach the server. If they must, require sign-in on every request and put it behind a firewall.",
357
+ note: "An agent's tool server usually runs on a developer's machine. On 0.0.0.0, anyone on the same network can call its tools, which often read files and run commands (CWE-1327).", extensions: CODE,
358
+ unseen: "Lintsure can't see a firewall, a container network or sign-in in front of this server.",
359
+ fileTest: (lines) => inMcpServer(lines, ALL_INTERFACES) }),
279
360
  rule({ id: "mcp.tool-runs-shell", title: "MCP tool that runs shell commands", status: "partial", severity: "high", controls: [LLM03, A06],
280
361
  fix: "Run a fixed program with execFile and an argument list, never a command string. Check every argument against an allow-list, and ask the user before anything that changes files or systems.",
281
362
  note: "The agent decides what to pass to this tool, and anything it reads (a web page, an issue, a file) can steer it. If tool input reaches the command, a prompt injection becomes a shell on this machine (CWE-78).", extensions: CODE,
@@ -1,10 +1,17 @@
1
1
  import type { Control, Rule } from "../types.js";
2
2
  export declare const AGENT_CONFIG: RegExp;
3
+ export declare const AGENT_DIRS: string;
4
+ export declare const AGENT_INSTRUCTIONS: RegExp;
3
5
  /** True when a line carries text hidden from a human reader. Pure. */
4
6
  export declare const hiddenText: (l: string) => boolean;
5
7
  export declare const poisonedDescription: (l: string) => boolean;
8
+ /** A YAML permissions file whose allow list names the whole shell or every tool (Continue's permissions.yaml). Only items
9
+ * under "allow:" count: the same entry under "ask:" or "exclude:" is a limit. Returns line numbers. Pure. */
10
+ export declare function yamlAllowsAll(lines: string[]): number[];
6
11
  /** Agent instruction line: Gap for override, concealment, hidden text or sending secrets out; Partial for download-and-run. Pure. */
7
12
  export declare function instructionsUnsafe(l: string): boolean | "partial";
13
+ /** A risk in the OWASP list for agent skills. Ids and names only. */
14
+ export declare const AST: (n: string, title: string) => Control;
8
15
  /** True when a signing or encryption secret falls back to a fixed value written in the code. Pure. */
9
16
  export declare function fallbackSecret(l: string): boolean;
10
17
  export declare const owaspRules: Rule[];
@@ -1,8 +1,9 @@
1
1
  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
- // Files whose commands an agent or editor runs by itself: Claude Code settings, MCP server lists, Cursor, VS Code, Gemini CLI.
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)$/;
4
+ // Files whose commands an agent or editor runs by itself: settings, MCP server lists and hook files for Claude Code, Cursor,
5
+ // VS Code, Gemini CLI, Codex, Copilot, Zed, OpenCode and others. Any mcp.json counts, wherever the agent keeps it.
6
+ 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(\.windows)?)\.json|\.codex\/hooks\.json|\.mastracode\/hooks\.json|\.github\/hooks\/[^/]+\.json|\.zed\/settings\.json|opencode\.json|\.vscode\/(tasks|mcp)\.json|\.gemini\/settings\.json)$/;
6
7
  // Download-and-run shapes: piped into a shell, run from $( ), process substitution, base64 into a shell, encoded PowerShell,
7
8
  // and download-then-execute chains.
8
9
  const RUNS_REMOTE = new RegExp([
@@ -14,7 +15,14 @@ const RUNS_REMOTE = new RegExp([
14
15
  String.raw `\b(curl|wget)\b[^;&|]*(&&|;)\s*(chmod\s+\+x|\.\/|sh\s|bash\s)`,
15
16
  ].join("|"), "i");
16
17
  // Files an agent reads as its own instructions.
17
- const AGENT_INSTRUCTIONS = /(^|\/)(SKILL\.md|AGENTS\.md|CLAUDE\.md|GEMINI\.md|\.cursorrules|\.windsurfrules|copilot-instructions\.md)$|(^|\/)\.cursor\/rules\/[^/]+\.mdc?$|(^|\/)\.(claude|agents|codex|gemini)\/(skills|commands|agents)\/.+\.md$/i;
18
+ // The folder each agent keeps its own files in: .claude, .agents, .cursor, .kiro, .continue, .github (Copilot) and the rest.
19
+ export const AGENT_DIRS = String.raw `\.(claude|agents?|codex|gemini|cursor|continue|kiro|kilocode|factory|codebuddy|opencode|pi|hermes|mastracode|openclaw|adal|autohand|roo|windsurf|cline|junie|rovodev|github)`;
20
+ export const AGENT_INSTRUCTIONS = new RegExp([
21
+ String.raw `(^|\/)(SKILL\.md|AGENTS\.md|CLAUDE\.md|GEMINI\.md|\.cursorrules|\.windsurfrules|\.clinerules|copilot-instructions\.md)$`,
22
+ String.raw `(^|\/)\.cursor\/rules\/[^/]+\.mdc?$`,
23
+ String.raw `(^|\/)\.clinerules\/[^/]+\.md$|(^|\/)\.junie\/guidelines\.md$`,
24
+ String.raw `(^|\/)${AGENT_DIRS}\/(skills|commands|agents|rules|steering|prompts|instructions)\/.+\.md$`,
25
+ ].join("|"), "i");
18
26
  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
27
  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
28
  // A line that says a download-and-run is blocked or forbidden describes a guard, it doesn't ask for one.
@@ -36,6 +44,21 @@ const MODEL_TAG = { test: (l) => /<\s*\/?\s*(important|system)\s*>|<\|(im_start|
36
44
  // .env is left out: a dotenv tool honestly says it reads the .env file.
37
45
  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
46
  export const poisonedDescription = (l) => hiddenText(l) || OVERRIDE.test(l) || CONCEAL.test(l) || MODEL_TAG.test(l) || KEY_FILE_ORDER.test(l);
47
+ const ALLOWS_ALL = /^\s*-\s*["']?(Bash|Bash\(\*\)|\*)["']?\s*(#.*)?$/;
48
+ /** A YAML permissions file whose allow list names the whole shell or every tool (Continue's permissions.yaml). Only items
49
+ * under "allow:" count: the same entry under "ask:" or "exclude:" is a limit. Returns line numbers. Pure. */
50
+ export function yamlAllowsAll(lines) {
51
+ const out = [];
52
+ let section = "";
53
+ lines.forEach((l, i) => {
54
+ const top = /^(\w+):/.exec(l);
55
+ if (top)
56
+ section = top[1];
57
+ else if (section === "allow" && ALLOWS_ALL.test(l))
58
+ out.push(i + 1);
59
+ });
60
+ return out;
61
+ }
39
62
  /** Agent instruction line: Gap for override, concealment, hidden text or sending secrets out; Partial for download-and-run. Pure. */
40
63
  export function instructionsUnsafe(l) {
41
64
  if (hiddenText(l))
@@ -50,6 +73,9 @@ export function instructionsUnsafe(l) {
50
73
  }
51
74
  const DRAFT = { mappedBy: "beta", reviewedAt: "pending" };
52
75
  const LLM01 = { framework: "owasp-llm", id: "LLM01:2026", title: "Prompt Injection" }, LLM03 = { framework: "owasp-llm", id: "LLM03:2026", title: "Excessive Agency" };
76
+ /** A risk in the OWASP list for agent skills. Ids and names only. */
77
+ export const AST = (n, title) => ({ framework: "owasp-ast", id: `AST${n}`, title });
78
+ const AST01 = AST("01", "Malicious Skills"), AST02 = AST("02", "Supply Chain Compromise"), AST03 = AST("03", "Over-Privileged Skills"), AST04 = AST("04", "Insecure Metadata");
53
79
  const A = (n, title) => ({ framework: "owasp-top10", id: `A${n}:2025`, title });
54
80
  const A01 = A("01", "Broken Access Control"), A02 = A("02", "Security Misconfiguration"), A03 = A("03", "Software Supply Chain Failures"), A04 = A("04", "Cryptographic Failures"), A05 = A("05", "Injection"), A06 = A("06", "Insecure Design"), A07 = A("07", "Authentication Failures"), A08 = A("08", "Software or Data Integrity Failures"), A09 = A("09", "Security Logging and Alerting Failures"), A10 = A("10", "Mishandling of Exceptional Conditions");
55
81
  // Request data on the same line. Without it a match is Partial: the value may be safe text from your own code.
@@ -167,7 +193,7 @@ export const owaspRules = [
167
193
  test: (l) => /"(pre|post)?install"\s*:\s*"[^"]*\b(curl|wget|Invoke-WebRequest)\b/.test(l) }),
168
194
  // Agent settings that run commands on their own (Claude Code hooks, MCP servers, editor tasks). An attacker who can
169
195
  // edit one of these files gets code run on every developer machine that opens the repo with that agent.
170
- rule({ id: "agent.config-runs-remote-code", title: "Agent config downloads and runs code", status: "gap", severity: "high", controls: [A03],
196
+ rule({ id: "agent.config-runs-remote-code", title: "Agent config downloads and runs code", status: "gap", severity: "high", controls: [A03, AST02],
171
197
  fix: "Don't download and run scripts from agent hooks, MCP server commands or editor tasks. Pin a reviewed local script or a versioned package instead, and review changes to these files like code.",
172
198
  note: "Agents run these commands on their own, often at startup, with your user's permissions. A changed URL or script runs on every machine that opens the repo (CWE-829, CWE-494).",
173
199
  extensions: [".json"], pathMatch: AGENT_CONFIG,
@@ -176,7 +202,7 @@ export const owaspRules = [
176
202
  // Instruction files are now code an agent follows: skills, AGENTS.md, CLAUDE.md, Cursor and Copilot rules. A line that
177
203
  // tells the agent to drop earlier instructions, hide something from the user, send secrets out, or download and run a
178
204
  // script is acted on the next time any agent opens the repo (skill collections spread these widely).
179
- rule({ id: "agent.instructions-unsafe", title: "Agent instructions that override, hide or download and run", status: "gap", severity: "high", controls: [A03, LLM01],
205
+ rule({ id: "agent.instructions-unsafe", title: "Agent instructions that override, hide or download and run", status: "gap", severity: "high", controls: [A03, LLM01, AST01, AST04],
180
206
  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.",
181
207
  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).",
182
208
  extensions: [".md", ".mdc", ""], pathMatch: AGENT_INSTRUCTIONS,
@@ -184,10 +210,10 @@ export const owaspRules = [
184
210
  test: instructionsUnsafe }),
185
211
  // A project file that switches off the agent's own permission prompts: every agent that opens the repo then runs any
186
212
  // command or edit without asking (Continue's headless default allows every tool, field study 2026-11).
187
- rule({ id: "agent.permissions-allow-all", title: "Agent settings that skip every permission prompt", status: "gap", severity: "high", controls: [A02, LLM03],
213
+ rule({ id: "agent.permissions-allow-all", title: "Agent settings that skip every permission prompt", status: "gap", severity: "high", controls: [A02, LLM03, AST03],
188
214
  fix: "Remove the bypass from the shared project file. Allow the few commands you trust by name (for example Bash(npm test)), and keep wider permissions in your own local settings, not in the repo.",
189
215
  note: "Committed agent settings apply to everyone who opens the repo with that agent. Skipping prompts or allowing every shell command lets a bad instruction, a poisoned file or a mistake run without a person seeing it (CWE-250, OWASP LLM03 Excessive Agency).",
190
- extensions: [".json", ".toml"], pathMatch: /(^|\/)(\.claude\/settings\.json|\.gemini\/settings\.json|\.codex\/config\.toml|\.continue\/(config|permissions)\.ya?ml|\.vscode\/settings\.json)$/,
216
+ extensions: [".json", ".toml", ".yaml", ".yml"], fileTest: yamlAllowsAll, pathMatch: /(^|\/)(\.claude\/settings\.json|\.gemini\/settings\.json|\.codex\/config\.toml|\.continue\/(config|permissions)\.ya?ml|\.vscode\/settings\.json)$/,
191
217
  test: (l) => /"defaultMode"\s*:\s*"bypassPermissions"|(?:^|[[,])\s*"(Bash|Bash\(\*\)|Bash\(:\*\)|\*)"\s*(?:[,\]]|$)|--dangerously-skip-permissions|"(yolo|autoAccept)"\s*:\s*true|\bapproval_policy\s*=\s*["']never["']|\bsandbox_mode\s*=\s*["']danger-full-access["']|"chat\.tools\.autoApprove"\s*:\s*true/.test(l) }),
192
218
  rule({ id: "ci.action-unpinned", title: "Third-party GitHub Action not pinned to a commit", status: "partial", severity: "medium", controls: [A03],
193
219
  fix: "Pin third-party actions to a full commit SHA, with the version as a comment, for example uses: owner/action@<40-character sha> # v2.",
@@ -44,6 +44,15 @@ export const standardsRules = [
44
44
  // Not user text in the instructions: `system: undefined` next to a prompt, and a helper that picks a fixed system
45
45
  // message from its arguments, getSystemMessage(input.locale) (0.3.14 review: 3 of 3 shown findings).
46
46
  && !/\bsystem\s*:\s*(undefined|null)\b/.test(l) && USER_TEXT.test(l.replace(/\bget\w*System\w*\([^()]*\)/g, "fixed")) }),
47
+ // The same risk from the other side: a page, a document or a stored memory can carry instructions too, and text placed
48
+ // in the system prompt is obeyed as the app's own (indirect prompt injection). Common in retrieval apps.
49
+ rule({ id: "llm.retrieved-text-in-system-prompt", title: "Retrieved or stored text placed inside the AI's system instructions", status: "partial", severity: "medium", controls: [LLM01],
50
+ fix: "Keep the system prompt fixed. Pass retrieved documents, search results and memories as a separate message, marked as reference material, and tell the model not to follow instructions found in them.",
51
+ note: "A web page, an uploaded file or a saved memory can contain a line written for the model. In the system prompt it carries the app's authority, so whoever wrote that text can steer the AI (OWASP LLM01). Marked Partial: the source may be one only your team writes.",
52
+ unseen: "Lintsure can't see where the text comes from. Content your own team writes is a smaller risk than pages, uploads or anything users can add to.",
53
+ extensions: CODE,
54
+ test: (l) => /\b(role\s*:\s*["']system["']|system(Prompt|_prompt|Message|_message|Instruction)?\s*[:=]|["']system["']\s*,)/.test(l)
55
+ && /\$\{[^}]*\b(context|docs|documents|chunks|retrieved\w*|searchResults|search_results|memories|pageContent|page_content|webpage|scraped\w*|fileContents?)\b[^}]*\}|\{(context|documents|docs|chunks|retrieved_\w+|search_results|memories)\}/.test(l) }),
47
56
  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],
48
57
  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.",
49
58
  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.",
@@ -1,7 +1,7 @@
1
1
  export type Status = "met" | "partial" | "gap" | "outside";
2
2
  export type Severity = "high" | "medium" | "low";
3
3
  /** Built-in frameworks. Rule packs can add more, so FrameworkId is open to other strings. */
4
- export type BuiltinFrameworkId = "gdpr" | "eu-ai-act" | "owasp-top10" | "cra" | "owasp-llm" | "cwe-top25";
4
+ export type BuiltinFrameworkId = "gdpr" | "eu-ai-act" | "owasp-top10" | "cra" | "owasp-llm" | "cwe-top25" | "owasp-ast" | "owasp-api";
5
5
  export type FrameworkId = BuiltinFrameworkId | (string & {});
6
6
  export interface Control {
7
7
  framework: FrameworkId;
@@ -114,6 +114,12 @@ export interface Finding {
114
114
  change?: "new" | "unchanged";
115
115
  /** Set when a person accepted this finding in .lintsure/accepted.yaml. */
116
116
  accepted?: Acceptance;
117
+ /** Set when a reviewer read the code and recorded this finding as real in .lintsure/confirmed.yaml. */
118
+ confirmed?: {
119
+ by: string;
120
+ date: string;
121
+ note?: string;
122
+ };
117
123
  }
118
124
  /** A person's decision to accept a finding, with their reason. Expired acceptances count as open again. */
119
125
  export interface Acceptance {
@@ -0,0 +1,20 @@
1
+ export interface Verify {
2
+ /** All of these should hold before a finding is called real. */
3
+ real: string[];
4
+ /** Any one of these makes it not a problem, if you can point to the evidence. */
5
+ notReal: string[];
6
+ }
7
+ /** The review lists for a rule: its own, or the ones for its kind. Never empty. Pure. */
8
+ export declare function verifyFor(ruleId: string): Verify;
9
+ /** Ids that have their own list, for the test that checks each one names a real rule. */
10
+ export declare const VERIFY_IDS: string[];
11
+ /** Links to a public catalogue that shows the same weakness in other standards, one per CWE number the rule names
12
+ * in its controls or its note. Links only: nothing is fetched. Pure. */
13
+ export declare function crossStandardLinks(rule: {
14
+ controls: {
15
+ id: string;
16
+ }[];
17
+ note: string;
18
+ }): string[];
19
+ /** The lists as text an agent or a person can work through. Pure. */
20
+ export declare function verifyText(ruleId: string): string;