Skip to content

IAM: ListPolicies ignores Scope and PathPrefix and never lists bundled managed policies #497

Closed

Description

@scttfrdmn

ListPolicies parses both Scope and PathPrefix and applies neither, and it enumerates
only policies created through CreatePolicy. The 52 bundled AWS managed policies are
invisible to every listing, so --scope AWS returns whatever the caller happened to
create and --path-prefix /service-role/ returns the same thing.

Found while verifying #484, which reported the narrower case: GetPolicy could not resolve
five service-role ARNs AttachRolePolicy accepted. Seeding the catalog fixed that
(v0.87.0). This is unrelated to that report and wider than it — the catalog is now correct
and ListPolicies still cannot see it.

Current behaviour

iam_plugin.go:1110 (listPolicies) reads Scope, PathPrefix, OnlyAttached,
MaxItems and Marker out of the request, then lists state keys under policy: and
returns them. No parameter narrows the result.

What AWS does

Per the ListPolicies reference:

  • Scope — All (default), AWS (AWS managed policies only), or Local (customer
    managed only).
  • PathPrefix — lists only policies whose Path begins with it. /service-role/ is the
    case a consumer reaches for.
  • OnlyAttached — only policies with a non-zero AttachmentCount.

Scope=AWS on real IAM returns roughly 1,200 policies; substrate can only ever return the
52 it bundles, which is a documented gap rather than a bug, but returning zero is the
bug.

Why it matters

A consumer discovering a policy ARN rather than hardcoding it — list-policies --scope AWS --path-prefix /service-role/ then picking a name — gets an empty list, so their
discovery path is untestable. It also breaks the pairing a reader expects: an ARN
GetPolicy resolves does not appear in any listing.

Acceptance criteria

  • ListPolicies includes the bundled managed policies, with AttachmentCount from
    stored attachments.
  • Scope=AWS returns only bundled policies; Scope=Local only CreatePolicy ones;
    All/absent returns both.
  • PathPrefix=/service-role/ returns only the service-role policies.
  • OnlyAttached=true narrows to attached policies.
  • docs/services.md states that the AWS-managed scope is the seeded catalog, not the
    full ~1,200.
  • Tests cover each parameter, the combination of Scope and PathPrefix, and that
    pagination still holds with the catalog in the result set.

Activity

  1. added
    type: bug
    area: iam
    on Aug 2, 2026
  2. added this to the v0.100.0 milestone on Aug 14, 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

    area: iamfidelitytype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions