@lunora/advisor 1.0.0-alpha.15 → 1.0.0-alpha.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/index.d.mts +1860 -1
- package/dist/index.d.ts +1860 -1
- package/dist/index.mjs +96 -6
- package/dist/packem_shared/{AE_METRIC_EVENTS-DexctYv6.mjs → AE_METRIC_EVENTS-BM14d0lm.mjs} +3 -1
- package/dist/packem_shared/actionFetchSsrf-wbmYgzmz.mjs +26 -0
- package/dist/packem_shared/aiRawRunEscapeHatch-C29jd32J.mjs +26 -0
- package/dist/packem_shared/aiToolSideEffectPromptInjection-BtD3alqB.mjs +33 -0
- package/dist/packem_shared/aiUnboundedGenerationPublic-CbAcSxLB.mjs +26 -0
- package/dist/packem_shared/allowUnauthenticatedShardAccessEnabled-BcASq-jP.mjs +30 -0
- package/dist/packem_shared/authCsrfCheckDisabled-DCf9FSoD.mjs +26 -0
- package/dist/packem_shared/authEmailVerificationDisabled-Dk-Tc5oU.mjs +26 -0
- package/dist/packem_shared/authSecureCookiesDisabled-osJrHW9Y.mjs +26 -0
- package/dist/packem_shared/authSessionFreshageZero-CjufCc_Q.mjs +26 -0
- package/dist/packem_shared/authTrustedOriginsWildcard-ylv4PKzC.mjs +26 -0
- package/dist/packem_shared/browserAllowPrivateTargets-CBvQxLAM.mjs +26 -0
- package/dist/packem_shared/browserUserUrlWithoutAllowlist-B5DrK72J.mjs +32 -0
- package/dist/packem_shared/containerInstanceKeyFromUserInput-DLl-jpex.mjs +26 -0
- package/dist/packem_shared/containerRuntimeEgressRelaxation-B0LlfmDA.mjs +26 -0
- package/dist/packem_shared/containerStartEnableInternetOverride-DDaHZQ1L.mjs +26 -0
- package/dist/packem_shared/flagGatesSecurityWithUnsafeDefault-BhIs0shr.mjs +41 -0
- package/dist/packem_shared/{fromServerSchema-WVRvXPy8.mjs → fromServerSchema-BiB6JSiW.mjs} +3 -0
- package/dist/packem_shared/helpers-BhGmRI2n.mjs +30 -0
- package/dist/packem_shared/httpActionMissingAuthGuard-CxipddNx.mjs +35 -0
- package/dist/packem_shared/httpActionResponseHeaderInjection-DOFS7pFT.mjs +39 -0
- package/dist/packem_shared/identityUndeclaredClaimTrusted-D8nXV2dd.mjs +32 -0
- package/dist/packem_shared/imagesUrlSourceFromUserInput-BYq6I7VC.mjs +26 -0
- package/dist/packem_shared/{indexReferencesUnknownField-DH0_dbUY.mjs → indexReferencesUnknownField-BfCCZfgW.mjs} +1 -1
- package/dist/packem_shared/insertManyUnsafeUserData-Dn77XpmX.mjs +26 -0
- package/dist/packem_shared/kvUnscopedUserKeyIdor-wOv1sRL8.mjs +26 -0
- package/dist/packem_shared/mailInboundDispatchWithoutVerify-CHSRA8zz.mjs +28 -0
- package/dist/packem_shared/mailRecipientFromRequestInput-Cka2qu5J.mjs +26 -0
- package/dist/packem_shared/maskWeakHashStrategyOnPii-1c4q8Opf.mjs +35 -0
- package/dist/packem_shared/maskedRelationLeakViaWith-CPI4s0sl.mjs +76 -0
- package/dist/packem_shared/normalizeIdUsedAsAuthorization-BVPtCpzT.mjs +50 -0
- package/dist/packem_shared/outputProjectionMissingOnPublicRead-Cjd885DW.mjs +51 -0
- package/dist/packem_shared/ownerFieldFromArgsNotAuth-mOw3hE5z.mjs +26 -0
- package/dist/packem_shared/paymentCreateWithoutAuthorize-BYm4JLxo.mjs +26 -0
- package/dist/packem_shared/paymentWebhookWideTolerance-D9QQJMJq.mjs +35 -0
- package/dist/packem_shared/plaintextSecretInWranglerVariables-NKO4YkKf.mjs +35 -0
- package/dist/packem_shared/privilegedDispatchUnvalidatedPayload-5Forjckt.mjs +37 -0
- package/dist/packem_shared/privilegedFanoutFromPublicProcedure-D3dL01B8.mjs +26 -0
- package/dist/packem_shared/publicTableRlsOptoutConfusion-DJ5GFSRD.mjs +38 -0
- package/dist/packem_shared/ratelimitDefaultMemoryStore-BISChG5C.mjs +26 -0
- package/dist/packem_shared/ratelimitKeySpoofableOrGlobal-DqlHYQQ3.mjs +26 -0
- package/dist/packem_shared/ratelimitMiddlewareFailOpen-CJgDCaUw.mjs +33 -0
- package/dist/packem_shared/{relationReferencesUnknownField-YznyXt_7.mjs → relationReferencesUnknownField-D4hckqi8.mjs} +1 -1
- package/dist/packem_shared/softDeleteIncludeDeletedFromArgs-BLqDKrkM.mjs +38 -0
- package/dist/packem_shared/storageGenerateUploadUrlNoContentTypePin-Da4L9Ge8.mjs +26 -0
- package/dist/packem_shared/storageKeyFromUserArgs-B7k0iiGb.mjs +26 -0
- package/dist/packem_shared/storagePresignedUrlForPrivateContent-yGmb8uqz.mjs +47 -0
- package/dist/packem_shared/storageUploadWithoutContentTypeAllowlist-BV-gF1lT.mjs +27 -0
- package/dist/packem_shared/storageUploadWithoutMaxSize-DpxO59wU.mjs +27 -0
- package/dist/packem_shared/vectorsNamespaceFromUserInput-CCSl5SYq.mjs +26 -0
- package/package.json +3 -2
- package/dist/packem_shared/helpers-DNCkMWZQ.mjs +0 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const WIDE_TOLERANCE_THRESHOLD_SECONDS = 60 * 60;
|
|
4
|
+
const paymentWebhookWideTolerance = {
|
|
5
|
+
categories: ["SECURITY"],
|
|
6
|
+
description: "A payment webhook adapter configured with an implausibly wide `webhookToleranceSeconds` (over an hour). The timestamp tolerance is the webhook replay window; widening it far past the 300s default keeps captured signed events replayable long after capture, defeating the replay check.",
|
|
7
|
+
facing: "EXTERNAL",
|
|
8
|
+
level: "WARN",
|
|
9
|
+
name: "payment_webhook_wide_tolerance",
|
|
10
|
+
remediation: "Keep `webhookToleranceSeconds` at or near the 300s default — just enough for clock skew. If a wide window was set to work around retries or backfills, handle those with idempotency on the event id instead, not by loosening the replay-window guard.",
|
|
11
|
+
run: (context) => {
|
|
12
|
+
if (context.paymentWebhooks === void 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
const isWide = (row) => row.toleranceSeconds !== void 0 && row.toleranceSeconds >= WIDE_TOLERANCE_THRESHOLD_SECONDS;
|
|
16
|
+
return context.paymentWebhooks.filter((row) => isWide(row)).map((row) => {
|
|
17
|
+
const location = `\`${row.exportName}\` (${row.file}:${row.line.toString()})`;
|
|
18
|
+
return emit(paymentWebhookWideTolerance, {
|
|
19
|
+
cacheKey: `payment_webhook_wide_tolerance:${row.file}:${row.line.toString()}`,
|
|
20
|
+
detail: `\`${row.callee}\` in ${location} sets \`webhookToleranceSeconds\` to ${(row.toleranceSeconds ?? 0).toString()}s (default 300s). That replay window keeps captured signed events valid long after capture.`,
|
|
21
|
+
metadata: {
|
|
22
|
+
callee: row.callee,
|
|
23
|
+
exportName: row.exportName,
|
|
24
|
+
file: row.file,
|
|
25
|
+
line: row.line,
|
|
26
|
+
toleranceSeconds: row.toleranceSeconds
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
source: "static",
|
|
32
|
+
title: "Payment webhook replay-tolerance window is implausibly wide"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { paymentWebhookWideTolerance as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const plaintextSecretInWranglerVariables = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A plaintext secret is committed to `wrangler.jsonc`'s `vars` block. `vars` are cleartext — baked into the deployed Worker and checked into source control — so the secret leaks via the repo and the bundle, and rotating it needs a config edit plus a redeploy.",
|
|
6
|
+
facing: "INTERNAL",
|
|
7
|
+
level: "ERROR",
|
|
8
|
+
name: "plaintext_secret_in_wrangler_vars",
|
|
9
|
+
remediation: "Move the value out of `vars`: bind it through a Secrets Store (`ctx.secrets.get(<NAME>)`) or set it with `wrangler secret put <NAME>` and read it from `env.<NAME>`. Delete the `vars` entry and rotate the exposed value — assume it is already compromised. Public/publishable keys (name them `*_PUBLIC` / `*_PUBLISHABLE`) are exempt.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.wranglerVariables === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const findings = [];
|
|
15
|
+
const occurrenceCount = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const wranglerVariable of context.wranglerVariables) {
|
|
17
|
+
const baseKey = `${wranglerVariable.file}:${wranglerVariable.key}`;
|
|
18
|
+
const occurrence = (occurrenceCount.get(baseKey) ?? 0) + 1;
|
|
19
|
+
occurrenceCount.set(baseKey, occurrence);
|
|
20
|
+
const occurrenceSuffix = occurrence > 1 ? `:${occurrence.toString()}` : "";
|
|
21
|
+
findings.push(
|
|
22
|
+
emit(plaintextSecretInWranglerVariables, {
|
|
23
|
+
cacheKey: `plaintext_secret_in_wrangler_vars:${baseKey}${occurrenceSuffix}`,
|
|
24
|
+
detail: `The \`vars\` entry \`${wranglerVariable.key}\` in ${wranglerVariable.file} holds a plaintext ${wranglerVariable.kind.replaceAll("_", " ")} (${wranglerVariable.preview}). \`vars\` ship in cleartext to the deployed Worker and are committed to source control — move it to a Secrets Store binding or \`wrangler secret put\` and rotate the exposed value.`,
|
|
25
|
+
metadata: { file: wranglerVariable.file, key: wranglerVariable.key, kind: wranglerVariable.kind, preview: wranglerVariable.preview }
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return findings;
|
|
30
|
+
},
|
|
31
|
+
source: "static",
|
|
32
|
+
title: "Plaintext secret in wrangler vars"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { plaintextSecretInWranglerVariables as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const privilegedDispatchUnvalidatedPayload = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `defineQueue`/`defineWorkflow` handler forwards its untrusted payload (queue body / workflow params) straight into a `ctx.run` dispatch whose target is RLS-gated. The handler runs under the system identity with RLS disabled, so the target's row policy — the only thing guarding it — is bypassed, letting a caller act as any user / write across tenants.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "ERROR",
|
|
8
|
+
name: "privileged_dispatch_unvalidated_payload",
|
|
9
|
+
remediation: "Don't forward an unchecked queue body / workflow param into an RLS-gated function. Re-derive the ownership/identity keys from server-trusted state (or an argument you validate against it) before dispatching, or route the work through a function that re-checks the caller's identity rather than relying on the row policy the privileged handler skips.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.privilegedDispatches === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const rlsProcedures = context.rlsProcedures ?? [];
|
|
15
|
+
const targetUsesRls = (targetFile, targetExport) => rlsProcedures.some((procedure) => procedure.usesRls && procedure.file === targetFile && procedure.exportName === targetExport);
|
|
16
|
+
return context.privilegedDispatches.filter((dispatch) => targetUsesRls(dispatch.targetFile, dispatch.targetExport)).map((dispatch) => {
|
|
17
|
+
const handlerKind = dispatch.dispatchKind === "queue" ? "queue" : "workflow";
|
|
18
|
+
const payloadSource = dispatch.dispatchKind === "queue" ? "queue message body" : "workflow params";
|
|
19
|
+
return emit(privilegedDispatchUnvalidatedPayload, {
|
|
20
|
+
cacheKey: `privileged_dispatch_unvalidated_payload:${dispatch.file}:${dispatch.line.toString()}`,
|
|
21
|
+
detail: `The ${handlerKind} handler \`${dispatch.handlerExport}\` (${dispatch.file}:${dispatch.line.toString()}) forwards its untrusted ${payloadSource} straight into \`${dispatch.targetFile}.${dispatch.targetExport}\`, which is guarded by \`.use(rls(...))\`. The handler runs under the system identity with RLS disabled, so the target's row policy is bypassed — any ownership/identity field the payload controls lets a caller act as another user or write across tenants. Re-derive the identity keys from server-trusted state before dispatching, or route through a function that re-checks the caller.`,
|
|
22
|
+
metadata: {
|
|
23
|
+
dispatchKind: dispatch.dispatchKind,
|
|
24
|
+
file: dispatch.file,
|
|
25
|
+
handlerExport: dispatch.handlerExport,
|
|
26
|
+
line: dispatch.line,
|
|
27
|
+
targetExport: dispatch.targetExport,
|
|
28
|
+
targetFile: dispatch.targetFile
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
source: "static",
|
|
34
|
+
title: "Privileged handler forwards untrusted payload into an RLS-gated function"
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { privilegedDispatchUnvalidatedPayload as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const privilegedFanoutFromPublicProcedure = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A public procedure fans work out to a privileged dispatch surface (`ctx.scheduler.runAfter`/`runAt`, a `ctx.queues.<name>` send, or `ctx.workflows.<name>.create`) with no rate-limit guard. Each dispatch runs later under the system identity and bills the account, so an anonymous caller can amplify cost and flood the async surface in a loop.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "WARN",
|
|
8
|
+
name: "privileged_fanout_from_public_procedure",
|
|
9
|
+
remediation: "Gate the public entry point with a rate limit (`.use(rateLimit(...))` or a `protectPublic({ rateLimit })` bundle), or make the fan-out procedure internal and trigger it only from an authenticated, guarded path. Never expose an unbounded scheduler/queue/workflow dispatch to anonymous callers.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.procedureProtections === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.procedureProtections.filter((procedure) => procedure.fanOut && procedure.visibility === "public" && !procedure.usesRateLimit).map(
|
|
15
|
+
(procedure) => emit(privilegedFanoutFromPublicProcedure, {
|
|
16
|
+
cacheKey: `privileged_fanout_from_public_procedure:${procedure.file}:${procedure.exportName}`,
|
|
17
|
+
detail: `\`${procedure.exportName}\` (${procedure.file}) is public and fans work out to a privileged dispatch surface (scheduler/queue/workflow) with no rate limit — an anonymous caller can drive that billable, system-identity dispatch in a loop. Add a rate-limit guard, or make it internal and trigger it from an authenticated path.`,
|
|
18
|
+
metadata: { exportName: procedure.exportName, file: procedure.file, kind: procedure.kind }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "Public procedure fans out to a privileged dispatch surface"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { privilegedFanoutFromPublicProcedure as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
import { o as ownershipOrPiiColumns } from './helpers-BhGmRI2n.mjs';
|
|
3
|
+
|
|
4
|
+
const publicTableRlsOptoutConfusion = {
|
|
5
|
+
categories: ["SECURITY"],
|
|
6
|
+
description: '`.public()` opts a table OUT of the schema\'s `.rls("required")` enforcement — it does not mean the table holds public data. A `.public()` table whose columns look ownership- or PII-shaped (`userId`, `email`, `ssn`, …) is exempt from the row-security guard, not "safe to expose".',
|
|
7
|
+
facing: "EXTERNAL",
|
|
8
|
+
level: "WARN",
|
|
9
|
+
name: "public_table_rls_optout_confusion",
|
|
10
|
+
remediation: 'Double-check this table actually needs the RLS opt-out. If it does not, remove `.public()` so `.rls("required")` covers it like every other table. If it genuinely must stay open (a shared lookup table, for instance), rename or comment it so the exemption is intentional rather than a name-implies-safety mistake, and make sure no procedure trusts `.public()` as an authorization boundary.',
|
|
11
|
+
run: (context) => {
|
|
12
|
+
if (context.schema.rlsMode !== "required") {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
const findings = [];
|
|
16
|
+
for (const table of context.schema.tables) {
|
|
17
|
+
if (!table.isPublic) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const flaggedColumns = ownershipOrPiiColumns(table);
|
|
21
|
+
if (flaggedColumns.length === 0) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
findings.push(
|
|
25
|
+
emit(publicTableRlsOptoutConfusion, {
|
|
26
|
+
cacheKey: `public_table_rls_optout_confusion:${table.name}`,
|
|
27
|
+
detail: `Table "${table.name}" is \`.public()\` (opted OUT of the schema's \`.rls("required")\` enforcement) but carries ownership/PII-shaped column(s): ${flaggedColumns.join(", ")}. \`.public()\` means "exempt from RLS", not "safe to expose" — confirm this table really needs the opt-out.`,
|
|
28
|
+
metadata: { columns: flaggedColumns, table: table.name }
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return findings;
|
|
33
|
+
},
|
|
34
|
+
source: "static",
|
|
35
|
+
title: "Public table opts out of RLS but carries sensitive columns"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { publicTableRlsOptoutConfusion as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const ratelimitDefaultMemoryStore = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "`new RateLimiter({...})` has no `store`, so it falls back to a per-instance in-memory store. On Workers each request may hit a different isolate, so the counter never sums across them — the limit silently under-counts and is effectively a no-op under load, giving false protection against brute-force and cost abuse.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "WARN",
|
|
8
|
+
name: "ratelimit_default_memory_store",
|
|
9
|
+
remediation: "Pass a shared, durable `store` to `new RateLimiter({...})` (a Durable-Object- or KV-backed store) so every Worker isolate reads and writes the same bucket. The default in-memory store is per-isolate and does not enforce a global limit.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.configCalls === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.configCalls.filter((call) => call.callee === "RateLimiter" && call.analyzable && !call.presentKeys.includes("store")).map(
|
|
15
|
+
(call) => emit(ratelimitDefaultMemoryStore, {
|
|
16
|
+
cacheKey: `ratelimit_default_memory_store:${call.file}:${call.line.toString()}`,
|
|
17
|
+
detail: `\`new RateLimiter({...})\` in ${call.file}:${call.line.toString()} has no \`store\` — it uses the per-instance in-memory store, which never sums across Worker isolates, so the limit silently under-counts under load. Pass a Durable-Object- or KV-backed \`store\` so the limit is enforced globally.`,
|
|
18
|
+
metadata: { callee: call.callee, file: call.file, line: call.line }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "RateLimiter using the default in-memory store"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { ratelimitDefaultMemoryStore as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const ratelimitKeySpoofableOrGlobal = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `rateLimit`/`dbRateLimit` middleware call's `key` selector is derived from the handler's `args` with no server-side scoping, so an attacker can rotate the key on every request (e.g. by resubmitting a different email/id) and never share a bucket with themselves — the limit never actually limits them.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "WARN",
|
|
8
|
+
name: "ratelimit_key_spoofable_or_global",
|
|
9
|
+
remediation: 'Derive the rate-limit `key` from a server-trusted value — `ctx.auth.userId` for authenticated callers, `ctx.ip` for anonymous ones (e.g. `key: (ctx) => ctx.auth.userId ?? ctx.ip ?? "anon"`) — instead of an `args` field the caller controls.',
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.ratelimitKeySelectors === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.ratelimitKeySelectors.map(
|
|
15
|
+
(selector) => emit(ratelimitKeySpoofableOrGlobal, {
|
|
16
|
+
cacheKey: `ratelimit_key_spoofable_or_global:${selector.file}:${selector.line.toString()}`,
|
|
17
|
+
detail: `\`${selector.callee}(…, "${selector.limitName}", { key })\` in \`${selector.exportName}\` (${selector.file}:${selector.line.toString()}) derives its \`key\` from \`args\` with no server-side scoping — an attacker can rotate the key per request and bypass the limit. Derive \`key\` from \`ctx.auth.userId\` / \`ctx.ip\` instead.`,
|
|
18
|
+
metadata: { callee: selector.callee, exportName: selector.exportName, file: selector.file, limitName: selector.limitName, line: selector.line }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "Rate-limit key derived from spoofable user input"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { ratelimitKeySpoofableOrGlobal as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const SENSITIVE_TOKENS = ["signin", "signup", "login", "register", "reset", "password", "otp", "verify", "payment", "checkout"];
|
|
4
|
+
const normalize = (value) => value.toLowerCase().replaceAll(/[^a-z0-9]+/gu, "");
|
|
5
|
+
const matchesSensitiveToken = (value) => {
|
|
6
|
+
const normalized = normalize(value);
|
|
7
|
+
return SENSITIVE_TOKENS.some((token) => normalized.includes(token));
|
|
8
|
+
};
|
|
9
|
+
const guardsSensitiveFlow = (row) => matchesSensitiveToken(row.exportName) || matchesSensitiveToken(row.limitName);
|
|
10
|
+
const ratelimitMiddlewareFailOpen = {
|
|
11
|
+
categories: ["SECURITY"],
|
|
12
|
+
description: "A rate-limit or Turnstile middleware guarding a sensitive auth/payment procedure is configured `failOpen: true`, so a limiter store outage or a failed Turnstile siteverify silently admits every request — turning a transient failure into an unthrottled brute-force / abuse window.",
|
|
13
|
+
facing: "EXTERNAL",
|
|
14
|
+
level: "WARN",
|
|
15
|
+
name: "ratelimit_middleware_fail_open",
|
|
16
|
+
remediation: "Drop `failOpen: true` (the default is fail-closed) on the rate-limit / Turnstile guard for auth and payment flows, or move the escape hatch to a non-sensitive procedure. Prefer rejecting traffic with a 503 over admitting unlimited unauthenticated attempts when the limiter or siteverify is unavailable.",
|
|
17
|
+
run: (context) => {
|
|
18
|
+
if (context.failOpenGuards === void 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return context.failOpenGuards.filter((row) => row.failOpen && guardsSensitiveFlow(row)).map(
|
|
22
|
+
(row) => emit(ratelimitMiddlewareFailOpen, {
|
|
23
|
+
cacheKey: `ratelimit_middleware_fail_open:${row.file}:${row.line.toString()}`,
|
|
24
|
+
detail: `\`${row.callee}(...)\` in \`${row.exportName}\` (${row.file}:${row.line.toString()}) sets \`failOpen: true\` while guarding a sensitive flow — a limiter/siteverify outage then admits every request instead of rejecting it.`,
|
|
25
|
+
metadata: { callee: row.callee, exportName: row.exportName, file: row.file, limitName: row.limitName, line: row.line }
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
source: "static",
|
|
30
|
+
title: "Fail-open rate-limit / CAPTCHA guard on a sensitive procedure"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { ratelimitMiddlewareFailOpen as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
-
import { t as tableColumnSet } from './helpers-
|
|
2
|
+
import { t as tableColumnSet } from './helpers-BhGmRI2n.mjs';
|
|
3
3
|
|
|
4
4
|
const missingColumns = (byName, columnsOf, holder, relation) => {
|
|
5
5
|
const target = byName.get(relation.table);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const softDeleteIncludeDeletedFromArgs = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `.public()` read passes `includeDeleted` (hardcoded `true` or derived from `args`) on a `.softDelete()` table, resurfacing soft-deleted rows to callers that should never see them.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "INFO",
|
|
8
|
+
name: "soft_delete_include_deleted_from_args",
|
|
9
|
+
remediation: "Drop `includeDeleted` from the public read so soft-deleted rows stay hidden, or move the trash/restore view behind an internal (or RLS/role-gated) procedure. Never wire `includeDeleted` from `args` on a public read — an attacker can set it to see rows the app treats as deleted.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.softDeleteReads === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const softDeleteTables = new Set(context.schema.tables.filter((table) => table.softDelete !== void 0).map((table) => table.name));
|
|
15
|
+
if (softDeleteTables.size === 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return context.softDeleteReads.filter((row) => row.visibility === "public" && row.table !== "" && softDeleteTables.has(row.table) && (row.hardcodedTrue || row.fromArgs)).map((row) => {
|
|
19
|
+
const location = `\`${row.exportName}\` (${row.file}:${row.line.toString()})`;
|
|
20
|
+
const detail = row.fromArgs ? `The public read in ${location} wires \`includeDeleted\` from request \`args\` on soft-delete table \`${row.table}\`, letting any caller resurface soft-deleted rows the app treats as gone.` : `The public read in ${location} hardcodes \`includeDeleted: true\` on soft-delete table \`${row.table}\`, returning soft-deleted rows to every caller.`;
|
|
21
|
+
return emit(softDeleteIncludeDeletedFromArgs, {
|
|
22
|
+
cacheKey: `soft_delete_include_deleted_from_args:${row.file}:${row.line.toString()}:${row.table}`,
|
|
23
|
+
detail,
|
|
24
|
+
metadata: {
|
|
25
|
+
exportName: row.exportName,
|
|
26
|
+
file: row.file,
|
|
27
|
+
line: row.line,
|
|
28
|
+
source: row.fromArgs ? "args" : "literal",
|
|
29
|
+
table: row.table
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
source: "static",
|
|
35
|
+
title: "Soft-deleted rows resurfaced via includeDeleted on a public read"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { softDeleteIncludeDeletedFromArgs as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const storageGenerateUploadUrlNoContentTypePin = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `ctx.storage.generateUploadUrl(key, …)` call has no `contentType` pin, so the signed PUT URL it mints authorizes any content-type/size the client chooses — `upload()`'s `allowedContentTypes`/`maxSize` guards never run for a client-side PUT against this URL.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "WARN",
|
|
8
|
+
name: "storage_generate_upload_url_no_content_type_pin",
|
|
9
|
+
remediation: "Pass `contentType` to `ctx.storage.generateUploadUrl(key, { contentType })` so the signature only authorizes a PUT with that exact content-type. If the client's upload size/type also needs bounding, prefer `upload()`/`store()` (with `allowedContentTypes`/`maxSize`) over a client-side signed PUT.",
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.storageUploads === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.storageUploads.filter((row) => row.method === "generateUploadUrl" && row.analyzable && !row.presentKeys.includes("contentType")).map(
|
|
15
|
+
(row) => emit(storageGenerateUploadUrlNoContentTypePin, {
|
|
16
|
+
cacheKey: `storage_generate_upload_url_no_content_type_pin:${row.file}:${row.line.toString()}`,
|
|
17
|
+
detail: `\`ctx.storage.generateUploadUrl\` in \`${row.exportName}\` (${row.file}:${row.line.toString()}) has no \`contentType\` pin — the signed PUT it mints accepts any type/size, minted client-side and bypassing \`upload()\`'s guards.`,
|
|
18
|
+
metadata: { exportName: row.exportName, file: row.file, line: row.line }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "generateUploadUrl signed PUT with no content-type pin"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { storageGenerateUploadUrlNoContentTypePin as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const storageKeyFromUserArgs = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `ctx.storage.*` call uses an R2 object key taken directly from the handler's `args` with no server-side scoping. The bucket methods key by the caller-supplied string, so any caller can read, overwrite, or delete another user's object — object-level IDOR.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "ERROR",
|
|
8
|
+
name: "storage_key_from_user_args",
|
|
9
|
+
remediation: `Prefix the object key with a server-trusted identity (e.g. \`\${ctx.auth.userId}/…\`) or resolve the object through a record the caller is known to own. Never pass request input straight through as an R2 object key.`,
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.storageKeyAccesses === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.storageKeyAccesses.map(
|
|
15
|
+
(access) => emit(storageKeyFromUserArgs, {
|
|
16
|
+
cacheKey: `storage_key_from_user_args:${access.file}:${access.line.toString()}`,
|
|
17
|
+
detail: `\`ctx.storage.*.${access.method}\` in \`${access.exportName}\` (${access.file}:${access.line.toString()}) uses an object key derived from \`args\` with no server-side scoping — any caller can read/overwrite/delete another user's object (IDOR). Prefix the key with a server-trusted identity (e.g. \`\${ctx.auth.userId}/…\`) or resolve the object through an owned record.`,
|
|
18
|
+
metadata: { exportName: access.exportName, file: access.file, line: access.line, method: access.method }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "R2 object key taken directly from user args (IDOR)"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { storageKeyFromUserArgs as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const SIGNER_METHODS = /* @__PURE__ */ new Set(["getPresignedUrl", "getSignedUrl"]);
|
|
4
|
+
const NEAR_MAX_EXPIRES_THRESHOLD_SECONDS = 6 * 24 * 60 * 60;
|
|
5
|
+
const isNativePresignedCall = (row) => row.method === "getPresignedUrl";
|
|
6
|
+
const isNearExpiryCeiling = (row) => SIGNER_METHODS.has(row.method) && row.expiresInSeconds !== void 0 && row.expiresInSeconds >= NEAR_MAX_EXPIRES_THRESHOLD_SECONDS;
|
|
7
|
+
const storagePresignedUrlForPrivateContent = {
|
|
8
|
+
categories: ["SECURITY"],
|
|
9
|
+
description: "`ctx.storage.getPresignedUrl(...)` mints a native S3 SigV4 URL that resolves directly against R2, bypassing the Worker's auth/RLS/rate-limit entirely — the wrong choice for private or policy-gated content. Either signer minting an `expiresInSeconds` near the shared 7-day ceiling also hands out a long-lived bearer credential.",
|
|
10
|
+
facing: "EXTERNAL",
|
|
11
|
+
level: "WARN",
|
|
12
|
+
name: "storage_presigned_url_for_private_content",
|
|
13
|
+
remediation: "For private/per-user/policy-gated content, use `getSignedUrl` (resolves back through the Worker, so your auth/RLS/rate-limit gates still run) instead of `getPresignedUrl`. Reserve `getPresignedUrl` for genuinely public or bulk content. On either signer, keep `expiresInSeconds` as short as the use case allows — well under the 7-day ceiling — rather than minting a near-maximum-lifetime URL.",
|
|
14
|
+
run: (context) => {
|
|
15
|
+
if (context.storageUploads === void 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return context.storageUploads.filter((row) => isNativePresignedCall(row) || isNearExpiryCeiling(row)).map((row) => {
|
|
19
|
+
const native = isNativePresignedCall(row);
|
|
20
|
+
const nearCeiling = isNearExpiryCeiling(row);
|
|
21
|
+
const location = `\`${row.exportName}\` (${row.file}:${row.line.toString()})`;
|
|
22
|
+
let detail;
|
|
23
|
+
if (native && nearCeiling) {
|
|
24
|
+
detail = `\`ctx.storage.getPresignedUrl\` in ${location} mints a native S3 SigV4 URL — bypasses the Worker's auth/RLS/rate-limit entirely — with an \`expiresInSeconds\` of ${(row.expiresInSeconds ?? 0).toString()}s, near the 7-day signing ceiling.`;
|
|
25
|
+
} else if (native) {
|
|
26
|
+
detail = `\`ctx.storage.getPresignedUrl\` in ${location} mints a native S3 SigV4 URL that resolves directly against R2, bypassing the Worker's auth/RLS/rate-limit entirely. Use \`getSignedUrl\` for app-gated access to private content.`;
|
|
27
|
+
} else {
|
|
28
|
+
detail = `\`ctx.storage.${row.method}\` in ${location} requests an \`expiresInSeconds\` of ${(row.expiresInSeconds ?? 0).toString()}s, near the 7-day signing ceiling — a leaked link stays valid for almost a week.`;
|
|
29
|
+
}
|
|
30
|
+
return emit(storagePresignedUrlForPrivateContent, {
|
|
31
|
+
cacheKey: `storage_presigned_url_for_private_content:${row.file}:${row.line.toString()}`,
|
|
32
|
+
detail,
|
|
33
|
+
metadata: {
|
|
34
|
+
expiresInSeconds: row.expiresInSeconds,
|
|
35
|
+
exportName: row.exportName,
|
|
36
|
+
file: row.file,
|
|
37
|
+
line: row.line,
|
|
38
|
+
method: row.method
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
source: "static",
|
|
44
|
+
title: "Native presigned URL or near-max-TTL signed URL for private content"
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { storagePresignedUrlForPrivateContent as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const UPLOAD_METHODS = /* @__PURE__ */ new Set(["store", "upload"]);
|
|
4
|
+
const storageUploadWithoutContentTypeAllowlist = {
|
|
5
|
+
categories: ["SECURITY"],
|
|
6
|
+
description: "A `ctx.storage.upload`/`store` call has no `allowedContentTypes` allowlist, so an uploader can store any content-type — including `text/html` or `image/svg+xml` — which, served back from `publicBaseUrl`, is a stored-XSS vector against your own origin.",
|
|
7
|
+
facing: "EXTERNAL",
|
|
8
|
+
level: "WARN",
|
|
9
|
+
name: "storage_upload_without_content_type_allowlist",
|
|
10
|
+
remediation: 'Pass `allowedContentTypes: ["image/png", "image/jpeg", …]` to `ctx.storage.upload`/`store` so an uploaded object\'s `contentType` must match an approved list. Reject anything HTML/SVG/script-executable unless the app genuinely needs to serve it.',
|
|
11
|
+
run: (context) => {
|
|
12
|
+
if (context.storageUploads === void 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return context.storageUploads.filter((row) => UPLOAD_METHODS.has(row.method) && row.analyzable && !row.presentKeys.includes("allowedContentTypes")).map(
|
|
16
|
+
(row) => emit(storageUploadWithoutContentTypeAllowlist, {
|
|
17
|
+
cacheKey: `storage_upload_without_content_type_allowlist:${row.file}:${row.line.toString()}`,
|
|
18
|
+
detail: `\`ctx.storage.${row.method}\` in \`${row.exportName}\` (${row.file}:${row.line.toString()}) has no \`allowedContentTypes\` allowlist — any content-type is accepted, including \`text/html\`/\`image/svg+xml\`, a stored-XSS risk if the object is served from \`publicBaseUrl\`.`,
|
|
19
|
+
metadata: { exportName: row.exportName, file: row.file, line: row.line, method: row.method }
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
source: "static",
|
|
24
|
+
title: "Storage upload with no content-type allowlist"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { storageUploadWithoutContentTypeAllowlist as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const UPLOAD_METHODS = /* @__PURE__ */ new Set(["store", "upload"]);
|
|
4
|
+
const storageUploadWithoutMaxSize = {
|
|
5
|
+
categories: ["SECURITY"],
|
|
6
|
+
description: "A `ctx.storage.upload`/`store` call has no `maxSize` cap, so a caller can push an unbounded body straight into R2 through the Worker — unbounded storage/billing exhaustion, and for a streamed body, unbounded worker time.",
|
|
7
|
+
facing: "EXTERNAL",
|
|
8
|
+
level: "WARN",
|
|
9
|
+
name: "storage_upload_without_max_size",
|
|
10
|
+
remediation: "Pass a `maxSize` (bytes) to `ctx.storage.upload`/`store` sized to the largest legitimate object the app accepts. `ArrayBuffer`/`Blob` bodies are rejected up front when oversized; a `ReadableStream` body is aborted mid-transfer once the limit is exceeded.",
|
|
11
|
+
run: (context) => {
|
|
12
|
+
if (context.storageUploads === void 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return context.storageUploads.filter((row) => UPLOAD_METHODS.has(row.method) && row.analyzable && !row.presentKeys.includes("maxSize")).map(
|
|
16
|
+
(row) => emit(storageUploadWithoutMaxSize, {
|
|
17
|
+
cacheKey: `storage_upload_without_max_size:${row.file}:${row.line.toString()}`,
|
|
18
|
+
detail: `\`ctx.storage.${row.method}\` in \`${row.exportName}\` (${row.file}:${row.line.toString()}) has no \`maxSize\` cap — a caller can push an unbounded body into R2, exhausting storage/billing.`,
|
|
19
|
+
metadata: { exportName: row.exportName, file: row.file, line: row.line, method: row.method }
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
source: "static",
|
|
24
|
+
title: "Storage upload with no size cap"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { storageUploadWithoutMaxSize as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { e as emit } from './finding-Dm_zvzS1.mjs';
|
|
2
|
+
|
|
3
|
+
const vectorsNamespaceFromUserInput = {
|
|
4
|
+
categories: ["SECURITY"],
|
|
5
|
+
description: "A `ctx.vectors.query`/`upsert`/`upsertMany` call uses a `namespace` derived from the handler's `args` with no server-side scoping. A Vectorize namespace partitions one index into isolated sub-collections, so an unscoped namespace lets any caller read or poison another tenant's vectors.",
|
|
6
|
+
facing: "EXTERNAL",
|
|
7
|
+
level: "WARN",
|
|
8
|
+
name: "vectors_namespace_from_user_input",
|
|
9
|
+
remediation: `Derive the \`namespace\` from a server-trusted identity (e.g. \`\${ctx.auth.orgId}\`), never from \`args\`.`,
|
|
10
|
+
run: (context) => {
|
|
11
|
+
if (context.vectorNamespaceAccesses === void 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return context.vectorNamespaceAccesses.map(
|
|
15
|
+
(access) => emit(vectorsNamespaceFromUserInput, {
|
|
16
|
+
cacheKey: `vectors_namespace_from_user_input:${access.file}:${access.line.toString()}`,
|
|
17
|
+
detail: `\`ctx.vectors.${access.method}\` in \`${access.exportName}\` (${access.file}:${access.line.toString()}) uses a Vectorize namespace derived from \`args\` with no server-side scoping — any caller can read or poison another tenant's vectors. Derive the namespace from a server-trusted identity (e.g. \`\${ctx.auth.orgId}\`), never from \`args\`.`,
|
|
18
|
+
metadata: { exportName: access.exportName, file: access.file, line: access.line, method: access.method }
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
source: "static",
|
|
23
|
+
title: "Vectorize namespace derived from unscoped user input"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { vectorsNamespaceFromUserInput as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/advisor",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.17",
|
|
4
4
|
"description": "Schema & query lints (splinter-style advisors) for Lunora, feeding the Studio Advisors view",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advisor",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/
|
|
49
|
+
"@lunora/errors": "1.0.0-alpha.1",
|
|
50
|
+
"@lunora/server": "1.0.0-alpha.15"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": "^22.15.0 || >=24.11.0"
|