Skip to content

Guard against spored/reaper IAM drift: code calls AWS APIs the role doesn't grant (recurring class) #254

Closed

Description

@scttfrdmn

Pattern

The same class of bug has now bitten three times: in-instance/out-of-band code (spored, ttl-reaper) calls an AWS API that the relevant IAM role/policy does not grant, so the call fails with AccessDenied — and because these paths are best-effort and under-logged, it manifests as a silent no-op, not a loud failure.

Confirmed instances:

Why it keeps happening

The IAM policy (pkg/aws/iam.go buildInlinePolicy for spored; lambda/ttl-reaper/template.yaml for the reaper) is maintained by hand, separately from the code that makes the calls. Adding an SDK call doesn't fail any build/test if the matching grant is missing — it only fails at runtime, in an account, often silently.

Ideas (pick one or more)

  1. A test that greps the agent/reaper packages for client.<Service> SDK call sites and asserts each service appears in the inline policy (a coarse but cheap drift guard — would have caught all three).
  2. Centralize the spored required-action list in one place that both buildInlinePolicy and a doc/test consume, so adding a call forces a policy edit in the same change.
  3. Make these best-effort AWS paths log AccessDenied loudly (distinct from "nothing to do") so a missing grant is diagnosable from logs without a live repro — directly addresses the "silent no-op" half. (spored did not mount the async-created ephemeral FSx after it reached AVAILABLE (no mount, no log lines) — #194 not firing #221 Q3 asked for exactly this on the FSx path.)
  4. A periodic spawn doctor-style IAM self-check that dry-run/simulates the spored role against its required actions.

Low-glamour, high-leverage: each occurrence has cost a live debugging session. Filing so the next FSx/DNS/whatever feature doesn't rediscover it.

Activity

  1. added
    enhancement
    on Jun 25, 2026
  2. scttfrdmn commented on Oct 11, 2026

    @scttfrdmn
    ContributorAuthor

    Audit note — the 2026-10 review found a hole in this issue's own guard, which is
    worth recording here rather than as a new issue.

    apiServicePrefix (pkg/reaperiam/drift_test.go:20) maps only
    ec2/fsx/ssm/netResource. But lambda/ttl-reaper/main.go:178 declares:

    type route53API interface {
        ListResourceRecordSets(...)
        ChangeResourceRecordSets(...)   // mutating
    }

    ifaceOpen matches it, the service lookup returns "", and
    if svc == "" { continue } silently drops both methods. methodCall has the
    same shape — it only matches (ec2|fsx|ssm)Client\.. So an entire AWS service the
    reaper calls, including a mutating action, is invisible to the gate titled "every
    AWS action the reaper calls must be granted".

    Honest severity: not a live permission gap. pkg/reaperdeploy never
    configures DNS, so a scan-self reaper has route53Client disabled. It is the gate
    that is wrong, not the policy.

    The fix is the rule-4 shape: derive the service from the interface name and
    fail on an unmapped one, rather than skipping it. A gate whose default for
    "I don't recognise this" is continue reports clean on exactly what it forgot —
    which is the same defect this issue exists to catch, one level up.

    Related, and the inverse direction: the in-account reaper over-grants
    ssm:SendCommand on Resource: "*". That one is a security finding and is
    tracked privately rather than here.

  3. modified the milestones: Later, v0.146.0 on Oct 19, 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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions