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
5 changes: 5 additions & 0 deletions docs/incidents/bo_alarm_reads_its_evidence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# bo. `bo_alarm_reads_its_evidence`

**What happened:** An alert route sends a WAF signature-drift alarm (a Count rule seeing crawler A get past a Block rule after it changed its JA4 or user agent) to the team's terraform repository, where the fix is a pull request that updates the block rule's match. The run ended `needs_input` with a long question asking a person to grant the team's read-only role WAF and Athena access, "Default if unanswered in 4 hours: Grant access". `wafv2:ListWebACLs` and `GetSampledRequests` were denied: the role's setup script never added any WAF read. The web ACL logs to an `aws-waf-logs-*` bucket with an Athena table, and nothing read it.

**The guarantee:** The role's setup script adds `coderhelm-read-waf`: WAF reads, and read-only Athena queries over the Glue tables on `aws-waf-logs-*` buckets, in the WAF log workgroups, with results written only under the workgroup's own results prefix. With those reads the run gathers the rule's matches before it plans (sampled requests, and the logs in S3 by JA4, JA3, user agent, accept language, path and cookie presence, over the last three hours) and goes on to its pull request. Without them the refusal is the install's one setup item, **AWS role reads**, with the one-line CloudShell update; the run names it in one line and goes on. The stop judge turns an ask or a hold for the role's reads into a proceed, the hand-back list doesn't carry it, and an access question never shows a default that can't happen.
5 changes: 4 additions & 1 deletion docs/self-host/check-your-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ The last result is kept in `.coderhelm/doctor.json`.

### Integrations

- **AWS role reads** (`aws_role_reads`, in the dashboard only)\
*If it warns:* A team's connected AWS role was refused a read an alert route needed, such as AWS WAF's sampled requests for a WAF alarm. Alarm runs read what the role allows and go on without the rest; no run asks a person for it.\
*Fix:* The one line to paste into AWS CloudShell in that account. It adds the read-only `coderhelm-read-waf` policy to the role and changes nothing else. The item clears the next time an alarm run reads with it.

## The guided install

