@lintsure/core 0.3.15 → 0.3.17
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/assessment.js +76 -76
- package/dist/src/guidance.d.ts +1 -1
- package/dist/src/guidance.js +36 -3
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.js +43 -13
- package/dist/src/knowledge/gdpr.js +1 -1
- package/dist/src/knowledge/index.js +2 -2
- package/dist/src/knowledge/more.d.ts +2 -0
- package/dist/src/knowledge/more.js +88 -2
- package/dist/src/knowledge/owasp-top10.js +1 -1
- package/dist/src/review.d.ts +10 -0
- package/dist/src/review.js +25 -0
- package/dist/src/rules/api.d.ts +10 -0
- package/dist/src/rules/api.js +43 -0
- package/dist/src/rules/index.js +9 -0
- package/dist/src/rules/more.d.ts +4 -0
- package/dist/src/rules/more.js +84 -3
- package/dist/src/rules/owasp.d.ts +13 -0
- package/dist/src/rules/owasp.js +117 -7
- package/dist/src/rules/standards.js +9 -0
- package/dist/src/types.d.ts +7 -1
- package/dist/src/verify.d.ts +20 -0
- package/dist/src/verify.js +120 -0
- package/docs/README.md +1 -1
- package/docs/agents.md +34 -1
- package/docs/frameworks.md +41 -5
- package/docs/rules.md +431 -32
- package/package.json +42 -42
|
@@ -10,13 +10,13 @@ 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"],
|
|
17
17
|
plain: "Keys, personal data and internal details must not reach the model, its logs or its answers unless they're meant to.",
|
|
18
18
|
evidence: "What data is sent to the model provider, and the provider's data retention terms." },
|
|
19
|
-
{ ref: "LLM03:2026", title: "Excessive Agency", inCode: "partly", rules: ["agent.permissions-allow-all", "mcp.tool-runs-shell", "mcp.tool-uses-secret"],
|
|
19
|
+
{ ref: "LLM03:2026", title: "Excessive Agency", inCode: "partly", rules: ["agent.permissions-allow-all", "agent.approval-author-alone", "agent.approval-rule-files-open", "mcp.tool-runs-shell", "mcp.tool-uses-secret"],
|
|
20
20
|
plain: "Tools and permissions given to an agent should be the minimum it needs, with a person approving anything risky.",
|
|
21
21
|
evidence: "A list of the tools each agent can call and which need approval." },
|
|
22
22
|
{ ref: "LLM04:2026", title: "Supply Chain", inCode: "partly", rules: ["deps.unpinned-version", "deps.install-script", "agent.config-runs-remote-code", "ml.unsafe-model-load", "mcp.config-unsafe-server"],
|
|
@@ -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", "agent.approval-author-alone", "agent.approval-rule-files-open", "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", "agent.approval-author-alone", "agent.approval-rule-files-open", "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",
|
package/dist/src/review.d.ts
CHANGED
|
@@ -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. */
|
package/dist/src/review.js
CHANGED
|
@@ -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
|
+
];
|
package/dist/src/rules/index.js
CHANGED
|
@@ -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.
|
package/dist/src/rules/more.d.ts
CHANGED
|
@@ -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<{
|
package/dist/src/rules/more.js
CHANGED
|
@@ -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
|
-
|
|
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,23 @@
|
|
|
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[];
|
|
11
|
+
export declare const APPROVALS_FILE: RegExp;
|
|
12
|
+
/** Lines of an approval policy where a change needs nobody but its author. Pure. */
|
|
13
|
+
export declare function approvalByAuthorAlone(lines: string[]): number[];
|
|
14
|
+
/** The "rules:" line of a policy that has an easy path (the author alone, or Claude approving) and no stricter rule that
|
|
15
|
+
* names the files steering agents and reviews. The strictest matching rule wins, so one such rule is what covers them. Pure. */
|
|
16
|
+
export declare function ruleFilesShareAnApprover(lines: string[]): number[];
|
|
6
17
|
/** Agent instruction line: Gap for override, concealment, hidden text or sending secrets out; Partial for download-and-run. Pure. */
|
|
7
18
|
export declare function instructionsUnsafe(l: string): boolean | "partial";
|
|
19
|
+
/** A risk in the OWASP list for agent skills. Ids and names only. */
|
|
20
|
+
export declare const AST: (n: string, title: string) => Control;
|
|
8
21
|
/** True when a signing or encryption secret falls back to a fixed value written in the code. Pure. */
|
|
9
22
|
export declare function fallbackSecret(l: string): boolean;
|
|
10
23
|
export declare const owaspRules: Rule[];
|