Skip to content

iam: ListInstanceProfiles ignores MaxItems, Marker and PathPrefix entirely #873

Closed

Description

@scttfrdmn

What is wrong

listInstanceProfiles (emulator/iam_plugin.go:3233-3257) decodes no request parameters at all — there is no parseIAMBody call and no params struct. It authorizes, lists the account's instance-profile keys, decodes each record, and returns every profile with IsTruncated hardcoded false.

API_ListInstanceProfiles publishes three request parameters, and substrate accepts and ignores every one:

Parameter Published Today
MaxItems Integer, "Valid Range: Minimum value of 1. Maximum value of 1000", default 100 ignored; every profile is returned
Marker String, 1-320, pattern [ -ÿ]+ ignored
PathPrefix String, 1-512, "If it is not included, it defaults to a slash (/), listing all instance profiles" ignored; a caller filtering by path gets everything

IsTruncated is hardcoded false, so a caller is told the page is complete whichever of those it sent. ListRoles, ListUsers, ListGroups and ListPolicies all decode and apply their equivalents, so this is the one listing in the plugin that does not.

Why it is worth fixing rather than leaving

This is the accepted-and-ignored class — the same shape as a 200 written for a request nothing acted on. A consumer's paginator asks for MaxItems=10, receives every profile in the account with IsTruncated=false, and concludes correctly from substrate's answer and incorrectly about AWS. A consumer filtering with PathPrefix=/service-role/ gets profiles from every path and cannot tell.

It is also why #868 could not cover it: that fix range-checks a decoded MaxItems, and there is nothing decoded here to check. #868's own inventory listed this operation (as iam_plugin.go:2123, before line drift), and the correction is recorded on that issue.

ListInstanceProfileTags — a different operation, in iam_tagging.go — does decode and validate MaxItems, so the two disagree about the same parameter name within one entity's operations.

What to do

  • Decode MaxItems, Marker and PathPrefix with parseIAMBody, as listRoles does.
  • Apply iamValidateMaxItems (emulator/iam_max_items.go) before any work, so the refusal matches the nineteen operations iam: paginateIAMKeys silently rewrites an out-of-range MaxItems to 100 at eight operations AWS refuses #868 guarded.
  • Page through paginateIAMKeys, which sorts the key space and base64-encodes the marker, and report the real IsTruncated and Marker.
  • Apply PathPrefix before paginating, not after. listUsers and listRoles filter after the page is cut, which can under-fill a page; that is a separate defect and this operation should not copy it.
  • Validate PathPrefix's pattern, or record explicitly that it is not validated, so the decision is not implied by the absence of a check.

Acceptance criteria

  • MaxItems=1 over three profiles returns one profile, IsTruncated true and a Marker; the marker round-trips and the walk returns each profile exactly once.
  • MaxItems=0 and MaxItems=1001 are refused with ValidationError/400, matching the nineteen operations iam: paginateIAMKeys silently rewrites an out-of-range MaxItems to 100 at eight operations AWS refuses #868 guarded.
  • An absent MaxItems still returns up to 100 profiles and reports IsTruncated truthfully.
  • PathPrefix=/service-role/ returns only profiles under that path, and the filter is applied before the page is cut — asserted with more profiles outside the prefix than the page size, so a filter-after-paginate implementation under-fills and fails.
  • docs/services.md's ListInstanceProfiles row stops recording the parameters as ignored.

Compatibility

A caller that sent MaxItems or PathPrefix and relied on receiving everything anyway will now receive a page or a filtered set. Any such caller was relying on substrate ignoring a parameter AWS applies.

Surfaced while implementing #868, whose inventory named this operation from a stale line number.

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

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions