xploitscan-shared-rules 1.14.0 → 1.14.2
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/README.md +2 -2
- package/dist/index.cjs +52 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +51 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Shared XploitScan rule definitions, helpers, compliance mappings, the AI false-positive filter, and the entropy-based secret scanner.
|
|
4
4
|
|
|
5
|
-
This package is the source of truth for XploitScan's detection logic. It's consumed by the [XploitScan CLI](https://www.npmjs.com/package/xploitscan), the [XploitScan MCP server](https://www.npmjs.com/package/xploitscan-mcp), the web scan API at [xploitscan.com](https://xploitscan.com), and the [XploitScan GitHub Action](https://github.com/marketplace/actions/xploitscan-security-scanner) — so detection behavior can't drift between surfaces.
|
|
5
|
+
This package is the source of truth for XploitScan's detection logic. It's consumed by the [XploitScan CLI](https://www.npmjs.com/package/xploitscan), the [XploitScan MCP server](https://www.npmjs.com/package/xploitscan-mcp), the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=XploitScan.xploitscan-vscode), the web scan API at [xploitscan.com](https://xploitscan.com), and the [XploitScan GitHub Action](https://github.com/marketplace/actions/xploitscan-security-scanner) — so detection behavior can't drift between surfaces.
|
|
6
6
|
|
|
7
7
|
## What's in here
|
|
8
8
|
|
|
9
|
-
- **210 security rules** — pattern + AST-based detection for hardcoded secrets, SQL injection, XSS, SSRF, prototype pollution, crypto misuse, deserialization, JWT alg confusion, and more.
|
|
9
|
+
- **210+ security rules** — pattern + AST-based detection for hardcoded secrets, SQL injection, XSS, SSRF, prototype pollution, crypto misuse, deserialization, JWT alg confusion, and more.
|
|
10
10
|
- **Compliance mappings** — each rule tagged with the SOC2, ISO 27001, and OWASP Top 10 controls it covers.
|
|
11
11
|
- **AI false-positive filter** — optional Claude Haiku integration that re-evaluates findings to suppress benign matches before reporting.
|
|
12
12
|
- **Entropy-based secret scanner** — detects high-entropy strings that look like credentials but don't match a known service-key pattern.
|
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
dangerousInnerHTML: () => dangerousInnerHTML,
|
|
53
53
|
deprecatedTLS: () => deprecatedTLS,
|
|
54
54
|
detectFramework: () => detectFramework,
|
|
55
|
+
detectPlatform: () => detectPlatform,
|
|
55
56
|
disabledTLSVerification: () => disabledTLSVerification,
|
|
56
57
|
djangoDebug: () => djangoDebug,
|
|
57
58
|
dockerCopySensitive: () => dockerCopySensitive,
|
|
@@ -1325,8 +1326,8 @@ var hardcodedSecrets = {
|
|
|
1325
1326
|
if (valMatch && nameMatch) {
|
|
1326
1327
|
const value = valMatch[1];
|
|
1327
1328
|
const isKeySuffix = nameMatch[1].endsWith("_KEY");
|
|
1328
|
-
const
|
|
1329
|
-
if (isKeySuffix &&
|
|
1329
|
+
const isSlotIdentifier = value.length < 40 && /^[a-z0-9]+([_-][a-z0-9]+)+$/.test(value);
|
|
1330
|
+
if (isKeySuffix && isSlotIdentifier) continue;
|
|
1330
1331
|
}
|
|
1331
1332
|
}
|
|
1332
1333
|
matches.push(rm);
|
|
@@ -4134,6 +4135,31 @@ function detectFramework(files) {
|
|
|
4134
4135
|
if (frameworks.size === 0) frameworks.add("unknown");
|
|
4135
4136
|
return [...frameworks];
|
|
4136
4137
|
}
|
|
4138
|
+
function detectPlatform(files) {
|
|
4139
|
+
const platforms = /* @__PURE__ */ new Set();
|
|
4140
|
+
for (const { path, content } of files) {
|
|
4141
|
+
const p = path.toLowerCase();
|
|
4142
|
+
if (/(^|\/)lovable\.config\./.test(p) || /lovable-tagger/i.test(content) || /lovable\.dev/i.test(content)) {
|
|
4143
|
+
platforms.add("lovable");
|
|
4144
|
+
}
|
|
4145
|
+
if (/(^|\/)\.bolt\//.test(p) || /(^|\/)\.stackblitzrc$/.test(p) || /bolt\.new/i.test(content)) {
|
|
4146
|
+
platforms.add("bolt");
|
|
4147
|
+
}
|
|
4148
|
+
if (/(^|\/)\.replit$/.test(p) || /(^|\/)replit\.nix$/.test(p)) {
|
|
4149
|
+
platforms.add("replit");
|
|
4150
|
+
}
|
|
4151
|
+
if (/(^|\/)\.cursorrules$/.test(p) || /(^|\/)\.cursor\//.test(p)) {
|
|
4152
|
+
platforms.add("cursor");
|
|
4153
|
+
}
|
|
4154
|
+
if (/(^|\/)claude\.md$/.test(p) || /(^|\/)\.claude\//.test(p)) {
|
|
4155
|
+
platforms.add("claude-code");
|
|
4156
|
+
}
|
|
4157
|
+
if (/v0\.dev/i.test(content) || /generated by v0\b/i.test(content)) {
|
|
4158
|
+
platforms.add("v0");
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
return [...platforms];
|
|
4162
|
+
}
|
|
4137
4163
|
function calculateGrade(findings, _totalFiles) {
|
|
4138
4164
|
if (findings.length === 0) {
|
|
4139
4165
|
return { grade: "A+", score: 100, summary: "No security issues detected. Excellent." };
|
|
@@ -8425,14 +8451,16 @@ var insecureDirectObjectReference = {
|
|
|
8425
8451
|
check(content, filePath) {
|
|
8426
8452
|
if (!filePath.match(/\.(js|ts|jsx|tsx)$/)) return [];
|
|
8427
8453
|
if (isTestFile(filePath)) return [];
|
|
8428
|
-
if (!/\/api\//i.test(filePath)) return [];
|
|
8429
|
-
if (!/export\s+(?:async\s+)?function\s+(?:GET|PUT|PATCH|DELETE)/i.test(content)) return [];
|
|
8430
|
-
if (!/params\.id|params\.(?:slug|uuid)|req\.params\./i.test(content)) return [];
|
|
8431
|
-
if (!/findUnique|findFirst|findById|\.findOne|WHERE.*=.*params|\.get\(.*params/i.test(content)) return [];
|
|
8432
|
-
if (/userId|ownerId|createdBy|user_id|owner_id|AND.*user|where.*user|authorize|canAccess|checkPermission|isOwner|belongsTo/i.test(content)) return [];
|
|
8433
8454
|
if (/admin/i.test(filePath)) return [];
|
|
8434
|
-
if (/
|
|
8435
|
-
|
|
8455
|
+
if (/userId|ownerId|createdBy|user_id|owner_id|AND.*user|where.*user|authorize|canAccess|checkPermission|isOwner|belongsTo/i.test(content)) return [];
|
|
8456
|
+
if (/requireUser|requireUserForApi|requireAuth|withAuth|getServerSession|auth\(\)|req\.user\b|passport|session\.user|isAuthenticated/i.test(content)) return [];
|
|
8457
|
+
if (!/findUnique|findFirst|findById|\.findOne|WHERE.*=.*(?:params|req\.(?:body|query))|\.get\(.*(?:params|req\.(?:body|query))/i.test(content)) return [];
|
|
8458
|
+
const isNextApiIdor = /\/api\//i.test(filePath) && /export\s+(?:async\s+)?function\s+(?:GET|PUT|PATCH|DELETE)/i.test(content) && /params\.id|params\.(?:slug|uuid)|req\.params\./i.test(content);
|
|
8459
|
+
const hasExpressHandler = /\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]*["'`]\s*,/i.test(content);
|
|
8460
|
+
const readsObjectRef = /req\.params\b|req\.(?:body|query)\.\w*id\b/i.test(content);
|
|
8461
|
+
const isExpressIdor = hasExpressHandler && readsObjectRef;
|
|
8462
|
+
if (!isNextApiIdor && !isExpressIdor) return [];
|
|
8463
|
+
const m = content.match(/params\.id|params\.(?:slug|uuid)|req\.params\.\w+|req\.params\b|req\.(?:body|query)\.\w*id/i);
|
|
8436
8464
|
if (!m || m.index === void 0) return [];
|
|
8437
8465
|
const lineNum = lineNumberAt(content, m.index);
|
|
8438
8466
|
return [{
|
|
@@ -8443,7 +8471,7 @@ var insecureDirectObjectReference = {
|
|
|
8443
8471
|
file: filePath,
|
|
8444
8472
|
line: lineNum,
|
|
8445
8473
|
snippet: getSnippet(content, lineNum),
|
|
8446
|
-
fix: "Add an ownership check: verify the requesting user owns the record before returning it. Example: WHERE id = params.id AND userId =
|
|
8474
|
+
fix: "Add an ownership check: verify the requesting user owns the record before returning it. Example: WHERE id = req.params.id AND userId = req.user.id"
|
|
8447
8475
|
}];
|
|
8448
8476
|
}
|
|
8449
8477
|
};
|
|
@@ -8794,6 +8822,7 @@ Common false positive patterns you should catch:
|
|
|
8794
8822
|
- The comparison is a type check (typeof x === "string") not a secret comparison
|
|
8795
8823
|
- The file is a test, mock, or fixture file
|
|
8796
8824
|
- The "secret" is a publishable/public key (pk_test_, NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY) designed to be client-side
|
|
8825
|
+
- The value is a slot/name identifier, not a credential: a SCREAMING_CASE *_KEY constant assigned a short lowercase word string (e.g. INDEX_KEY = "mc_saves_index", CACHE_KEY = "user-prefs-v2") is a localStorage/cookie/cache key NAME, not a secret. Real secrets are high-entropy and mixed-case (sk_live_aBcD\u2026), not dictionary words joined by - or _
|
|
8797
8826
|
- The innerHTML/dangerouslySetInnerHTML uses a static constant or JSON.stringify, not user input
|
|
8798
8827
|
- The redirect URL has already been validated (isAllowedRedirect, validateRedirect)
|
|
8799
8828
|
- The webhook endpoint is for a non-Stripe service but flagged as "Stripe webhook"
|
|
@@ -8887,6 +8916,8 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8887
8916
|
return empty;
|
|
8888
8917
|
}
|
|
8889
8918
|
const fpMap = /* @__PURE__ */ new Map();
|
|
8919
|
+
let reviewedAny = false;
|
|
8920
|
+
let firstError = null;
|
|
8890
8921
|
for (const [file, fileFindings] of byFile) {
|
|
8891
8922
|
const content = fileContents.get(file);
|
|
8892
8923
|
if (!content) continue;
|
|
@@ -8902,6 +8933,7 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8902
8933
|
});
|
|
8903
8934
|
const text = response.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
8904
8935
|
const results = parseReviewResponse(text);
|
|
8936
|
+
reviewedAny = true;
|
|
8905
8937
|
for (const r of results) {
|
|
8906
8938
|
if (r.verdict === "fp" && r.index >= 0 && r.index < batch.length) {
|
|
8907
8939
|
const globalIndex = toReview.indexOf(batch[r.index]);
|
|
@@ -8910,11 +8942,18 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8910
8942
|
}
|
|
8911
8943
|
}
|
|
8912
8944
|
}
|
|
8913
|
-
} catch {
|
|
8945
|
+
} catch (err) {
|
|
8946
|
+
if (!firstError) firstError = err;
|
|
8914
8947
|
continue;
|
|
8915
8948
|
}
|
|
8916
8949
|
}
|
|
8917
8950
|
}
|
|
8951
|
+
if (!reviewedAny && firstError) {
|
|
8952
|
+
console.error(
|
|
8953
|
+
"[ai-fp-filter] AI review unavailable \u2014 every model call failed; returning unreviewed findings:",
|
|
8954
|
+
firstError instanceof Error ? firstError.message : String(firstError)
|
|
8955
|
+
);
|
|
8956
|
+
}
|
|
8918
8957
|
const filtered = toReview.filter((_, i) => !fpMap.has(i));
|
|
8919
8958
|
const filteredFindings = [];
|
|
8920
8959
|
for (const [idx, reason] of fpMap) {
|
|
@@ -8923,7 +8962,7 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
8923
8962
|
return {
|
|
8924
8963
|
findings: [...filtered, ...overflow],
|
|
8925
8964
|
filteredFindings,
|
|
8926
|
-
aiReviewed:
|
|
8965
|
+
aiReviewed: reviewedAny,
|
|
8927
8966
|
removedCount: fpMap.size,
|
|
8928
8967
|
totalBefore
|
|
8929
8968
|
};
|
|
@@ -9119,6 +9158,7 @@ function scanEntropy(files) {
|
|
|
9119
9158
|
dangerousInnerHTML,
|
|
9120
9159
|
deprecatedTLS,
|
|
9121
9160
|
detectFramework,
|
|
9161
|
+
detectPlatform,
|
|
9122
9162
|
disabledTLSVerification,
|
|
9123
9163
|
djangoDebug,
|
|
9124
9164
|
dockerCopySensitive,
|