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
2 changes: 1 addition & 1 deletion docs/incidents/bo_alarm_reads_its_evidence.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

**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.
**The guarantee:** The role stack's template (`CoderHelmLogReader`) has the WAF reads and a WAF log group (`WafLogs`): read-only Athena queries over the Glue tables on `aws-waf-logs-*` buckets, with results written only under the workgroup's own results location. 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 role stack's one-click update ([cw](./cw_role_reads_arrive_by_stack_update.md)); 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: 5 additions & 0 deletions docs/incidents/cw_role_reads_arrive_by_stack_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# cw. `cw_role_reads_arrive_by_stack_update`

**What happened:** AWS WAF alarm runs needed WAF, Athena and Glue reads on the WAF logs. They were first added to the CloudShell setup script (`coderhelm-read-waf`), with a one-line update shown as a setup item. Every team would have had to find and paste a script for each new read. The line patched a role CloudFormation had made, and it gave the reads to the data-source role `CoderhelmReadOnly`, while alarm runs read through `CoderHelmLogReader`. A release can't add a read by itself: CoderHelm's own roles may not change IAM.

**The guarantee:** Every read is declared in the role stack's one versioned template (`infra/cfn/coderhelm-log-reader.yaml`, published with each release), as named groups a stack parameter switches on: `WafLogs` (with `WafLogResults` and `WafLogKey`), `DatabaseClusters` and `Warehouses`. A WAF alarm run on an old role reads what it may and records what it was refused and what it found: the log bucket's KMS key and the workgroup's results location. It asks nobody. The install's one item, **AWS role reads**, is this release's one-click update of that stack, with those values filled in, which an AWS admin of the account creates. The same item names a role that is older than the release, and data sources the old script made. Those sources move onto the stack's role only after it reads them end to end. The data-source script no longer writes any permission: it creates or updates the role stack.
6 changes: 3 additions & 3 deletions docs/self-host/check-your-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ 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.
*If it warns:* A connected AWS account's role stack needs this release's update: a run was refused a read an alert route needed (such as the WAF log tables for a WAF alarm), the role is older than this release, or data sources still read through the older `CoderhelmReadOnly` role. Runs read what the role allows and go on without the rest; no run asks a person for it.\
*Fix:* The link opens CloudFormation's quick-create of this release's update stack on `CoderHelmLogReader`, with the account's groups and what CoderHelm found filled in. An AWS admin of that account reviews it and presses **Create stack**. The item clears once the role has the reads.

## The guided install

Expand Down Expand Up @@ -213,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`, `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.
`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 connected account's role stack needs this release's update; its `fix.url` is that account's one-click update stack. 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
28 changes: 18 additions & 10 deletions docs/self-host/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ 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.
- **One template for every read**\
Every read CoderHelm has in a team's account is declared in the role stack's one template, `coderhelm-log-reader.yaml`, published with each release (`launch/<version>/`). Reads that only some teams need are named groups, each switched on by a stack parameter. The update template next to it (`coderhelm-log-reader-update.yaml`) has the same groups and parameters:

| Group (parameter) | What it reads, and why |
|---|---|
| Logs, alarms, metrics, Airflow, ECS, the code behind a log group, AWS WAF requests, bucket and key settings (always) | Error lines, alarm states and metrics to find what broke; the tasks and tags behind a log group to find its repository; for a WAF alarm, the web ACL, the requests its rule matched (`wafv2:GetSampledRequests`) and where it logs. |
| WAF logs (`WafLogs`, `WafLogResults`, `WafLogKey`) | For a WAF alarm, what the web ACL logged to its `aws-waf-logs-*` bucket: the log objects, the Glue table definitions Athena needs (`glue:GetDatabases`, `GetDatabase`, `GetTables`, `GetTable`, `GetPartitions`) and the Athena workgroups' settings (`athena:ListWorkGroups`, `GetWorkGroup`). With `WafLogResults` (the WAF log workgroup's results location, `bucket/prefix/`) it runs read-only queries (`athena:StartQueryExecution`, `GetQueryExecution`, `GetQueryResults`, `StopQueryExecution`) and writes their results only there (`s3:PutObject`). With `WafLogKey` (the log bucket's customer-managed KMS key) it may `kms:Decrypt` with that key only through S3 (`kms:ViaService` `s3.*.amazonaws.com`). Writes anywhere but the results location, every change to WAF, Athena, Glue or a bucket, and Glue's connections are denied. |
| Databases (`DatabaseClusters`) | The Aurora PostgreSQL clusters named, through the RDS Data API, as the read-only user `coderhelm_readonly`, inside transactions that are rolled back (`CommitTransaction` is denied); only that user's password secret (`coderhelm-readonly-*`). |
| Warehouses (`Warehouses`) | The Redshift clusters named, signed in only as the passwordless read-only user `coderhelm_readonly`, one statement at a time, its own results only. |
| Knowledge bases, imports, copying into Bedrock, infrastructure versions, Inspector, Health, approved maintenance | Each named on the AWS page with its reason; knowledge bases and imports are in [Knowledge sources](./knowledge-sources.md). |

A WAF alarm on an alert route turns the WAF log group on for that account: the run reads the bucket's default encryption for `WafLogKey` and the workgroup's results location for `WafLogResults`, and every later update link carries them. Until the results location is known the group reads the logs' tables and settings and writes nothing; the next WAF alarm finds the location and the item offers the update that adds the queries.
- **Data sources: databases and warehouses**\
**Settings, Data sources, AWS** gives a script to paste into AWS CloudShell. It makes only what a stack can't: the read-only user inside the database or warehouse you pick (and the database user's password secret). Then it creates CoderHelm's role stack `CoderHelmLogReader`, or updates it to this release's template, naming that database in `DatabaseClusters` or that warehouse in `Warehouses` and keeping every other parameter as it was. The script never writes a permission on a role by itself. A role named `CoderHelmLogReader` that the stack didn't make is left alone, and the script says so.
- **Roles the older script made**\
Before this, the data-source script made a role named `CoderhelmReadOnly` and wrote its permissions by hand, so no release could reach it. Those connections keep working. The account's update link names every database and warehouse the team's data sources read there, and the **AWS role reads** item says how many still use the older role. Once an AWS admin creates that update, the daily permissions check tries each such source with the stack's role: the same database, user and secret. Only a source whose own connection check passes end to end (the role is taken on, the read-only user signs in, tables are listed) is switched; the rest stay on the older role and are tried again the next day. CoderHelm never changes or deletes `CoderhelmReadOnly`; delete it once no data source uses it.
- **How a release's new reads reach a team**\
A release can't add a read to a team's role by itself: CoderHelm's own roles have a permissions boundary that forbids changing IAM, so a person always approves a wider role. When a release changes the template, or an alert route or data source needs a group the role lacks, the install shows one setup item for the whole install, **AWS role reads** (`aws_role_reads` in Settings, then **Setup**). For each account it says why: a read a run was refused (for example `glue:GetDatabases` for a WAF alarm's logs), a role older than this release, or data sources still on the older role. Its link is the one-click update of that account's role (**Create stack** on `CoderHelmLogReaderUpdate-<id>`), from this release's template with the account's groups and what CoderHelm found filled in. An AWS admin of that account opens it signed in there, reviews it and creates it. Until then, runs read what the role allows, name the item in one line and go on: no run asks a person for access, and none waits on it. On a self-hosted install, the install's own account is no exception for these groups: WAF logs, databases and warehouses are read through the connected `CoderHelmLogReader` role there too, never through the install's gateway and worker roles, so the install's permission limit and its access stack don't grow for them.
- **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. `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).
- Roles in teams' AWS accounts are assumed only by name (`CoderHelmLogReader`, `CoderhelmReadOnly*`) and with an external id. Every read they have is declared in one template, `coderhelm-log-reader.yaml`, as named groups a stack parameter switches on (see [Integrations](./integrations.md#connected-aws-accounts)), and a release reaches a team's role only through the one-click update an AWS admin of that account creates: CoderHelm can't widen a team's role by itself. The WAF log group's one write is `s3:PutObject` for Athena query results, only under the results location the stack names and denied everywhere else; its `kms:Decrypt` is on the named key, only through S3. Roles named `CoderhelmReadOnly` were made by an older setup script; CoderHelm moves data sources off them once the stack's role reads them, and never changes them. 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
Loading
Loading