Skip to content

Every team AWS read is made as the team's role - #782

Merged
nambok merged 1 commit into
mainfrom
team-reads-as-team-role
Nov 18, 2026
Merged

nambok merged 1 commit into
mainfrom
team-reads-as-team-role

Conversation

@nambok

@nambok nambok commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

On a self-hosted install that runs in the team's own AWS account, a WAF alarm run's WAF tools were refused wafv2:ListWebACLs. CloudTrail showed the calls came from the worker's own Lambda role, not from CoderHelmLogReader. The cause is in live::aws::assume (services/common/src/live/aws.rs:558, install_target and own_session). When the reader was in the install's account, it swapped the reader for the install's own role, and that role never gets the WAF reads. The refusal blamed the team's role, so the run waited for it. The wait's re-check (log_findings::session_for) took on the reader itself, was allowed, and restarted the run. The restarted run read with the worker's role again and was refused again, so it looped.

Now every read of a team's AWS data is made as the team's role. The run and the re-check take on the role with the same call. A refusal names the principal AWS refused. A restarted run never waits twice for the same read.

Changes

  • live/aws.rs:
    • assume always takes on the connected role with the team's private ID. The install-account swap (install_target) is removed.
    • assume and assume_exact return a new TeamSession, which carries the role ARN. Nothing else can build one.
    • New refused_principal and refused_other_principal functions.
  • Reads that only accept a TeamSession: WAF alarm evidence, sampled requests, WAF log objects (alarm_evidence, waf_logs::read), CloudWatch metrics (metrics::Aws, probe), log reads (log_repo::live::Live, log_look::LiveLook) and the permission check's probes. The install's own credentials (own_session) can't be passed to any of them.
  • log_findings::session_for (the re-check, alarm evidence and log reads) loads the account's connection with AwsAccount::from_item(..).target() and calls assume. That is the same target and the same call the run's tools use.
  • live/permissions.rs: the check runs on the role the reads use, the install's own account included. The integrations page and the connect check no longer hide the update stack for the install's own account.
  • Refusals (alarm_evidence::failure_line, metrics::aws_error): when AWS refused a principal that isn't the team's role, the line names that principal and says it is CoderHelm's own failure. It also writes an error log and never counts as the team's "AWS role reads" item.
  • role_wait:
    • go_on records the reads that let it restart the run (ROLE_WENT_ON#<new run>).
    • finish_without_code decides with ending_after. When the restarted run is refused one of those same reads, it ends OwnFailure and never waits again: an error log, one line on the run, then it plans again with what it has.
  • Docs:
    • docs/self-host/integrations.md: the install's own account is read as the team's role and shows Update in AWS like any other account. Knowledge bases stay on the install's role.
    • New incident rk_team_reads_as_the_team_role (doc and replay test). cx now checks for ending_after.

Knowledge-base reads in the install's account keep using the install's own role, as bedrock.md documents. They are not part of this change.

Verification

  • cargo fmt --all --check and rustfmt --edition 2021 --check on the incident files: clean.
  • cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings: clean.
  • cargo test -p common -p worker -p gateway: common 2827 passed, gateway 1083 passed, worker 2281 passed, integration tests passed.
  • Replay rk_team_reads_as_the_team_role (same-account install; the worker role is refused, the reader role is allowed):
    • With the Lambda's environment set (install role ARN and worker keys), assume on the same-account reader never returns the worker's keys. On main it returns them without calling STS.
    • The re-check's target and the run's target are identical for the same stored connection.
    • The worker's AccessDenied names coderhelm-prod-ServiceRole-…, says it is CoderHelm's own failure, and is not counted against the team's role. The team role's own refusal is still the team's item.
    • A run restarted after the re-check read wafv2:ListWebACLs and then refused it again ends OwnFailure, not a second wait. A different read still waits, and a person's item still goes to the person.
  • The replay fails on main. The swap test gets the worker's keys back, and the other three tests don't compile: ending_after, failure_line, reader_target and TeamSession don't exist there.
  • No AWS calls were made.

On a self-hosted install in the team's own AWS account, live::aws::assume
swapped CoderHelmLogReader for the install's own Lambda role, which never
gets the WAF reads. A run's WAF tools were refused as the worker's role,
the refusal blamed the team's role and the run waited; the wait's
re-check took on the reader itself, was allowed and restarted the run,
which was refused again: a loop.

- assume always takes on the team's role and returns a TeamSession, the
  only session WAF, alarm evidence, WAF log objects, metrics, log reads
  and the permission check accept.
- log_findings::session_for (the re-check) is the account's connection
  taken on with assume: the same target and call as the run's tools.
- A refusal of a principal that isn't the team's role names it and is
  CoderHelm's own failure, never the team's setup item.
- A run a re-check restarted never waits again for what the re-check read
  (role_wait::ending_after): an error log, one line on the run, and it
  goes on with what it has.
- Incident rk_team_reads_as_the_team_role.
@nambok
nambok merged commit f0e03a6 into main Nov 18, 2026
10 checks passed
@nambok
nambok deleted the team-reads-as-team-role branch November 18, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant