# Pull a kill switch

Take a route offline, serve the private network only, or scale an app to zero while a vulnerability is fixed.

A kill switch stops an app from serving part or all of its traffic until you release it. Use one
for the hours between "a vulnerability in this app is being exploited" and "the fixed version is
live". A switch reduces exposure; it is not the fix.

| Switch          | What it does                                                                                                                                       |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `route_offline` | One hostname, or one path prefix (`/admin`) on every hostname, answers `503` with `Retry-After`. The rest of the app keeps serving.                |
| `private_only`  | Only private-network sources (your VPC, a VPN) are served; public requests get `403`. Behind the app's load balancer, the balancer is refused too. |
| `scale_to_zero` | Every container stops. The machines stay on and are billed, so releasing the switch starts the app again within a minute.                          |

A switch takes effect on the machines' next check-in, within seconds. It stays through deploys,
setting changes and Terraform applies, and only a person releasing it ends it. While an app is
scaled to zero, a deployment is refused (a push to a deploy-on-push branch does not deploy) until
the switch is released.

## Prerequisites

- `deploy:ApplyKillSwitch` to pull a switch and `deploy:ReleaseKillSwitch` to release one, on the
  app. Neither needs `deploy:UpdateApp`, so an on-call responder can hold just these.
- `deploy:ListKillSwitches` to see them, and in the console `deploy:DescribeApp` to open the app.

## Pull a switch

**Console**
1. Open the app, then the **Kill switches** tab. From a Security Posture finding "Contains a
   known-exploited vulnerability", the section for the apps running the image offers the same for
   each app that runs the image.
2. Choose **Pull a kill switch**, pick the switch, for **Take a route offline** the hostname or a
   path, and give a reason.
3. Choose **Pull kill switch**. The app's header shows a red banner while any switch is active.

**CLI**
```sh
dcloud deploy kill-switches apply app-id --kind route_offline --target /admin --reason "CVE-2025-29927, fix in progress"
dcloud deploy kill-switches apply app-id --kind scale_to_zero --reason "exploited, waiting for the fix"
```

**API**
```http
POST /deploy/api/apps/app-id/kill-switches
Content-Type: application/json

{ "kind": "private_only", "reason": "CVE-2025-29927, fix in progress" }
```

The answer is `201` with the switch, or `200` with the same switch when it was already active.

## Release it

**Console**
On the **Kill switches** tab, choose **Release** beside the switch.

**CLI**
```sh
dcloud deploy kill-switches list app-id
dcloud deploy kill-switches release switch-id
```

**API**
```http
DELETE /deploy/api/kill-switches/switch-id
```

## Limits

- On pooled hosting there is no private network: `private_only` and path targets are refused
  (`409`). A hostname taken offline answers `404`, and scaled to zero no hostname is served; the
  running server stops after its idle time.
- `private_only` is checked per request: a public client still completes the TLS handshake before
  it gets `403`.
- Every pull and release is in the audit log under the person's name, and in the app's activity.

## Related

- [Scale an app](scale-an-app.md)
- `deploy.kill-switches.apply` · `dcloud deploy kill-switches apply`
