Merge remote-tracking branch 'origin/main' into census-approved-email-signin
5 files changed,
+96
−0
docs/superpowers/notes/census-proposal-sec-host-imdsv2-module.md+28 −0infra/modules/region-host/main.tf+13 −0infra/modules/region-host/tests/instance_metadata.tftest.hcl+49 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-sec-host-imdsv2-module.tsv+5 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-sec-host-imdsv2-module.md b/docs/superpowers/notes/census-proposal-sec-host-imdsv2-module.md| new file mode 100644 |
| index 000000000..37512514f |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-sec-host-imdsv2-module.md |
| @@ -0,0 +1,28 @@ |
| +# Census approval: sec-host-imdsv2-module |
| + |
| +Ruling `census-ruling-sec-host-imdsv2-module`. Every change below keeps the disposition it already has, so it needs an approval, not a decision. |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `infra/modules/region-host/main.tf` `external` | body | unchanged (1) | aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart | |
| + |
| +Envelopes re-pinned: `infra/modules/region-host`. |
| + |
| +Seal: `09e20ea4bbc534710334e632e903878656dabfb5817d4d96c6e7c56508172148` → `945934f5978ace14dc5a9bae0ed69dfabf29b994504fc843c03d4a633ecd6c6a`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-sec-host-imdsv2-module.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
| + |
| +## Branch context |
| + |
| +The branch `sec-host-imdsv2-module` adds a `metadata_options` block to |
| +`aws_instance.host` in `infra/modules/region-host/main.tf` (IMDSv2 required, |
| +hop limit 1, endpoint enabled), matching scanner-host, and a plan-time tofu |
| +test under `infra/modules/region-host/tests/`. The record-write census does |
| +not change: no record write is added or moved. |
| + |
| +The new `tests/instance_metadata.tftest.hcl` is outside the census: the scan's |
| +extension list excludes `.tftest.hcl`, and envelopes group by immediate |
| +directory, so the module hash covers only the `.tf` files. |
| + |
| +Executing identity: tofu on an operator's machine with the operator's AWS |
| +credentials; no box unit runs the file and no binary embeds it. |
diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf| index b35ecc196..11fca1987 100644 |
| --- a/infra/modules/region-host/main.tf |
| +++ b/infra/modules/region-host/main.tf |
| @@ -490,6 +490,19 @@ resource "aws_instance" "host" { |
| iam_instance_profile = aws_iam_instance_profile.host.name |
| user_data = var.user_data |
| user_data_replace_on_change = false |
| + # IMDSv2 only, one hop. With the block absent EC2 leaves IMDSv1 on, and a |
| + # plain GET from any request-forgery bug in a tenant app reads this |
| + # role's credentials; v2 needs a PUT with a header first, which those |
| + # bugs rarely give an attacker. Hop limit 1 keeps the token from leaving |
| + # the box. Changing these on a running instance is in place, no restart. |
| + # The flagship boxes were switched by hand on 2026-10-23; this keeps a |
| + # replaced box from coming back on v1. The scanner host has done the same |
| + # since it was written. |
| + metadata_options { |
| + http_endpoint = "enabled" |
| + http_tokens = "required" |
| + http_put_response_hop_limit = 1 |
| + } |
| root_block_device { |
| volume_size = var.root_volume_size |
| volume_type = "gp3" |
diff --git a/infra/modules/region-host/tests/instance_metadata.tftest.hcl b/infra/modules/region-host/tests/instance_metadata.tftest.hcl| new file mode 100644 |
| index 000000000..a2c60aa2e |
| --- /dev/null |
| +++ b/infra/modules/region-host/tests/instance_metadata.tftest.hcl |
| @@ -0,0 +1,49 @@ |
| +# Plan-time tests for the host instance's metadata service settings. |
| +# mock_provider means no AWS account and no credentials. |
| +mock_provider "aws" {} |
| + |
| +override_data { |
| + target = data.aws_vpcs.default |
| + values = { ids = ["vpc-0aaaaaaaaaaaaaaaa"] } |
| +} |
| + |
| +override_data { |
| + target = data.aws_caller_identity.current |
| + values = { account_id = "123456789012" } |
| +} |
| + |
| +# The termination queue's ARN feeds an EventBridge target, which the provider |
| +# validates as an ARN; the mock's random string is not one. |
| +override_resource { |
| + target = aws_sqs_queue.terminations |
| + values = { arn = "arn:aws:sqs:eu-west-1:123456789012:carlos-test-host-terminations" } |
| +} |
| + |
| +variables { |
| + name = "carlos-test-ie" |
| + sg_description = "carlos test host" |
| + iam_name = "carlos-test-host" |
| + instance_type = "t4g.small" |
| + root_volume_size = 20 |
| + user_data = "#!/bin/sh\n" |
| + deployment_bucket_arn = "arn:aws:s3:::carlos-test-platform" |
| + data_bucket_arn = "arn:aws:s3:::carlos-test-ie" |
| + ssm_parameter_arn = "arn:aws:ssm:eu-west-1:123456789012:parameter/carlos/*" |
| +} |
| + |
| + |
| +run "imdsv2_only" { |
| + command = plan |
| + assert { |
| + condition = aws_instance.host.metadata_options[0].http_tokens == "required" |
| + error_message = "the host requires IMDSv2 tokens" |
| + } |
| + assert { |
| + condition = aws_instance.host.metadata_options[0].http_put_response_hop_limit == 1 |
| + error_message = "the IMDS token must not leave the box (hop limit 1)" |
| + } |
| + assert { |
| + condition = aws_instance.host.metadata_options[0].http_endpoint == "enabled" |
| + error_message = "the endpoint stays on: the box role is how the host reaches AWS" |
| + } |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 786c30395..6e21d1925 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -1,3 +1,4 @@ |
| # Census chain manifest: overlays loaded after rootReadChain's own, in order. |
| # One per line: <overlay file name under testdata>\t<the seal it leaves>. |
| # make census-propose appends here; nothing else edits this file. |
| +plan14-root-reads-sec-host-imdsv2-module.tsv 945934f5978ace14dc5a9bae0ed69dfabf29b994504fc843c03d4a633ecd6c6a |
diff --git a/internal/provision/testdata/plan14-root-reads-sec-host-imdsv2-module.tsv b/internal/provision/testdata/plan14-root-reads-sec-host-imdsv2-module.tsv| new file mode 100644 |
| index 000000000..c4ac824f6 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-sec-host-imdsv2-module.tsv |
| @@ -0,0 +1,5 @@ |
| +# Census overlay sec-host-imdsv2-module, written by census-propose (#369). census-ruling-sec-host-imdsv2-module, approved by the census owner before the merge; the approval card is docs/superpowers/notes/census-proposal-sec-host-imdsv2-module.md. |
| +# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy bf41de79166910448a12a9ba5e5568bc7365193b909d5ebbe942facce8ecb95c infra/modules/region-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's module with one optional aws_iam_role_policy, host_console_mail, count 0 unless console_mail_from is set; it grants the host role ses:SendEmail on the one sending identity, the carlos-bab configuration set and its tenants, conditioned on ses:FromAddress equal to console_mail_from; no read is added and nothing on a box reads the file;rev3=census-ruling-sec-host-imdsv2-module;basis=aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart file:external@0 8ec89e75ca0a0d2ddde74bffe226adb5a5935249fd41590bcce1623c5201ab47 |
| +infra/modules/region-host/main.tf external legacy accepted-legacy accepted-legacy;rev3=census-ruling-console-invite-delivery;basis=tofu on an operator's machine with the operator's AWS credentials (no box unit; no binary embeds the file): main's module with one optional aws_iam_role_policy, host_console_mail, count 0 unless console_mail_from is set; it grants the host role ses:SendEmail on the one sending identity, the carlos-bab configuration set and its tenants, conditioned on ses:FromAddress equal to console_mail_from; no read is added and nothing on a box reads the file;rev3=census-ruling-sec-host-imdsv2-module;basis=aws_instance.host gains metadata_options (IMDSv2 required, hop limit 1, endpoint enabled), matching scanner-host; tofu configuration only, run on an operator's machine; no read, file or record write is added; applies in place on a running instance with no restart file:external@0 8ec89e75ca0a0d2ddde74bffe226adb5a5935249fd41590bcce1623c5201ab47 |
| +@coverage infra/modules/region-host 5f1b1bbc02603a54e136ff004e2495bef2b0f22054e058b5930a539749b1b558 |