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

**What happened:** The owner of a self-hosted install got a push alert in their team's channel: "AWS account (the install's own account) needs 1 new read-only permission. This CoderHelm release reads a little more from your AWS accounts... Until an admin updates the CoderHelmLogReader role, the parts that need it are skipped." The account was the install's own. The daily sweep (`passes::aws_permissions`) skipped the install's own account only when the check's `install_account` was true, but the check's builder always wrote false; only tests ever set it. So that account was treated like any other: the alert went out, and the AWS page offered the one-click update stack for it. And since every team read is made as the account's `CoderHelmLogReader` (case `rk`), that role in the install's own account really did fall behind each release: nothing in the release updated it.

**The guarantee:**
- No push alert for new read-only permissions, ever: the daily sweep only checks every account and saves the result for the AWS page. Its told and claim records and the message are gone.
- Another account shows it only as the AWS page's quiet item, **Update needed**, with its one-click update stack, and as the install's **AWS role reads** setup item.
- The install's own account on a one-stack install is marked by the check's own builder (`PermissionCheck::new`, from the install's read role and `INSTALL_READER_KEPT`). It gets no update stack, no setup item, and the page says it updates with the release.
- The release brings the reads itself: the access stack's reader update (`lambda/native-reader`, `infra/lib/native/access-stack.ts`) runs after each update of the install's stack, once a day, and when an admin applies the access stack. It creates or updates `CoderHelmLogReaderUpdate-release` from the running release's published update template, with read-only groups only. Its role may do only that, only from that template, and may write only that role's policy, only through CloudFormation.
- An access stack made before the reader update asks an AWS admin once (Settings, System, Permissions). From then on, no release needs anyone for that role's reads.

**Test:** `services/worker/src/passes/incidents/rq_reader_reads_arrive_with_the_release.rs`
6 changes: 3 additions & 3 deletions docs/self-host/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Teams connect their own AWS accounts so CoderHelm can read CloudWatch logs, alar
- **Making the role by hand**\
The AWS page lists every action the role needs, grouped by what CoderHelm reads with it, and your install's account id. Create the role named `CoderHelmLogReader`, let your install's account assume it only with the team's External ID, and allow those actions.
- **Reading the install's own account**\
Connect it the same way: the `CoderHelmLogReader` role there, with the team's External ID. Every read of the account (logs, metrics, WAF, settings and the rest) is made as that role, exactly as in any other account, so AWS records every read under the team's role and the permission check looks at the same role. When a release adds a read, the account shows **Update in AWS** like any other. Knowledge bases in the install's account are the one exception: the install's own role searches them (see [bedrock.md](bedrock.md)).
Connect it the same way: the `CoderHelmLogReader` role there, with the team's External ID. Every read of the account (logs, metrics, WAF, settings and the rest) is made as that role, exactly as in any other account, so AWS records every read under the team's role and the permission check looks at the same role. When a release adds a read, a one-stack install (Launch Stack) brings it to that role by itself: its access stack's reader update runs after each update of the install's stack, and creates or updates the stack `CoderHelmLogReaderUpdate-release` from that release's update template, with the read-only groups only (see [security.md](security.md#the-reader-update)). So the account shows **Updates with the release** and nothing to do: no **Update in AWS**, no setup item. An install from the CLI has no reader update, so there its own account shows **Update in AWS** like any other. Knowledge bases in the install's account are the one exception: the install's own role searches them (see [bedrock.md](bedrock.md)).
- **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.
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 again. None of this is ever sent to Slack, Teams or email: it is only the account's line on the AWS page and the **AWS role reads** setup item. Until the role is updated, features that need a missing permission say so where they are used, skip that step and keep working with the rest.
- **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:

Expand All @@ -41,7 +41,7 @@ Teams connect their own AWS accounts so CoderHelm can read CloudWatch logs, alar
- **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.
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. The one exception is the install's own account on a one-stack install, where the access stack an AWS admin applied does it after each update (the reader update), with this release's read-only groups only; the groups a team chose there (knowledge bases, imports, WAF logs, databases, warehouses) still come from the team's own update stack. 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
15 changes: 14 additions & 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. 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).
- 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 one exception is `CoderHelmLogReader` in a one-stack install's own account, which the access stack an AWS admin applied brings up to each release's read-only groups ([The reader update](#the-reader-update)). 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 Expand Up @@ -148,6 +148,19 @@ It can't choose the code: only a published release's template. It does choose th

**What CoderHelm never applies.** A change set that changes the deploy role or either boundary: the boundary forbids the role to change those (that is what keeps it from giving itself more), and nothing else in the install may. Executing such a change set in the CloudFormation console doesn't get around it either: the stack's service role is the deploy role, so AWS runs it as that role whoever presses Execute (and its rollback fails the same way). So no update changes them: the parent template carries them exactly as installs have them, every update keeps the install's own copies, and the updater checks every IAM call a prepared update needs, and the EC2 and log calls CloudFormation makes for a private network's security group, function and log group, against the deploy role before it runs. When the deploy role is behind (its access stack is at an older release than the one running), such an update never starts: it says to apply the access stack update first, and Settings, System, Permissions shows it as needed. Newer documents for them ship in each release's signed `access.json`, which someone with administrator rights applies with their own permissions as the stack `coderhelm-<name>-access`: created once, then updated in place with each newer release's `access.json`, never deleted and made again (Settings, System, Permissions; [Updates](./updates.md#permissions)). CoderHelm asks for it only when what is new matters to something the install uses: a read that only one switch of the AWS card uses counts only while that switch is on. Its writer function and role are named `CoderHelmAccess-<name>`, outside the install's names, so no CoderHelm role can invoke, pass or change them, and no CoderHelm role may create, change or delete that stack (`TheAccessStackStays`). Letting CoderHelm apply these would need a role that can rewrite the deploy role's boundary, which is a role that can give itself anything: so there is none.

### The reader update

Every read of a team's data in the install's own account is made as the team's `CoderHelmLogReader` role there, and the install's own roles may never change IAM. So the same access stack carries one more function, `CoderHelmReader-<name>` (lambda/native-reader), which brings each release's read-only permissions to that role with no step of anyone's:

- it runs when the install's stack finishes an update (CloudFormation's stack status event: a version update or a switch of the AWS card), once a day, and when an admin creates or updates the access stack;
- when the role `CoderHelmLogReader` exists in the account, it creates or updates one stack, `CoderHelmLogReaderUpdate-release`, from the running release's published update template (`https://coderhelm-public.s3.amazonaws.com/launch/<version>/coderhelm-log-reader-update.yaml`), the same template every **Update in AWS** link opens;
- with read-only groups only: the three switches of the AWS card as the install's stack has them, and every other parameter empty or off. It never names a knowledge base, a bucket, WAF logs, a database or a warehouse, never copies into Bedrock and never turns on database maintenance; a team's choices there stay on its own update stacks;
- its role may create and update only that stack, and only from a release's update template (`cloudformation:TemplateUrl`); it may write only that role's inline policies, and only through CloudFormation (`aws:CalledVia`); its other calls are reads (the install's stack, the role, a template's parameters) and its own log;
- like the writer it is named outside the install's names, so no CoderHelm role can invoke, pass or change it, and it never reads the event it is sent;
- deleting the access stack leaves `CoderHelmLogReaderUpdate-release` in place.

An access stack made before the reader update asks for it once (Settings, System, Permissions: "adds the reader update"). An install from the CLI has none, so its own account's role is updated like any other account's.

- Only CloudFormation can assume it, only for this account (`aws:SourceAccount`) and only for this stack and its parts (`aws:SourceArn`).
- It carries the boundary (its own copy, kept with it).
- Its policy is the deploy policy from `infra/lib/access.ts`, plus every CloudFormation action on the parent stack and its parts, reading the release bucket, reading and updating (never deleting) the install's secret, and the install guide's progress bucket. `infra/test/fixtures/native-sim.json` holds AWS's IAM policy simulator verdict on every call CloudFormation makes through it. The deploy policy lets it:
Expand Down
2 changes: 2 additions & 0 deletions docs/self-host/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ The CloudFormation console has no link that opens an update with a new template

A stack of that name that something else made, like the boundary stack of an install hardened from the CLI, is never updated or deleted from here; the card says to ask CoderHelm support. No CoderHelm role can create, change or delete a stack of that name.

The access stack also carries the reader update ([security.md](./security.md#the-reader-update)): after each update of the install's stack it brings that release's read-only permissions to `CoderHelmLogReader` in your install's own account, so that account never needs an **Update in AWS**. An access stack from before it shows **adds the reader update** once.

Updates never wait for this item, and it never waits for an update.

### An install launched from v0.8.54-beta.20261108
Expand Down
Loading
Loading