Skip to content

fix(security): scope spored CreateTags to managed instances (#174) - #236

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/174-scope-createtags
Jun 24, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/174-scope-createtags

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #174 (HIGH, from the 2026-06 suite audit).

Problem

The spored IAM role granted ec2:CreateTags on Resource: "*" with no condition (lumped in with the read-only Describe* calls at pkg/aws/iam.go), while the destructive TerminateInstances/StopInstances were conditioned on ec2:ResourceTag/spawn:managed=true. So a compromised spore could tag any instance spawn:managed=true and then terminate it — the condition scoping the destructive perms gave no containment.

Fix

Split tag writes into their own statement conditioned on ec2:ResourceTag/spawn:managed=true:

ec2:CreateTags, ec2:DeleteTags  →  Resource "*"  if  ec2:ResourceTag/spawn:managed = true

A spore can now only (re)tag instances already in scope — it can't bring a foreign instance into scope to then terminate it. spored only ever tags its own instance, which carries spawn:managed=true from launch, so legitimate use is unaffected. (Also adds the previously-missing DeleteTags grant the FSx-mount path uses.) updateInlinePolicy re-applies this to existing roles on the next launch/role refresh.

Tests

TestSporedTagPermissionsScoped asserts the CreateTags statement carries the spawn:managed=true condition (and that some statement still grants CreateTags, so spored's lifecycle tagging keeps working). make check clean.

Note

The companion HIGH #173 (dns-updater Route53 spoofing) is a separate, cross-repo IAM-auth change — documented on that issue, shipping independently. This PR is self-contained.

#174)

The spored IAM role granted ec2:CreateTags on Resource "*" with no condition,
lumped in with the read-only Describe* calls — while TerminateInstances/
StopInstances were conditioned on ec2:ResourceTag/spawn:managed=true. A
compromised spore could therefore tag ANY instance spawn:managed=true and then
terminate it, so the condition on the destructive actions provided no real
containment (the forgeable spawn:iam-user owner tag likewise).

Fix: split CreateTags/DeleteTags into their own statement conditioned on
ec2:ResourceTag/spawn:managed=true, so a spore can only (re)tag instances ALREADY
in scope — it cannot pull a foreign instance into scope. spored only ever tags
its own instance (which carries spawn:managed=true from launch), so legitimate
use is unaffected. Also adds the previously-missing DeleteTags grant the
FSx-mount path uses. updateInlinePolicy re-applies this to existing roles on the
next launch/refresh.

Regression test asserts CreateTags carries the spawn:managed condition.
Closes #174.
…licy

Splitting tag-writes into their own conditioned statement (#174) made the base
spored policy 3 statements (read / tag-write / destructive) instead of 2; update
the count assertions accordingly.
@scttfrdmn
scttfrdmn merged commit a748efd into main Jun 24, 2026
6 checks passed
@scttfrdmn
scttfrdmn deleted the fix/174-scope-createtags branch June 24, 2026 19:45
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HIGH] spored role grants unconditioned ec2:CreateTags on * → tag-then-terminate escalation

1 participant