Skip to content

reaper: delete unattached spored managed policies (/spore-host/spored-*-vN) it detaches #1576

Open

Description

@scttfrdmn

Follow-up to #1573 (leave no trace).

#1573 moves the spored grants into customer-managed policies at arn:aws:iam::<account>:policy/spore-host/spored-{policy,baseline-policy,nested-baseline-policy}-v<schema>, one per document per schema per account, attached to the spored roles.

Who deletes them after that PR:

  • pkg/aws.deleteRole (spawn cleanup, spawn pool drain) deletes a spored policy it detaches when no other role has it attached (IAM's DeleteConflict is the check).
  • spawn cleanup --instance-roles runs instancerole.SweepSporedPolicies: spored-named policies at /spore-host/, AttachmentCount == 0, created more than 24 h ago.
  • A launch at a newer schema detaches the older version from its role and deletes it if that was the last attachment.

The gap: the TTL reaper's role sweep (pkg/instancerole.Delete, called from lambda/ttl-reaper/instanceroles.go) detaches every managed policy from a role it deletes, spored ones included, but never deletes the policy. Its iamAPI has no DeletePolicy/ListPolicies, and pkg/reaperiam grants nothing on policy/*. So when the reaper deletes the last spawn-instance-* role carrying an older schema's baseline policy, that policy stays until someone runs spawn cleanup --instance-roles.

Size of it: at most three policies per schema per account (customer-managed policies are free, and the account quota is 1,500). This is clutter, not cost, which is why #1573 left it out of the patch release rather than taking on a reaper redeploy.

To fix:

  • Call instancerole.SweepSporedPolicies from the reaper's instance-role sweep, under REAPER_INSTANCE_ROLES, so report mode only reports.
  • Add iam:ListPolicies (Resource *; IAM has no narrower one) and iam:DeletePolicy on arn:aws:iam::*:policy/spore-host/* to the three reaper policies in pkg/reaperiam. The drift gate will require them once the iamAPI declares the methods.
  • Redeploy the reaper.

Activity

  1. added this to the Hardening milestone on Nov 10, 2026
  2. added
    enhancement
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlifecycle

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions