Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions docs/guide/platform/administration/security-audits.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void platform security budget --platform-usd 500
void platform security policy public
```

`probe` tells you which requirements your account meets and what you still need to configure. Spending caps are off by default. When you enable a scan mode, the probe must pass. Void checks again daily. If a later check fails, the administrator UI shows a banner and scans pause until the account is ready again.
`probe` tells you which requirements your account meets and what you still need to configure. Monthly spending caps are off by default. When you enable a scan mode, the probe must pass. Void checks again daily. If a later check fails, the administrator UI shows a banner and scans pause until the account is ready again.

| Mode | Scans |
| -------------------- | --------------------------------------------------------------- |
Expand Down Expand Up @@ -67,7 +67,7 @@ To check a change before you deploy it, run this from the app’s directory:
void project security check
```

The CLI lists the files it will upload, the model that will review them, and the maximum cost. It includes your current edits to Git-tracked files and skips untracked files, secret-like files, lockfiles, and binaries. Confirm to queue the check.
The CLI lists the files it will upload, the model that will review them, and the [scan’s spend limit](#scan-spend-limit). It includes your current edits to Git-tracked files and skips untracked files, secret-like files, lockfiles, and binaries. Confirm to queue the check.

Anyone with deploy access can run a check on a project covered by the scan policy. It counts toward the same spending caps as a deploy scan. Read the result in the terminal now, or look it up by its check ID for up to 30 days. A local check doesn’t update project findings, send email, or change a request to go public. See [project security commands](../../../reference/cli/project.md#void-project-security).

Expand Down Expand Up @@ -152,7 +152,7 @@ These scans review more than a deploy scan. Each costs money and counts toward t
| Review every live app in full on a schedule | `void platform security sweeps on --every-days 30` | Platform administrators |
| Scan again on Cloudflare when a third-party model fails | `void platform security fallback on` | Platform administrators |

A full scan names its model and the most it can cost, then asks first. Add `--client-assets` to also review the client bundles' sources, from the source maps deployed with them. Backfill handles up to 50 projects at a time; run it again for the rest. Only a few sweeps start each hour, so deploy scans keep moving. Fallback scans the same changes once more on the default `@cf` model when a third-party model refuses, times out, or returns unreadable output; it never sends code from a `@cf` scan to a third party. Sweeps and fallback are off by default. A deployment whose code is no longer stored cannot be scanned again until the project deploys. See [Findings and scans](/reference/cli/platform-security#findings-scans).
A full scan names its model and its [spend limit](#scan-spend-limit), then asks first. Add `--client-assets` to also review the client bundles' sources, from the source maps deployed with them. Backfill handles up to 50 projects at a time; run it again for the rest. Only a few sweeps start each hour, so deploy scans keep moving. Fallback scans the same changes once more on the default `@cf` model when a third-party model refuses, times out, or returns unreadable output; it never sends code from a `@cf` scan to a third party. Sweeps and fallback are off by default. A deployment whose code is no longer stored cannot be scanned again until the project deploys. See [Findings and scans](/reference/cli/platform-security#findings-scans).

## GitHub checks {#github-checks}

Expand All @@ -173,10 +173,33 @@ void platform config plans set pro --security-cap 200

A Pro project can now use up to $200 of the shared $500 budget. A project-specific limit takes precedence over the owner’s plan, followed by the default project cap. An owner or project admin can choose a lower limit for their own project. Plan caps apply even when default project caps are off. Set a plan’s `--security-cap` to `none` to remove its cap or `inherit` to use the default. See [Security scan cap](./plans.md#security-scan-cap).

Void starts a scan only if its maximum cost fits both the project and platform budgets. All scans, including rescans and scans before going public, count toward these budgets. Deployments continue when a cap is reached. The first scan after you raise the cap or the calendar month resets (UTC) includes the skipped changes.
All scans, including rescans and scans before going public, count toward these budgets, which reset each calendar month (UTC). A monthly cap can skip or stop a scan while deploys continue. When scanning resumes, the next scan reviews changes since the last successful scan, or the whole app if there isn’t one to compare with.

Both caps are off by default. The platform pays for scans separately from a plan’s AI usage. On the **Scans** page, you can compare the metered cost with the cost AI Gateway reports about an hour later. Project owners and admins receive email when a project reaches 80% and 100% of its cap. Platform admins receive the same alerts for the platform cap, once per threshold each month.

### Scan spend limit {#scan-spend-limit}

Every scan has a spend limit, including when monthly caps are off. To start a scan, Void reserves that amount against the monthly caps that apply. Commands that start scans show it as the estimated cost.

Before each model call, Void estimates what the call costs. If that is more than what is left of the limit, Void refuses the call. The scan ends as incomplete (spend limit reached) and keeps the findings it has confirmed. A call can cost more than its estimate, so a scan can go a little over its limit.

Spending counts cached input at the model's cached price. Only DeepSeek and GLM have one. For the other models, cached input counts at full price.

By default, the limit is the model's list price for the smaller of the input-token limit and 1.2 million tokens, plus the output-token limit. With the default token settings this is $0.504 for DeepSeek, $2.208 for GLM and $7.20 for Opus. The input-token limit counts cached input in full and defaults to 10 million. To set one limit for every model, from $0.01 to $12:

```sh
void platform security limits --scan-usd 2.50
void platform security limits --scan-usd auto # back to the default
```

Turning scans on saves the token limits, and upgrading doesn't change saved values. An installation that turned scans on when the default was 1.2 million input tokens keeps that limit until you raise it:

```sh
void platform security limits --scan-input-tokens 10000000
```

A saved input-token limit above 1.2 million no longer raises the default spend limit. For example, a DeepSeek policy with 2 million input tokens and the default output limit goes from $0.744 to $0.504. Set `--scan-usd` to keep a higher limit.

## Emails

| Email | Sent to |
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/cli/platform-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ The `never` rule skips deploy scans, rescans, sweeps, backfill, and local checks
```sh
void platform security models [--default <id>] [--block <id,...>] [--unblock <id,...>] [--accept-provider-notice] [--plan] [--yes]
void platform security models --provider <openai|anthropic> (--key-stdin | --remove-key) [--plan] [--yes]
void platform security limits [--concurrency <n>] [--scan-timeout <minutes>] [--plan] [--yes]
void platform security limits [--concurrency <n>] [--scan-timeout <minutes>] [--scan-input-tokens <n>] [--scan-usd <usd|auto>] [--plan] [--yes]
void platform security budget [--platform-usd <n> | --platform-off] [--project-default-usd <n> | --project-caps <on|off>] [--plan] [--yes]
void platform security budget --project <project-id> (--usd <n> | --clear) [--plan] [--yes]
void platform security model <project-id> <model-id|--default> [--accept-provider-notice] [--plan] [--yes]
```

**Models.** Accept the provider notice with `--accept-provider-notice` when choosing a third-party model. To bill your own OpenAI or Anthropic account, pipe the key from your password manager to `models --provider <name> --key-stdin --yes`. Void saves it after a successful test call. Use `--remove-key` to switch back. See [Use your own provider key](/guide/platform/administration/security-audits#own-provider-key).

**Scan limits.** Set `--concurrency` to the number of scans the platform can run at once. Each Cloudflare model runs one scan at a time, so additional slots can serve different models. Set `--scan-timeout` in minutes.
**Scan limits.** Set `--concurrency` to the number of scans the platform can run at once. Each Cloudflare model runs one scan at a time, so additional slots can serve different models. Set `--scan-timeout` in minutes. `--scan-input-tokens` caps the input tokens one scan may send, cached ones included. `--scan-usd` sets the [spend limit](/guide/platform/administration/security-audits#scan-spend-limit) of every scan; `auto` prices it from the token limits.

**Budget.** Run `void platform security budget` to see this month’s spend and caps. Use `--platform-usd` to enable a platform cap or `--project-default-usd` to enable default project caps. Turn off the default with `--project-caps off`.

Expand All @@ -77,9 +77,9 @@ Use `--page` and `--limit` (up to 100) to page through findings, oldest first. F

To update several findings together, separate their IDs with commas. Void checks every ID before applying the change.

`rescan` runs a full scan of the live deployment. It tells you which model it uses and the most it can cost, then asks before it starts. Monthly caps apply to rescans too. `--client-assets` also reviews the sources of the project's client bundles from the source maps deployed with them. Project admins can start the same scan with `void project security scan`.
`rescan` runs a full scan of the live deployment. It tells you which model it uses and the [scan's spend limit](/guide/platform/administration/security-audits#scan-spend-limit), then asks before it starts. Monthly caps apply to rescans too. `--client-assets` also reviews the sources of the project's client bundles from the source maps deployed with them. Project admins can start the same scan with `void project security scan`.

Turning security audits on scans nothing that is already live. `backfill` scans each live deployment in scope that has never been scanned, up to 50 projects at a time; run it again for the rest. `--plan` shows how many projects it reaches and the most the scans can cost. A deployment whose code is no longer stored cannot be scanned; the preview counts these, and the next deploy of each project scans it.
Turning security audits on scans nothing that is already live. `backfill` scans each live deployment in scope that has never been scanned, up to 50 projects at a time; run it again for the rest. `--plan` shows how many projects it reaches and the total of the scans' spend limits. A deployment whose code is no longer stored cannot be scanned; the preview counts these, and the next deploy of each project scans it.

`sweeps on` reviews every live app in full on a schedule, with a deeper review than a deploy scan: a project is swept when it has had no full scan for `--every-days` days (7 to 90, default 30). A few sweeps start each hour, so deploy scans keep moving. Projects whose live code is no longer stored are not swept until they deploy again. Sweeps are off by default; each one costs more than a deploy scan, and the monthly caps apply.

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/cli/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void project security check
void project security scan
```

Both commands name the model and maximum cost before you confirm. Pass `--yes` with `--json` or in a non-interactive shell. Monthly caps apply.
Both commands name the model and its estimated cost, the [scan’s spend limit](/guide/platform/administration/security-audits#scan-spend-limit), before you confirm. Pass `--yes` with `--json` or in a non-interactive shell. Monthly caps apply.

- **Local changes.** `check` lists the Git-tracked files it will send, including uncommitted edits. Untracked files, secret-like files such as `.env*`, keys and `.npmrc`, lockfiles, binaries, and media stay local. The limit is 10,000 files and 32 MB per check. For a larger repository, run it in the app’s subdirectory.
- **Live deployment.** Add `--client-assets` to review the original sources of browser bundles. Deploy the source map next to the bundle (for example, `app.js.map`) or reference it with `sourceMappingURL`. Without a map, Void reviews the bundle. Sending the additional code can increase the cost.
Expand Down
17 changes: 13 additions & 4 deletions packages/platform/src/security-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const SECURITY_PROVIDER_NAMES: Readonly<Record<SecurityModelHost, string>
*/
export const SECURITY_PROVIDER_NOTICE_VERSION = 1;

/** Token counts a scan reserve is computed from when no limits are given (spec §16.1). */
/** Input token ceiling for pricing the automatic scan reserve. */
export const SECURITY_RESERVE_INPUT_TOKENS = 1_200_000;
export const SECURITY_RESERVE_OUTPUT_TOKENS = 120_000;

Expand Down Expand Up @@ -220,15 +220,24 @@ export function securityModelCostUsd(
return nano === null ? null : nano / 1_000_000_000;
}

/** Worst-case cost of one scan, reserved against the caps at start (spec §16.1). */
/** The amount reserved at scan start in USD, or `null` for an unpriced model. */
export function securityScanReserveUsd(
id: SecurityModelId,
limits: Readonly<{ maxInputTokens: number; maxOutputTokens: number }> = {
limits: Readonly<{
maxInputTokens: number;
maxOutputTokens: number;
maxScanUsd?: number | null;
}> = {
maxInputTokens: SECURITY_RESERVE_INPUT_TOKENS,
maxOutputTokens: SECURITY_RESERVE_OUTPUT_TOKENS,
},
): number | null {
return securityModelCostUsd(id, limits.maxInputTokens, limits.maxOutputTokens);
const defaultUsd = securityModelCostUsd(
id,
Math.min(limits.maxInputTokens, SECURITY_RESERVE_INPUT_TOKENS),
limits.maxOutputTokens,
);
return defaultUsd === null ? null : (limits.maxScanUsd ?? defaultUsd);
}

/**
Expand Down
41 changes: 36 additions & 5 deletions packages/platform/src/security-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,30 @@ export type SecurityLimitRange = Readonly<{ min: number; max: number; default: n

/**
* Allowed whole-number range and default of every limit. Concurrency and timeout come
* from the spec. The token and call ranges are ours: at their top, the most expensive
* priced model reserves $12 per scan.
* from the spec. The input token cap counts every input token, cached or not. The
* per-scan spend limit (`maxScanUsd`) is separate: see `SECURITY_SCAN_USD_RANGE`.
*/
export const SECURITY_LIMIT_RANGES = {
/** Running scans per installation. */
concurrency: { min: 1, max: 10, default: 2 },
/** Wall clock per scan, the only timeout setting. */
timeoutMinutes: { min: 5, max: 60, default: 20 },
maxInputTokens: { min: 50_000, max: 2_000_000, default: 1_200_000 },
maxInputTokens: { min: 50_000, max: 20_000_000, default: 10_000_000 },
maxOutputTokens: { min: 5000, max: 200_000, default: 120_000 },
modelCallsPerScan: { min: 10, max: 200, default: 80 },
} as const;

/** Allowed per-scan spend limit (`maxScanUsd`) in USD, whole cents. */
export const SECURITY_SCAN_USD_RANGE = { min: 0.01, max: 12 } as const;

/** The whole-number limits. Each has a range in `SECURITY_LIMIT_RANGES`. */
export type SecurityLimitKey = keyof typeof SECURITY_LIMIT_RANGES;
export type SecurityPolicyLimits = Readonly<Record<SecurityLimitKey, number>>;
export type SecurityPolicyLimits = Readonly<
Record<SecurityLimitKey, number> & {
/** Per-scan spend limit in USD. `null` or missing: priced from the token limits. */
maxScanUsd?: number | null;
}
>;

export const SECURITY_LIMIT_KEYS: ReadonlyArray<SecurityLimitKey> = [
'concurrency',
Expand Down Expand Up @@ -282,14 +291,19 @@ function limitsFrom(value: unknown, strict: boolean): SecurityPolicyLimits {
maxInputTokens: read('maxInputTokens'),
maxOutputTokens: read('maxOutputTokens'),
modelCallsPerScan: read('modelCallsPerScan'),
maxScanUsd: scanUsd(input.maxScanUsd ?? null, strict),
};
}

/** A change to some limits. Unknown keys are refused so a typo is not silently ignored. */
export function parseSecurityLimitsPatch(value: unknown): Partial<SecurityPolicyLimits> {
const input = record(value, 'Security limits');
const patch: Partial<Record<SecurityLimitKey, number>> = {};
const patch: { -readonly [K in keyof SecurityPolicyLimits]?: SecurityPolicyLimits[K] } = {};
for (const [key, limit] of Object.entries(input)) {
if (key === 'maxScanUsd') {
patch.maxScanUsd = scanUsd(limit ?? null, true);
continue;
}
const known = SECURITY_LIMIT_KEYS.find((candidate) => candidate === key);
if (!known) {
throw new Error(`Unknown security limit: ${key}.`);
Expand All @@ -299,6 +313,23 @@ export function parseSecurityLimitsPatch(value: unknown): Partial<SecurityPolicy
return patch;
}

/** `maxScanUsd`: `null`, or whole cents in range. The lenient reader clamps and rounds. */
function scanUsd(value: unknown, strict: boolean): number | null {
if (value === null) {
return null;
}
const { min, max } = SECURITY_SCAN_USD_RANGE;
if (typeof value === 'number' && Number.isFinite(value)) {
const amount = Math.round(Math.min(max, Math.max(min, value)) * 100) / 100;
if (!strict || amount === value) {
return amount;
}
}
throw new Error(
`maxScanUsd must be null or a USD amount from ${min} to ${max} with at most two decimals.`,
);
}

/** A USD amount for a monthly cap: 0 to `SECURITY_MAX_MONTHLY_USD`, whole cents. */
export function parseSecurityUsd(value: unknown, label: string): number {
if (
Expand Down
Loading