Expand Down Expand Up @@ -210,7 +213,7 @@ Install admins (`admins` in the config) who are team admins can call these while
}
```

`status` is `pass`, `warn`, `fail` or `skip` (an optional integration that isn't set up). `fix` has `text` and any of `command` (to copy), `url` (outside CoderHelm) and `href` (a dashboard page). `ready` is true when nothing fails. Keys: `url`, `domain`, `github_keys`, `github_app`, `github_permissions`, `github_workflow_starts`, `github_installations`, `github_webhook`, `github_sign_in`, `email_sender`, `email_identity`, `email_sandbox`, `email_cognito`, `model`, `dlq`, `updates`, `slack`, `teams`, `jira`, `aws_connections`. A self-hosted install has no Google sign-in, so there is no `google_sign_in` check. On an install that uses CoderHelm's GitHub App (hybrid), `github_app` and `github_installations` say whether the app is linked instead, and never block an update. `github_sign_in` passes when the install's own GitHub App has its OAuth client id and secret stored, or when the install has neither and is registered with CoderHelm (GitHub sign-in then goes through CoderHelm's app, [Sign in with GitHub through CoderHelm](./hybrid.md#sign-in-with-github-through-coderhelm)). It warns when only one of the two is stored, when the install's own app has neither, and when an install on CoderHelm's GitHub App isn't registered yet: the sign-in page doesn't offer Continue with GitHub until then. It never blocks an update.
`status` is `pass`, `warn`, `fail` or `skip` (an optional integration that isn't set up). `fix` has `text` and any of `command` (to copy), `url` (outside CoderHelm) and `href` (a dashboard page). `ready` is true when nothing fails. Keys: `url`, `domain`, `github_keys`, `github_app`, `github_permissions`, `github_workflow_starts`, `github_installations`, `github_webhook`, `github_sign_in`, `email_sender`, `email_identity`, `email_sandbox`, `email_cognito`, `model`, `dlq`, `updates`, `slack`, `teams`, `jira`, `aws_connections`, `aws_role_reads`. `aws_role_reads` warns, and never blocks an update, while a team's connected AWS role lacks a read an alert route used; its `fix.command` is the one-line CloudShell update. A self-hosted install has no Google sign-in, so there is no `google_sign_in` check. On an install that uses CoderHelm's GitHub App (hybrid), `github_app` and `github_installations` say whether the app is linked instead, and never block an update. `github_sign_in` passes when the install's own GitHub App has its OAuth client id and secret stored, or when the install has neither and is registered with CoderHelm (GitHub sign-in then goes through CoderHelm's app, [Sign in with GitHub through CoderHelm](./hybrid.md#sign-in-with-github-through-coderhelm)). It warns when only one of the two is stored, when the install's own app has neither, and when an install on CoderHelm's GitHub App isn't registered yet: the sign-in page doesn't offer Continue with GitHub until then. It never blocks an update.

### `GET /api/system/domain`, `PUT /api/system/domain`, `DELETE /api/system/domain`

Expand Down
10 changes: 10 additions & 0 deletions docs/self-host/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Teams connect their own AWS accounts so CoderHelm can read CloudWatch logs, alar
Connect it the same way: the `CoderHelmLogReader` role there, with the team's External ID, proves the team may read it. After that, the install reads its own account with its gateway's and worker's own roles, which the install's stack gives this release's read-only permissions (`infra/lib/own-account-read.ts`, the same list as the update template). Each version update brings any new permission, so the install's own account never shows **Update in AWS**; if a permission is still missing, the page says it comes with the next version update.
- **When a release needs new permissions**\
Each AWS connection shows **Permissions up to date** or **Update needed: N new read-only permissions**. The check runs live: it asks IAM's policy simulator about the role (`iam:SimulatePrincipalPolicy` on that one role), or, for roles made before that, tries the cheapest read of each kind. **Update in AWS** opens a stack (`CoderHelmLogReaderUpdate-<id>`) that adds exactly this release's permissions to the existing role. Sign in to the role's account, review it and press **Create stack**. When you come back, the page checks again by itself. If something went wrong, it names the reason and the fix: the stack failed, it isn't in the role's account, a permissions boundary or an organization policy (SCP) blocks the permissions. Once a day the install checks every account, and each team's Slack or Teams channel hears once per release that needs an update. Until then, features that need a missing permission say so where they are used, skip that step and keep working with the rest.
- **The data-source role, and AWS WAF alarms**\
AWS data sources (databases, warehouses) use the read-only role `CoderhelmReadOnly`, made by the setup script a team pastes into AWS CloudShell from **Settings, Data sources, AWS**. The script also gives it `coderhelm-read-waf`, so a run an alert rule starts for an AWS WAF alarm can read what the alarm's rule matched:
- `wafv2:Get*` and `wafv2:List*`: web ACLs, sampled requests, where a web ACL logs;
- `s3:GetObject`, `s3:ListBucket` and `s3:GetBucketLocation` on `aws-waf-logs-*` buckets only;
- when the account has an Athena workgroup with `waf` in its name (with a results location) and a Glue table on an `aws-waf-logs-*` bucket, in the region the script runs in: `glue:Get*` on those databases and tables, `athena:StartQueryExecution`, `athena:Get*` and `athena:StopQueryExecution` in those workgroups, and `s3:PutObject` only under each workgroup's own results prefix;
- every change to WAF, Athena, Glue or a bucket, Glue's connections, and any object written outside the results prefix are denied.

A web ACL that logs to S3 is read with one Athena query: the alarm's rule only, the last three hours (bounded by the table's projected date partition, or by the workgroup's scan limit; with neither the bucket isn't queried), counted by JA4, JA3, user agent, accept language, path and whether a cookie was sent. No client address, cookie or other header value is selected.
- **When a role lacks a read an alert route needs**\
It is one setup item for the whole install, **AWS role reads** (`aws_role_reads` in Settings, then **Setup**), with one line to paste into AWS CloudShell in the role's account. The line adds `coderhelm-read-waf` to the existing role and changes nothing else. Until then, alarm runs read what the role allows, name the item in one line and go on to the pull request they can justify: no run asks a person for access, and none waits on it.
- **Alert routes (SNS)**\
**Settings, Alerts** shows the subscription endpoint, `https://coderhelm.example.com/webhooks/alerts/sns`. Save and turn on the route before you subscribe the topic: CoderHelm only confirms subscriptions for topics with a route that's on. If you subscribed first, press **Request confirmation** on the subscription in SNS. Every message's signature is checked before anything else.
- **Alarms that keep firing**\
Expand Down
2 changes: 1 addition & 1 deletion docs/self-host/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ order: 11

- Each function has its own role with only the tables, queues, keys and actions it uses.
- The build sandbox runs a repository's own build scripts, which are untrusted: its CodeBuild role can only read and write one bucket of short-lived source tarballs and write its logs. No GitHub token, no tables, no KMS.
- Roles in teams' AWS accounts are assumed only by name (`CoderHelmLogReader`, `CoderhelmReadOnly*`) and with an external id. When the data is in the install's own account, see the exception in [The permissions boundary](#the-permissions-boundary).
- Roles in teams' AWS accounts are assumed only by name (`CoderHelmLogReader`, `CoderhelmReadOnly*`) and with an external id. `CoderhelmReadOnly`'s one write is `s3:PutObject` for Athena query results, held by an explicit deny to the WAF log workgroup's own results prefix (see [Integrations](./integrations.md#connected-aws-accounts)). When the data is in the install's own account, see the exception in [The permissions boundary](#the-permissions-boundary).
- An install made with Launch Stack holds no broad standing rights in your account: see [What an install can do in your account](#what-an-install-can-do-in-your-account).

## What an install can do in your account
Expand Down
50 changes: 50 additions & 0 deletions services/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions services/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ aws-sdk-cloudwatchlogs = { version = "1", default-features = false, features = [
aws-sdk-cloudwatch = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# alarm_evidence: what an AWS WAF alarm's rule matched (sampled requests, read-only)
aws-sdk-wafv2 = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# alarm_evidence: a web ACL's logs held in S3, read through its Athena table (read-only query)
aws-sdk-athena = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-glue = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
# log_repo: which repo a log group's code lives in (read-only lookups)
aws-sdk-ecs = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
aws-sdk-lambda = { version = "1", default-features = false, features = ["default-https-client", "rt-tokio"] }
Expand Down
Loading
Loading