xploitscan-shared-rules 1.27.0 → 1.27.1
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 +28 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2104,6 +2104,7 @@ var missingAuthMiddleware = {
|
|
|
2104
2104
|
description: "API routes without authentication checks allow unauthorized access.",
|
|
2105
2105
|
check(content, filePath, project) {
|
|
2106
2106
|
if (!isServerSideFile(filePath, content)) return [];
|
|
2107
|
+
if (PUBLIC_BY_CONVENTION_ROUTE.test(routeSegmentName(filePath))) return [];
|
|
2107
2108
|
const routePatterns = [
|
|
2108
2109
|
// Express/Hono style
|
|
2109
2110
|
/\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]+["'`]\s*,\s*(?:async\s+)?\(?(?:req|c|ctx)/gi,
|
|
@@ -2169,7 +2170,22 @@ var missingAuthMiddleware = {
|
|
|
2169
2170
|
/\bjwt\.verify\b/i,
|
|
2170
2171
|
/\bbearer\s/i,
|
|
2171
2172
|
/\b(?:protect|guard)\(/i,
|
|
2172
|
-
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i
|
|
2173
|
+
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
2174
|
+
// A handler that can answer HTTP 401 is, by definition, deciding whether
|
|
2175
|
+
// the caller is allowed in. This catches the whole family of
|
|
2176
|
+
// capability-token flows the named patterns above miss — magic links,
|
|
2177
|
+
// share links, unsubscribe links, invite/claim URLs — where there is no
|
|
2178
|
+
// session and no account, and the unguessable token in the request IS
|
|
2179
|
+
// the credential, checked by a bespoke lookup like
|
|
2180
|
+
// `findShareByToken(slug, token)`.
|
|
2181
|
+
//
|
|
2182
|
+
// 401 only, deliberately not 403. 401 means "I could not authenticate
|
|
2183
|
+
// you"; 403 is routinely returned by things that never identified the
|
|
2184
|
+
// caller at all — an Origin allowlist on an anonymous analytics beacon,
|
|
2185
|
+
// a feature flag, a geo block. Accepting 403 would suppress genuinely
|
|
2186
|
+
// unauthenticated routes.
|
|
2187
|
+
/\bstatus(?:Code)?\s*[:(]\s*401\b/,
|
|
2188
|
+
/\bsendStatus\s*\(\s*401\b/
|
|
2173
2189
|
];
|
|
2174
2190
|
const APP_LEVEL_AUTH = [
|
|
2175
2191
|
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
@@ -2229,6 +2245,15 @@ var missingAuthMiddleware = {
|
|
|
2229
2245
|
return filterSilenced(unauthenticated, content, "VC003");
|
|
2230
2246
|
}
|
|
2231
2247
|
};
|
|
2248
|
+
var PUBLIC_BY_CONVENTION_ROUTE = /^(?:og|opengraph-image|twitter-image|icon|apple-icon|favicon|sitemap|robots|manifest|badge)(?:[.-]\w+)?$/i;
|
|
2249
|
+
function routeSegmentName(filePath) {
|
|
2250
|
+
const segments = filePath.split("/");
|
|
2251
|
+
const base = segments[segments.length - 1] ?? "";
|
|
2252
|
+
if (/^route\.(?:ts|tsx|js|jsx|mjs|cjs)$/i.test(base)) {
|
|
2253
|
+
return segments[segments.length - 2] ?? "";
|
|
2254
|
+
}
|
|
2255
|
+
return base.replace(/\.[^.]+$/, "");
|
|
2256
|
+
}
|
|
2232
2257
|
var supabaseNoRLS = {
|
|
2233
2258
|
id: "VC004",
|
|
2234
2259
|
title: "Supabase Client Without Row Level Security",
|
|
@@ -2762,10 +2787,10 @@ var insecureCookies = {
|
|
|
2762
2787
|
check(content, filePath) {
|
|
2763
2788
|
if (isTestFile(filePath)) return [];
|
|
2764
2789
|
if (!/cookie/i.test(content)) return [];
|
|
2765
|
-
const setCookiePattern = /(?:set-cookie|setCookie
|
|
2790
|
+
const setCookiePattern = /(?:set-cookie|setCookie|\bcookie\s*=|res\.cookie\s*\()/gi;
|
|
2766
2791
|
if (!setCookiePattern.test(content)) return [];
|
|
2767
2792
|
const hasHttpOnly = /httpOnly\s*:\s*true|httponly/i.test(content);
|
|
2768
|
-
const hasSecure = /secure\s*:\s*
|
|
2793
|
+
const hasSecure = /secure\s*:\s*(?!false\b)\S/i.test(content) || /;\s*secure/i.test(content);
|
|
2769
2794
|
const hasSameSite = /sameSite\s*:|samesite/i.test(content);
|
|
2770
2795
|
const matches = [];
|
|
2771
2796
|
if (!hasHttpOnly || !hasSecure || !hasSameSite) {
|