Commit 6bb148b
authored
feat: enforce IMDSv2 by default (Phase 6.a) (#24)
Part of #12. Phase 6 split: this PR ships IMDSv2 enforcement only.
EBS encryption (also scoped in #12) becomes a Phase 6.b follow-up
that needs per-AMI root-device lookup to set BlockDeviceMappings
safely (wrong DeviceName creates an unused extra volume or clobbers
the root).
## Change
RunInstances params now include:
MetadataOptions: {
HttpTokens: config.input.httpTokens,
HttpPutResponseHopLimit: 1,
HttpEndpoint: 'enabled',
}
- HttpTokens default 'required' — IMDSv2 session token mandatory on
every metadata request. Mitigates SSRF to IAM-credential theft.
- HttpPutResponseHopLimit: 1 — token can't cross into a nested
container, cap the blast radius of a containerized workload that
tries to walk metadata.
- HttpEndpoint: 'enabled' — explicit; default but good to pin.
## New input
'http-tokens' in action.yml, default 'required', accepted values
'required' and 'optional'. Consumers who must keep IMDSv1
compatibility set 'optional' explicitly.
## Tests
tests/config.test.js — 2 new cases: default fallback + override.
Total 34 -> 36.
## Consumer impact
Transparent for code running on the runner that uses IMDS via a
modern SDK (aws-sdk v2/v3, SSM agent, cloud-init) — all support
IMDSv2 without config. Risk: an old tool or hand-rolled script
that hits 169.254.169.254/latest/meta-data without first PUTting
for a token. None expected on the hardened AL2023 AMI.
## Dogfood
Small single-knob change — should pass the provider acctest cleanly
once rotated. Phase 6.b (EBS encryption) will be scoped separately.
Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>1 parent 46cf1d0 commit 6bb148b
5 files changed
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87942 | 87942 | | |
87943 | 87943 | | |
87944 | 87944 | | |
| 87945 | + | |
| 87946 | + | |
| 87947 | + | |
| 87948 | + | |
| 87949 | + | |
| 87950 | + | |
| 87951 | + | |
| 87952 | + | |
| 87953 | + | |
87945 | 87954 | | |
87946 | 87955 | | |
87947 | 87956 | | |
| |||
88033 | 88042 | | |
88034 | 88043 | | |
88035 | 88044 | | |
| 88045 | + | |
88036 | 88046 | | |
88037 | 88047 | | |
88038 | 88048 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
| |||
0 commit comments