Public: anyone can read this; the crew can change it.

AWS writes for mail setup are a named allowlist beside the read rule, and nothing else #18142

opened this

Merged 4h 50m ago, live in production

awsCall now refuses every non-read AWS operation except nine named ones, and only sends those when the caller says the account has writes allowed. The new and neighbouring tests pass (aws-writes, aws-sign, unused-exports), and tsc and the gate's --fix ran clean. I did not run the full suite.

Notes

opened this

awsCall now refuses every non-read AWS operation except nine named ones, and only sends those when the caller says the account has writes allowed. The new and neighbouring tests pass (aws-writes, aws-sign, unused-exports), and tsc and the gate's --fix ran clean. I did not run the full suite.

What changed (src/cloud/aws_call.ts, new test/aws-writes.test.ts)

  • The list: WRITES holds exact service:Operation pairs, not a pattern:
    • SES: CreateEmailIdentity, PutAccountDetails, DeleteEmailIdentity.
    • IAM: CreateUser, PutUserPolicy, CreateAccessKey, DeleteUser, DeleteUserPolicy, DeleteAccessKey.
    • GetEmailIdentity, the DKIM-token read, already passes the existing Get rule, so it needs no entry.
  • Writes allowed: awsCall takes a new last argument writes, default false. No code yet reads an account's writes setting, so I did not wire that up. A listed write without writes: true throws "this AWS account is read-only".
  • Unlisted writes: these are still refused by name, for example "DeleteBucket is not a read". A listed name under the wrong service is refused too.
  • Send-only policy: sendOnlyPolicy(identityArn) builds a policy allowing only ses:SendRawEmail on that one identity ARN. PutUserPolicy is refused unless its PolicyDocument is exactly that output for a valid SES identity ARN. A wildcard resource, other actions or malformed JSON are all refused.
  • Hosts: ses and iam are added as fixed hosts (email.<region>.amazonaws.com and iam.amazonaws.com). IAM callers should pass us-east-1. No forge.json egress change.
  • Credentials: no log lines were added, and the errors carry only the host, the status and AWS's error code. A test checks the secret never appears in an error.

Tests: one per listed verb, each sent on a writable account and refused on a read-only one. Others cover an unlisted write refused by name, the policy shape, and no credential in errors.

Left out

  • SES v2 is REST-shaped (POST /v2/email/identities, and DELETE for undo). awsCall only builds query and JSON POST asks and GET paths, and the signer is GET/POST only, so those verbs are allowlisted and gated but not yet sendable against real SES. That needs a REST-write transport in a follow-up.
  • No account "writes allowed" flag is stored.
  • No page or terminal surface, so the commit says No door: and credits #18134.
  • I added no new function similar to an existing one, so there was nothing to reuse.

To try: bun test test/aws-writes.test.ts test/aws-sign.test.ts

🤖 Generated with Claude Code

Closes #18134

2 earlier comments
commented

awsCall now refuses every non-read AWS operation except nine named ones, and only sends those when the caller says the account has writes allowed. The new and neighbouring tests pass (aws-writes, aws-sign, unused-exports), and tsc and the gate's --fix ran clean. I did not run the full suite.

What changed (src/cloud/aws_call.ts, new test/aws-writes.test.ts)

  • The list: WRITES holds exact service:Operation pairs, not a pattern:
    • SES: CreateEmailIdentity, PutAccountDetails, DeleteEmailIdentity.
    • IAM: CreateUser, PutUserPolicy, CreateAccessKey, DeleteUser, DeleteUserPolicy, DeleteAccessKey.
    • GetEmailIdentity, the DKIM-token read, already passes the existing Get rule, so it needs no entry.
  • Writes allowed: awsCall takes a new last argument writes, default false. No code yet reads an account's writes setting, so I did not wire that up. A listed write without writes: true throws "this AWS account is read-only".
  • Unlisted writes: these are still refused by name, for example "DeleteBucket is not a read". A listed name under the wrong service is refused too.
  • Send-only policy: sendOnlyPolicy(identityArn) builds a policy allowing only ses:SendRawEmail on that one identity ARN. PutUserPolicy is refused unless its PolicyDocument is exactly that output for a valid SES identity ARN. A wildcard resource, other actions or malformed JSON are all refused.
  • Hosts: ses and iam are added as fixed hosts (email.<region>.amazonaws.com and iam.amazonaws.com). IAM callers should pass us-east-1. No forge.json egress change.
  • Credentials: no log lines were added, and the errors carry only the host, the status and AWS's error code. A test checks the secret never appears in an error.

Tests: one per listed verb, each sent on a writable account and refused on a read-only one. Others cover an unlisted write refused by name, the policy shape, and no credential in errors.

Left out

  • SES v2 is REST-shaped (POST /v2/email/identities, and DELETE for undo). awsCall only builds query and JSON POST asks and GET paths, and the signer is GET/POST only, so those verbs are allowlisted and gated but not yet sendable against real SES. That needs a REST-write transport in a follow-up.
  • No account "writes allowed" flag is stored.
  • No page or terminal surface, so the commit says No door: and credits #18134.
  • I added no new function similar to an existing one, so there was nothing to reuse.

To try: bun test test/aws-writes.test.ts test/aws-sign.test.ts

🤖 Generated with Claude Code

commented

This pull now ties AWS writes to the account's writeAllowed flag and takes the three SES names out of the allowlist.

  • Writes follow the account. accountCall(f, key, writeAllowed) in src/cloud/aws_read.ts binds the flag into awsCall. readAws uses it, and readWhole in src/cloud/projects.ts fills the flag from getCloudAccount(...).writeAllowed. A read-only account refuses every listed write, and a writeAllowed account sends it. A test covers both cases, and reads still go through on a read-only account.
  • SES names removed. CreateEmailIdentity, PutAccountDetails and DeleteEmailIdentity are no longer in WRITES. A comment says why: SES v2 is REST, and this transport only signs GET and POST. A test checks that the SES ask is refused by name. I did not build the REST write transport here, so the SES entries return once it exists. The IAM entries stay.
  • IAM region. An iam call outside us-east-1 now throws "iam is signed for us-east-1 only", which also stops it surfacing as a credential error. The doc comment says so, and a test covers it.

readAws is the only caller of accountCall, and it only reads today, so no write path uses the flag yet. The first mail-setup action will call accountCall with the account's flag.

bun x tsc --noEmit is clean, test/aws-writes.test.ts and test/cloud-part-of.test.ts pass, and gate --fix was committed. I did not run the dead-code, process-state or during check tests. My bun test test/dead-code.test.ts filter matched no file, so the dead-code test didn't run. The commit lines say No door and name #18134.

The gate also notes that one comment line in src/cloud/projects.ts is over 100 columns. I left it, since the gate says the nightly rewrap handles it on main.

commented

Left #18134 open: 1 unticked item remain (aws_call.ts still refuses every verb that is not Describe, List or Get, except an explicit list of exactly: SES create-identity, get-identity (DKIM tokens), put-account-details; IAM create-user, put-user-policy, create-access-key, and the matching deletes for undo.).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs