xploitscan-shared-rules 1.15.2 → 1.16.0
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/index.cjs +187 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -1
- package/dist/index.d.ts +119 -1
- package/dist/index.js +180 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
allCustomRules: () => allCustomRules,
|
|
36
36
|
allRules: () => allRules,
|
|
37
37
|
androidDebuggable: () => androidDebuggable,
|
|
38
|
+
assessHeaders: () => assessHeaders,
|
|
38
39
|
blockingMainThread: () => blockingMainThread,
|
|
39
40
|
buildTaintMap: () => buildTaintMap,
|
|
40
41
|
calculateGrade: () => calculateGrade,
|
|
@@ -52,6 +53,8 @@ __export(index_exports, {
|
|
|
52
53
|
corsWildcard: () => corsWildcard,
|
|
53
54
|
dangerousInnerHTML: () => dangerousInnerHTML,
|
|
54
55
|
deprecatedTLS: () => deprecatedTLS,
|
|
56
|
+
detectBuilder: () => detectBuilder,
|
|
57
|
+
detectExposedConfig: () => detectExposedConfig,
|
|
55
58
|
detectFramework: () => detectFramework,
|
|
56
59
|
detectPlatform: () => detectPlatform,
|
|
57
60
|
disabledTLSVerification: () => disabledTLSVerification,
|
|
@@ -80,7 +83,9 @@ __export(index_exports, {
|
|
|
80
83
|
exposedServerActions: () => exposedServerActions,
|
|
81
84
|
exposedSourceMaps: () => exposedSourceMaps,
|
|
82
85
|
exposedStackTraces: () => exposedStackTraces,
|
|
86
|
+
extractScriptUrls: () => extractScriptUrls,
|
|
83
87
|
filterFalsePositives: () => filterFalsePositives,
|
|
88
|
+
findSourceMapRefs: () => findSourceMapRefs,
|
|
84
89
|
firebaseClientConfig: () => firebaseClientConfig,
|
|
85
90
|
flaskSecretKey: () => flaskSecretKey,
|
|
86
91
|
freeRules: () => freeRules,
|
|
@@ -157,6 +162,7 @@ __export(index_exports, {
|
|
|
157
162
|
ipcPathTraversal: () => ipcPathTraversal,
|
|
158
163
|
isCalleeNamed: () => isCalleeNamed,
|
|
159
164
|
isMethodCall: () => isMethodCall,
|
|
165
|
+
isPrivateAddress: () => isPrivateAddress,
|
|
160
166
|
isVendoredFinding: () => isVendoredFinding,
|
|
161
167
|
isVendoredPath: () => isVendoredPath,
|
|
162
168
|
javaDeserialization: () => javaDeserialization,
|
|
@@ -204,6 +210,7 @@ __export(index_exports, {
|
|
|
204
210
|
openRedirectParams: () => openRedirectParams,
|
|
205
211
|
overlyPermissiveIAM: () => overlyPermissiveIAM,
|
|
206
212
|
parseFile: () => parseFile,
|
|
213
|
+
parseScanTarget: () => parseScanTarget,
|
|
207
214
|
pathTraversal: () => pathTraversal,
|
|
208
215
|
pickleDeserialization: () => pickleDeserialization,
|
|
209
216
|
piiInLogs: () => piiInLogs,
|
|
@@ -9305,6 +9312,179 @@ function scanEntropy(files) {
|
|
|
9305
9312
|
}
|
|
9306
9313
|
return findings;
|
|
9307
9314
|
}
|
|
9315
|
+
|
|
9316
|
+
// src/url-recon.ts
|
|
9317
|
+
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
9318
|
+
"localhost",
|
|
9319
|
+
"127.0.0.1",
|
|
9320
|
+
"0.0.0.0",
|
|
9321
|
+
"::1",
|
|
9322
|
+
"[::1]",
|
|
9323
|
+
"metadata.google.internal",
|
|
9324
|
+
"metadata.goog",
|
|
9325
|
+
"instance-data"
|
|
9326
|
+
]);
|
|
9327
|
+
var BLOCKED_SUFFIXES = [".local", ".localhost", ".internal", ".home.arpa", ".cluster.local"];
|
|
9328
|
+
function isPrivateAddress(address) {
|
|
9329
|
+
const addr = address.trim().toLowerCase().replace(/^\[|\]$/g, "");
|
|
9330
|
+
const mapped = addr.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
9331
|
+
if (mapped) return isPrivateAddress(mapped[1]);
|
|
9332
|
+
const v4 = addr.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
9333
|
+
if (v4) {
|
|
9334
|
+
const [a, b] = [Number(v4[1]), Number(v4[2])];
|
|
9335
|
+
if ([a, Number(v4[2]), Number(v4[3]), Number(v4[4])].some((o) => o > 255)) return true;
|
|
9336
|
+
if (a === 0) return true;
|
|
9337
|
+
if (a === 10) return true;
|
|
9338
|
+
if (a === 127) return true;
|
|
9339
|
+
if (a === 169 && b === 254) return true;
|
|
9340
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
9341
|
+
if (a === 192 && b === 168) return true;
|
|
9342
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
9343
|
+
if (a === 192 && b === 0) return true;
|
|
9344
|
+
if (a === 198 && (b === 18 || b === 19)) return true;
|
|
9345
|
+
if (a >= 224) return true;
|
|
9346
|
+
return false;
|
|
9347
|
+
}
|
|
9348
|
+
if (addr === "::" || addr === "::1") return true;
|
|
9349
|
+
if (/^f[cd][0-9a-f]{2}:/.test(addr)) return true;
|
|
9350
|
+
if (/^fe[89ab][0-9a-f]:/.test(addr)) return true;
|
|
9351
|
+
return false;
|
|
9352
|
+
}
|
|
9353
|
+
function parseScanTarget(input) {
|
|
9354
|
+
const raw = (input || "").trim();
|
|
9355
|
+
if (!raw) return { ok: false, reason: "Enter a URL to scan." };
|
|
9356
|
+
if (raw.length > 2048) return { ok: false, reason: "That URL is too long." };
|
|
9357
|
+
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `https://${raw}`;
|
|
9358
|
+
let url;
|
|
9359
|
+
try {
|
|
9360
|
+
url = new URL(withScheme);
|
|
9361
|
+
} catch {
|
|
9362
|
+
return { ok: false, reason: "That doesn't look like a valid URL." };
|
|
9363
|
+
}
|
|
9364
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
9365
|
+
return { ok: false, reason: "Only http and https URLs can be scanned." };
|
|
9366
|
+
}
|
|
9367
|
+
if (url.username || url.password) {
|
|
9368
|
+
return { ok: false, reason: "Remove the username and password from the URL." };
|
|
9369
|
+
}
|
|
9370
|
+
if (url.port && url.port !== "80" && url.port !== "443") {
|
|
9371
|
+
return { ok: false, reason: "Only the standard web ports (80 and 443) can be scanned." };
|
|
9372
|
+
}
|
|
9373
|
+
const host = url.hostname.toLowerCase();
|
|
9374
|
+
if (BLOCKED_HOSTNAMES.has(host)) {
|
|
9375
|
+
return { ok: false, reason: "That address is not publicly reachable." };
|
|
9376
|
+
}
|
|
9377
|
+
if (BLOCKED_SUFFIXES.some((s) => host.endsWith(s))) {
|
|
9378
|
+
return { ok: false, reason: "That address is not publicly reachable." };
|
|
9379
|
+
}
|
|
9380
|
+
if (isPrivateAddress(host)) {
|
|
9381
|
+
return { ok: false, reason: "That address is not publicly reachable." };
|
|
9382
|
+
}
|
|
9383
|
+
if (!host.includes(".")) {
|
|
9384
|
+
return { ok: false, reason: "Enter a full domain name." };
|
|
9385
|
+
}
|
|
9386
|
+
return { ok: true, url: url.toString(), hostname: host };
|
|
9387
|
+
}
|
|
9388
|
+
var BUILDER_SIGNATURES = [
|
|
9389
|
+
{
|
|
9390
|
+
id: "lovable",
|
|
9391
|
+
name: "Lovable",
|
|
9392
|
+
patterns: [/lovable-tagger/i, /lovable\.dev/i, /data-lov-id=/i, /gpteng\.co/i]
|
|
9393
|
+
},
|
|
9394
|
+
{ id: "v0", name: "v0", patterns: [/v0-user-next/i, /v0\.dev/i, /_next\/static.*v0-/i] },
|
|
9395
|
+
{ id: "bolt", name: "Bolt", patterns: [/bolt-vite-react/i, /stackblitz/i, /bolt\.new/i] },
|
|
9396
|
+
{ id: "base44", name: "Base44", patterns: [/@base44\/sdk/i, /base44\.app/i, /base44\.com/i] }
|
|
9397
|
+
];
|
|
9398
|
+
function detectBuilder(haystack) {
|
|
9399
|
+
for (const sig of BUILDER_SIGNATURES) {
|
|
9400
|
+
for (const p of sig.patterns) {
|
|
9401
|
+
const m = haystack.match(p);
|
|
9402
|
+
if (m) return { id: sig.id, name: sig.name, evidence: m[0].slice(0, 120) };
|
|
9403
|
+
}
|
|
9404
|
+
}
|
|
9405
|
+
return null;
|
|
9406
|
+
}
|
|
9407
|
+
function findSourceMapRefs(js, bundleUrl) {
|
|
9408
|
+
const out = [];
|
|
9409
|
+
const re = /[#@]\s*sourceMappingURL\s*=\s*([^\s*'"]+)/g;
|
|
9410
|
+
let m;
|
|
9411
|
+
while ((m = re.exec(js)) !== null) {
|
|
9412
|
+
const ref = m[1].trim();
|
|
9413
|
+
if (!ref || ref.startsWith("data:")) continue;
|
|
9414
|
+
try {
|
|
9415
|
+
out.push(new URL(ref, bundleUrl).toString());
|
|
9416
|
+
} catch {
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9419
|
+
return [...new Set(out)];
|
|
9420
|
+
}
|
|
9421
|
+
function detectExposedConfig(js) {
|
|
9422
|
+
const out = [];
|
|
9423
|
+
const supabase = js.match(/https:\/\/([a-z0-9]{16,32})\.supabase\.co/i);
|
|
9424
|
+
if (supabase) {
|
|
9425
|
+
out.push({
|
|
9426
|
+
kind: "supabase",
|
|
9427
|
+
projectRef: supabase[1],
|
|
9428
|
+
detail: "A Supabase project URL is present in the client bundle. This is normal and expected \u2014 but it means row-level security is the only thing standing between a visitor and your data."
|
|
9429
|
+
});
|
|
9430
|
+
}
|
|
9431
|
+
const firebase = js.match(/["']?projectId["']?\s*:\s*["']([a-z0-9-]{4,60})["']/i);
|
|
9432
|
+
if (firebase && /firebase/i.test(js)) {
|
|
9433
|
+
out.push({
|
|
9434
|
+
kind: "firebase",
|
|
9435
|
+
projectRef: firebase[1],
|
|
9436
|
+
detail: "A Firebase project configuration is present in the client bundle. This is normal and expected \u2014 but it means your Firestore/Storage rules are the only access control."
|
|
9437
|
+
});
|
|
9438
|
+
}
|
|
9439
|
+
return out;
|
|
9440
|
+
}
|
|
9441
|
+
function assessHeaders(headers) {
|
|
9442
|
+
const h = {};
|
|
9443
|
+
for (const [k, v] of Object.entries(headers)) h[k.toLowerCase()] = v;
|
|
9444
|
+
const out = [];
|
|
9445
|
+
if (!h["content-security-policy"]) {
|
|
9446
|
+
out.push({
|
|
9447
|
+
header: "Content-Security-Policy",
|
|
9448
|
+
severity: "medium",
|
|
9449
|
+
message: "No CSP. A single injected script has nothing stopping it from loading or exfiltrating."
|
|
9450
|
+
});
|
|
9451
|
+
}
|
|
9452
|
+
if (!h["strict-transport-security"]) {
|
|
9453
|
+
out.push({
|
|
9454
|
+
header: "Strict-Transport-Security",
|
|
9455
|
+
severity: "medium",
|
|
9456
|
+
message: "No HSTS. A first visit over http can be intercepted before the redirect to https."
|
|
9457
|
+
});
|
|
9458
|
+
}
|
|
9459
|
+
if (!h["x-content-type-options"]) {
|
|
9460
|
+
out.push({
|
|
9461
|
+
header: "X-Content-Type-Options",
|
|
9462
|
+
severity: "low",
|
|
9463
|
+
message: "Missing nosniff. Browsers may re-interpret a response as a type you did not intend."
|
|
9464
|
+
});
|
|
9465
|
+
}
|
|
9466
|
+
if (!h["referrer-policy"]) {
|
|
9467
|
+
out.push({
|
|
9468
|
+
header: "Referrer-Policy",
|
|
9469
|
+
severity: "low",
|
|
9470
|
+
message: "No referrer policy. Full URLs \u2014 including any ids in the path \u2014 leak to third parties."
|
|
9471
|
+
});
|
|
9472
|
+
}
|
|
9473
|
+
return out;
|
|
9474
|
+
}
|
|
9475
|
+
function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
9476
|
+
const out = [];
|
|
9477
|
+
const re = /<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi;
|
|
9478
|
+
let m;
|
|
9479
|
+
while ((m = re.exec(html)) !== null && out.length < limit) {
|
|
9480
|
+
try {
|
|
9481
|
+
const u = new URL(m[1], pageUrl);
|
|
9482
|
+
if (u.protocol === "http:" || u.protocol === "https:") out.push(u.toString());
|
|
9483
|
+
} catch {
|
|
9484
|
+
}
|
|
9485
|
+
}
|
|
9486
|
+
return [...new Set(out)];
|
|
9487
|
+
}
|
|
9308
9488
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9309
9489
|
0 && (module.exports = {
|
|
9310
9490
|
NON_APP_PATH_PATTERNS,
|
|
@@ -9312,6 +9492,7 @@ function scanEntropy(files) {
|
|
|
9312
9492
|
allCustomRules,
|
|
9313
9493
|
allRules,
|
|
9314
9494
|
androidDebuggable,
|
|
9495
|
+
assessHeaders,
|
|
9315
9496
|
blockingMainThread,
|
|
9316
9497
|
buildTaintMap,
|
|
9317
9498
|
calculateGrade,
|
|
@@ -9329,6 +9510,8 @@ function scanEntropy(files) {
|
|
|
9329
9510
|
corsWildcard,
|
|
9330
9511
|
dangerousInnerHTML,
|
|
9331
9512
|
deprecatedTLS,
|
|
9513
|
+
detectBuilder,
|
|
9514
|
+
detectExposedConfig,
|
|
9332
9515
|
detectFramework,
|
|
9333
9516
|
detectPlatform,
|
|
9334
9517
|
disabledTLSVerification,
|
|
@@ -9357,7 +9540,9 @@ function scanEntropy(files) {
|
|
|
9357
9540
|
exposedServerActions,
|
|
9358
9541
|
exposedSourceMaps,
|
|
9359
9542
|
exposedStackTraces,
|
|
9543
|
+
extractScriptUrls,
|
|
9360
9544
|
filterFalsePositives,
|
|
9545
|
+
findSourceMapRefs,
|
|
9361
9546
|
firebaseClientConfig,
|
|
9362
9547
|
flaskSecretKey,
|
|
9363
9548
|
freeRules,
|
|
@@ -9434,6 +9619,7 @@ function scanEntropy(files) {
|
|
|
9434
9619
|
ipcPathTraversal,
|
|
9435
9620
|
isCalleeNamed,
|
|
9436
9621
|
isMethodCall,
|
|
9622
|
+
isPrivateAddress,
|
|
9437
9623
|
isVendoredFinding,
|
|
9438
9624
|
isVendoredPath,
|
|
9439
9625
|
javaDeserialization,
|
|
@@ -9481,6 +9667,7 @@ function scanEntropy(files) {
|
|
|
9481
9667
|
openRedirectParams,
|
|
9482
9668
|
overlyPermissiveIAM,
|
|
9483
9669
|
parseFile,
|
|
9670
|
+
parseScanTarget,
|
|
9484
9671
|
pathTraversal,
|
|
9485
9672
|
pickleDeserialization,
|
|
9486
9673
|
piiInLogs,
|