Closed
Description
Part of plan #15. Phase 6 — Security Defaults.
Problem
The action runs EC2 instances configured entirely by the consumer's inputs (subnet-id, security-group-id, ec2-image-filters). It does nothing to encourage or enforce secure defaults:
- Consumers can (and do) run runners in public subnets with broadly-permissive SGs.
- No guidance on IMDSv2 enforcement — runners are network-reachable attack targets until they register, and IMDSv1 allows SSRF-style credential exfiltration.
- No guidance on encrypted EBS root volumes.
Proposed changes
Documentation
New docs/security-defaults.md covering:
- Subnet choice. Prefer private subnet + NAT gateway (or VPC endpoints for
ec2,s3,github.com). Public subnets + EIPs only if there's a specific need (e.g., IP allowlisting at a third-party API). - Security group. Outbound-only; inbound SSH blocked; no 0.0.0.0/0 ingress. Example TF snippet.
- IMDSv2. Set
HttpTokens: required+HttpPutResponseHopLimit: 1on RunInstances. Mitigates SSRF → IAM credential theft. - EBS encryption. Set
BlockDeviceMappings[*].Ebs.Encrypted: true. Protects data at rest. - Instance profile. Pass
iam-role-nameonly for jobs that need AWS access from within the runner. For self-contained jobs (like the provider'smake testacc), skip it.
Code changes
- Set IMDSv2 required unconditionally in
RunInstancesparams. This is a reasonable hard default — IMDSv1 has no legitimate modern use case. If anyone complains, add an opt-out input. - Set EBS encryption on the root volume unconditionally. Adds no cost and is a reasonable default.
- Add an input
http-tokens(defaultrequired) so a consumer can override if they must.
Consumer impact (terraform-provider-namecheap)
- Current SG
sg-106ec76d, subnetsubnet-01c4ff5a, EIPeipalloc-1796f61b— needs review against the documented defaults. EIP + public subnet is presumably for Namecheap API IP allowlisting (theacceptance_testjob hitsapi.namecheap.com). - IMDSv2 requirement: should be transparent.
aws-sdkclients and SSM agent all support IMDSv2. - EBS encryption: transparent.
Acceptance criteria
-
docs/security-defaults.mdexists with concrete TF + workflow examples. - IMDSv2 required by default;
http-tokensinput provides override. - EBS root encryption on by default.
- README links to
docs/security-defaults.mdfrom the Usage section. - Existing consumer workflows still start runners successfully (dogfood test).
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat: enforce IMDSv2 by default (Phase 6.a) (#24)
kurok commentedon Apr 21, 2026
Phase 6 split: Phase 6.a (IMDSv2) landed via #24. Phase 6.b (EBS encryption) remains scoped for a follow-up — requires per-AMI root-device lookup to set BlockDeviceMappings safely. Closing this issue as Phase 6.a is the enforceable piece; EBS encryption will get its own issue.