carlos / platform Public

region-host: deny the host role read of /carlos/release-key (H1-M2)

The module attaches AmazonSSMManagedInstanceCore (ssm:GetParameter* on *) for
Session Manager. The existing host_ssm_parameter_scope Deny uses NotResource =
[ssm_parameter_arn], so when a deployment sets ssm_parameter_arn to
.../parameter/carlos/* (the IE/flagship role does), /carlos/release-key sits
INSIDE the allowed pattern and the managed Allow lets an internet-facing box
read the root release-signing key. Re-found as hunt H1-M2 on the IE role.

Add aws_iam_role_policy.host_release_key_deny (new var deny_release_key_reads,
default true), ported verbatim from platform-infrastructure/dev/
release-key-deny.tf: an explicit Deny on GetParameter/GetParameters/
GetParameterHistory for parameter/carlos/release-key, plus a GetParametersByPath
deny on the ancestor list paths (parameter/carlos, parameter/carlos/, parameter,
parameter/). Explicit Deny wins over the managed Allow for the key alone; the
ancestor-path deny blocks the recursive-list route without denying deeper
/carlos/<app>/* by-path reads the box needs. Account id from the module's
existing data.aws_caller_identity.current.

Step 1 confirmed the console does not depend on the host-role grant: it reads
CARLOS_RELEASE_KEY from its service env drop-in (cmd/console/main.go os.Getenv),
and the promote/ship scripts fetch the key with an operator AWS_PROFILE, never
the box role. So the Deny does not break signing or promotion.

Stage the carloku-infrastructure wiring under infra-proposed/carloku-infra/
region-ie.tf (ref bump + explicit deny_release_key_reads = true); real infra
repos untouched. tofu fmt passes; validate blocked by the sandbox (provider
plugin will not run under bwrap) — no AWS/remote-state touched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude Opus (hunt fix) pushed by claude agent, operated by paul@keymail.dev 22bcbb6c265ffed2d1c588cf9b4ea9faebc3b038 parent fb86a68
4 files changed, +310 −0
  • infra-proposed/RATIONALE.md +71 −0
  • infra-proposed/carloku-infra/region-ie.tf +161 −0
  • infra/modules/region-host/main.tf +54 −0
  • infra/modules/region-host/variables.tf +24 −0
diff --git a/infra-proposed/RATIONALE.md b/infra-proposed/RATIONALE.md
index 91a29a7cb..183242016 100644
--- a/infra-proposed/RATIONALE.md
+++ b/infra-proposed/RATIONALE.md
@@ -49,3 +49,74 @@ is branch-diff only; rolling it is a later scoped step (re-bootstrap / AMI
refresh), per the plan.
`update-platform-binary.sh` (operator-sha path) is intentionally untouched.
+
+---
+
+# Task 2 — deny the IE/region host role read of /carlos/release-key (H1-M2)
+
+Branch-diff only. The MODULE change is applied directly in this worktree at
+`infra/modules/region-host/{main.tf,variables.tf}`. This staged file is the
+PROPOSED carloku-infrastructure wiring; the real carloku-infrastructure repo
+is untouched.
+
+- `carloku-infra/region-ie.tf` → carloku-infrastructure/region-ie.tf
+
+## The hole
+`region-ie.tf` sets `ssm_parameter_arn = ".../parameter/carlos/*"`. The
+module's existing `host_ssm_parameter_scope` Deny uses `NotResource =
+[ssm_parameter_arn]`, so it denies only reads OUTSIDE that pattern —
+`/carlos/release-key` is INSIDE it, left to the managed
+AmazonSSMManagedInstanceCore Allow (`ssm:GetParameter*` on `*`). So the
+internet-facing IE box can read the root release-signing key. Same class as
+discussion #7; re-found as H1-M2 on the IE/region role.
+
+## Module change (this worktree)
+`infra/modules/region-host/main.tf`: new `aws_iam_role_policy
+"host_release_key_deny"` (count = `var.deny_release_key_reads ? 1 : 0`),
+inserted right after `host_ssm_parameter_scope` (its close was at :475; the
+new block sits between it and `aws_iam_instance_profile "host"`). Two explicit
+Deny statements, ported verbatim from `platform-infrastructure/dev/
+release-key-deny.tf`:
+ 1. `DenyReleaseKeyReads` — `ssm:GetParameter`, `GetParameters`,
+ `GetParameterHistory` on
+ `arn:aws:ssm:*:<account>:parameter/carlos/release-key`.
+ 2. `DenyReleaseKeyAncestorPathReads` — `ssm:GetParametersByPath` on the four
+ ancestor list paths `parameter/carlos`, `parameter/carlos/`, `parameter`,
+ `parameter/`.
+Account id is `data.aws_caller_identity.current.account_id` (already declared
+in the module at main.tf:607). `infra/modules/region-host/variables.tf`: new
+`variable "deny_release_key_reads"` (bool, default true).
+
+## Why it composes
+Explicit Deny beats any Allow in IAM, including a managed policy's, so the key
+path is denied no matter how wide `ssm_parameter_arn` / the managed Allow are.
+The new Deny and the existing `NotResource` Deny never conflict: both are
+Deny, and adding a Deny can only subtract access. The GetParametersByPath deny
+names only the ANCESTOR list paths (`/carlos`, account root), so the box still
+reads deeper by-path prefixes (`/carlos/<app>/*`, pepper, smtp creds) — the
+other `/carlos/*` reads it needs are untouched. The four single-read actions
+cover only parameter reads; Session Manager's channel/inventory/association
+actions are not named, so the admin path is unchanged.
+
+## Promotion is not affected (Step 1)
+The console does NOT read the key from SSM at runtime: `cmd/console/main.go`
+reads `os.Getenv("CARLOS_RELEASE_KEY")` at serve() start (:312), populated by
+the `console.service` `release-key` env drop-in placed by hand over SSM
+(carloku README §"What's on the IE box", line 136). The promote/ship scripts
+(`promote-console.sh`, `promote-app.sh`, `ship-app.sh`, `promote-pending.sh`,
+`promote-platform-site.sh`) fetch `/carlos/release-key` with an operator
+`AWS_PROFILE` (keymail / titogo / passed-in), never the box instance role. No
+boot-time box-role read of the key exists in either infra repo. So the Deny
+cannot break signing or promotion.
+
+## Rollout (must flag to Paul)
+The carloku wiring needs the module `?ref=` bumped to the first platform tag
+that carries `host_release_key_deny` (placeholder `<RELEASE-KEY-DENY-TAG>` in
+the staged file). The module variable defaults ON, so the bump alone lands the
+Deny on the IE role; `deny_release_key_reads = true` is stated explicitly at
+the call site for visibility. Apply TARGETED at
+`module.host_ie.aws_iam_role_policy.host_release_key_deny` under scoped
+approval — a whole-module plan on this live box also carries its other drift.
+Expected targeted plan: 1 to add, 0 to change, 0 to destroy. The other three
+regions (us/uk/au, still v0.21.0) are not touched by this task; they pick up
+the Deny-on-by-default when they are rolled onto a tag that carries it.
diff --git a/infra-proposed/carloku-infra/region-ie.tf b/infra-proposed/carloku-infra/region-ie.tf
new file mode 100644
index 000000000..a9be3039c
--- /dev/null
+++ b/infra-proposed/carloku-infra/region-ie.tf
@@ -0,0 +1,161 @@
+# The IE region of the flagship: one Graviton box running `carlos agent`,
+# behind an Elastic IP. The box is disposable by construction — all
+# durable state is in the buckets — so there is no backup story for hosts
+# at all, only for buckets. Residency is enforced in the module: the host
+# role reaches the deployment bucket plus ITS OWN region's data bucket
+# and nothing else.
+
+module "host_ie" {
+ # v0.28.8 for console_mail_from (below); v0.24.1 brought store_scanning.
+ # The other three regions stay on v0.21.0 until they are rolled
+ # deliberately. Apply this bump TARGETED at host_console_mail: a whole
+ # module plan also carries the module's other changes since v0.24.1.
+ #
+ # TASK-2 (H1-M2): bump the ref to the first platform tag that carries the
+ # module's aws_iam_role_policy.host_release_key_deny (TAG TBD — assigned
+ # when the Task-2 module change is released; shown here as the placeholder
+ # <RELEASE-KEY-DENY-TAG>). That module change defaults deny_release_key_reads
+ # to true, so the Deny lands on this IE role on the bump; the line below
+ # states it explicitly so the intent is visible at the call site. Apply it
+ # TARGETED at module.host_ie.aws_iam_role_policy.host_release_key_deny — a
+ # whole-module plan on this box also carries the module's other drift.
+ source = "git::https://github.com/carlosframework/platform.git//infra/modules/region-host?ref=<RELEASE-KEY-DENY-TAG>"
+ name = "carlos-flagship-ie"
+ sg_description = "carlos flagship IE host"
+ iam_name = "carlos-flagship-host"
+ instance_type = "t4g.large"
+ root_volume_size = 60
+ user_data = file("${path.module}/host-init.sh")
+ deployment_bucket_arn = module.buckets.deployment_bucket_arn
+ data_bucket_arn = module.buckets.data_bucket_arn
+ ssm_parameter_arn = "arn:aws:ssm:eu-west-1:${local.account}:parameter/carlos/*"
+
+ # Release-key deny (hunt H1-M2). ssm_parameter_arn above is .../carlos/*,
+ # so /carlos/release-key sits INSIDE the allowed pattern and the managed
+ # AmazonSSMManagedInstanceCore Allow lets this internet-facing IE box read
+ # the root release-signing key. This explicit Deny (module default; named
+ # here for visibility) names the key path by Resource and wins over that
+ # Allow, leaving every other /carlos/* read the box needs untouched. The
+ # console reads CARLOS_RELEASE_KEY from its service drop-in and the promote
+ # scripts fetch the key with an operator profile, so no host loses the key.
+ deny_release_key_reads = true
+
+ # Object storage (#368/#381). Setting the prefix is what gives THIS box's
+ # role the provisioning grant and creates the permissions boundary store
+ # users are made under; the other three regions get none of it, because the
+ # console is the only thing that provisions.
+ #
+ # The prefix is deliberately NOT "carlos-": that also matches this
+ # deployment's own buckets (carlos-flagship-271376211898), and while the
+ # module carries an explicit Deny for exactly that overlap, a prefix that
+ # cannot collide in the first place is the better answer.
+ store_bucket_prefix = "carlos-store-"
+
+ # Object-storage virus scanning (platform spec 2026-10-04): lets THIS box's
+ # role read and tag store objects. The console is the only thing that scans.
+ store_scanning = true
+
+ # Console email (platform spec 2026-10-21 console email sign-in): lets THIS
+ # box's role send as exactly this address, the console's
+ # CARLOS_CONSOLE_MAIL_FROM, through the ops account's SES tenant. The
+ # console signs people in and delivers invitations with it. Paul enabled
+ # it on 2026-10-21; the identity itself is made by the console (bab,
+ # referrer console-mail) and its DKIM records live in dns-carloku.tf.
+ console_mail_from = "noreply@carloku.com"
+ console_mail_region = "eu-west-1"
+
+ # Instance moves (#331): this box stages a moving instance's data into
+ # the TARGET region's data bucket: Put/Delete on moves/* only, never
+ # instances/* and never GetObject (module variable doc).
+ # IE -> UK first (bdn/ips, 2026-10-01); add a region here before moving
+ # anything into it.
+ sibling_staging_arns = [aws_s3_bucket.data_uk.arn]
+
+ # Wildcard-cert DNS-01 against the staged oncarlos.com Route53 zone
+ # (dns53.tf). CHANGE TO EXISTING INFRASTRUCTURE — the rest of the region
+ # work is pure addition, this line is not: it adds an inline policy
+ # (`carlos-flagship-host-route53`) to the LIVE IE host role, so the plan
+ # shows work inside module.host_ie. It is additive and bounded — the
+ # module's conditions allow only _acme-challenge.* TXT UPSERT/DELETE in
+ # this one zone — and it grants nothing until the box actually runs with
+ # CARLOS_DNS_PROVIDER=route53 against an authoritative zone. The IE box
+ # keeps issuing through DNSimple until then; this is staging, not a flip.
+ route53_zone_ids = [aws_route53_zone.oncarlos.zone_id]
+
+ # DNS-steering grant (multi-region ingress stage 5, platform PR #259):
+ # latency A records + health checks for steered hosts in the oncarlos.com
+ # zone, name-bound to *.oncarlos.com so the apex A stays out of reach.
+ # Inert until CARLOS_STEERING_ZONE_ID is set on the box — the converger
+ # duty is dormant without it.
+ steering_zone_ids = [aws_route53_zone.oncarlos.zone_id]
+ steering_record_names = ["*.oncarlos.com"]
+
+ # Cost Explorer read for the economics dashboard's daily bill pull
+ # (platform PR #171, internal/console/cepull.go): this is the box that
+ # runs the flagship console, so it gets the account-level ce:GetCostAndUsage
+ # grant. Per-box flag, off everywhere else; the grant lands on the shared
+ # host role, so every process on this box can read the account's bill.
+ enable_cost_explorer = true
+
+ # Memory-low alarm recipient (memory-pressure spec §2.4); alerts.tf
+ # says why it starts empty.
+ alerts_email = local.memory_alerts_email
+
+ # Keymail migration (plan K1): the inbound challenge-MX binds :25 directly on
+ # the box — the edge doesn't speak SMTP. The SG uses in-line rules, so the
+ # port comes through the module's extra_ingress, never a standalone rule
+ # resource. Inert until a unit sets KEYMAIL_MX_ADDR; outbound :25 stays
+ # blocked by AWS (keymail sends via the SES API).
+ extra_ingress = [{
+ description = "smtp (keymail inbound mail bridge MX)"
+ from_port = 25
+ to_port = 25
+ protocol = "tcp"
+ cidr_blocks = ["0.0.0.0/0"]
+ }]
+
+ # Platform STUN/TURN relay (media roadmap stage 4a, platform spec
+ # 2026-09-07-relay-stun-turn-design.md §6): opens udp+tcp 3478 and the
+ # udp 49152-65535 allocation range, inline like extra_ingress above. The
+ # unit itself only starts once /etc/carlos/relay-masters is staged on
+ # the box (ConditionPathExists), so this line alone listens for nothing.
+ # Ireland first; the other regions follow when a tenant needs them.
+ relay = true
+}
+
+# State surgery from the pre-module layout (refactor 2026-08-01) — pure
+# bookkeeping, no real resource is touched.
+moved {
+ from = aws_security_group.host_ie
+ to = module.host_ie.aws_security_group.host
+}
+
+moved {
+ from = aws_iam_role.host
+ to = module.host_ie.aws_iam_role.host
+}
+
+moved {
+ from = aws_iam_role_policy.host_buckets
+ to = module.host_ie.aws_iam_role_policy.host_buckets
+}
+
+moved {
+ from = aws_iam_role_policy_attachment.host_ssm
+ to = module.host_ie.aws_iam_role_policy_attachment.host_ssm
+}
+
+moved {
+ from = aws_iam_instance_profile.host
+ to = module.host_ie.aws_iam_instance_profile.host
+}
+
+moved {
+ from = aws_instance.host_ie
+ to = module.host_ie.aws_instance.host
+}
+
+moved {
+ from = aws_eip.host_ie
+ to = module.host_ie.aws_eip.host
+}
diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf
index 11fca1987..aca89632e 100644
--- a/infra/modules/region-host/main.tf
+++ b/infra/modules/region-host/main.tf
@@ -474,6 +474,60 @@ resource "aws_iam_role_policy" "host_ssm_parameter_scope" {
})
}
+# The release-signing key, named and denied on its own.
+#
+# host_ssm_parameter_scope above only bites when ssm_parameter_arn is tight.
+# A deployment whose hosts legitimately read a swathe of /carlos/* (the usual
+# shape — pepper, smtp creds, per-app config) sets ssm_parameter_arn to
+# `.../parameter/carlos/*`, and /carlos/release-key sits INSIDE that pattern:
+# the NotResource deny does not cover it, and the managed Allow does. So an
+# internet-facing box can read the root release-signing key — the exact hole
+# found standing up a fleet (discussion #7), and re-found in the H1 hunt
+# (H1-M2) on the IE/region role.
+#
+# This deny names the key path by Resource, so it wins no matter how wide
+# ssm_parameter_arn is. The console does NOT depend on the host-role grant
+# for the key: it reads CARLOS_RELEASE_KEY from its service env/drop-in
+# (cmd/console/main.go reads os.Getenv), and the promote/ship scripts fetch
+# /carlos/release-key with an operator AWS_PROFILE, never the box role.
+#
+# The GetParametersByPath ancestor-path deny blocks the recursive-list route
+# to the key (listing /carlos or the account root returns it too) WITHOUT
+# denying a by-path read of a deeper prefix like /carlos/<app>/*, so the
+# box keeps the /carlos/* reads it needs. Two explicit Deny statements never
+# conflict with the NotResource deny above — adding deny only subtracts.
+resource "aws_iam_role_policy" "host_release_key_deny" {
+ count = var.deny_release_key_reads ? 1 : 0
+ name = "${var.iam_name}-release-key-deny"
+ role = aws_iam_role.host.id
+ policy = jsonencode({
+ Version = "2012-10-17"
+ Statement = [
+ {
+ Sid = "DenyReleaseKeyReads"
+ Effect = "Deny"
+ Action = [
+ "ssm:GetParameter",
+ "ssm:GetParameters",
+ "ssm:GetParameterHistory",
+ ]
+ Resource = "arn:aws:ssm:*:${data.aws_caller_identity.current.account_id}:parameter/carlos/release-key"
+ },
+ {
+ Sid = "DenyReleaseKeyAncestorPathReads"
+ Effect = "Deny"
+ Action = "ssm:GetParametersByPath"
+ Resource = [
+ "arn:aws:ssm:*:${data.aws_caller_identity.current.account_id}:parameter/carlos",
+ "arn:aws:ssm:*:${data.aws_caller_identity.current.account_id}:parameter/carlos/",
+ "arn:aws:ssm:*:${data.aws_caller_identity.current.account_id}:parameter",
+ "arn:aws:ssm:*:${data.aws_caller_identity.current.account_id}:parameter/",
+ ]
+ },
+ ]
+ })
+}
+
resource "aws_iam_instance_profile" "host" {
name = var.iam_name
role = aws_iam_role.host.name
diff --git a/infra/modules/region-host/variables.tf b/infra/modules/region-host/variables.tf
index cfe641067..831ad99b5 100644
--- a/infra/modules/region-host/variables.tf
+++ b/infra/modules/region-host/variables.tf
@@ -116,6 +116,30 @@ variable "scope_ssm_parameter_reads" {
default = true
}
+variable "deny_release_key_reads" {
+ description = <<-EOT
+ Add an explicit Deny on this role reading /carlos/release-key from SSM,
+ regardless of how wide ssm_parameter_arn is (hunt finding H1-M2).
+
+ scope_ssm_parameter_reads only protects the key when ssm_parameter_arn is
+ narrow. A deployment that sets ssm_parameter_arn to `.../parameter/carlos/*`
+ — the common case — puts /carlos/release-key INSIDE the allowed pattern,
+ and the managed AmazonSSMManagedInstanceCore Allow then lets an
+ internet-facing box read the root release-signing key. This deny names the
+ key path (and its ancestor GetParametersByPath list paths) by Resource, so
+ an explicit Deny wins over that Allow for the key alone, leaving every
+ other /carlos/* read the box needs untouched.
+
+ On (the default) because no host this module builds signs releases: the
+ console reads CARLOS_RELEASE_KEY from its service env/drop-in and the
+ promote scripts fetch the key with an operator profile, never the box
+ role. Set it to false only if a host on this deployment is proven to read
+ /carlos/release-key through its instance role at runtime.
+ EOT
+ type = bool
+ default = true
+}
+
variable "extra_ingress" {
description = "Additional ingress rules beyond the standard 80/443 (e.g. tcp/25 for a host running an inbound MX). The SG uses in-line rules, so extra rules MUST come through here — a standalone aws_vpc_security_group_ingress_rule in the root would fight the in-line set and be stripped on every apply."
type = list(object({