Skip to content

IAM MaxItems and MaxSessionDuration are rejected over the wire: a query-protocol integer arrives as a string #642

Closed

Description

@scttfrdmn

What happens

Any IAM operation that takes an integer parameter fails with 400 ValidationError when a real
SDK or the CLI sends it. Reproduced through the Go SDK against StartTestServer:

aws iam list-users --max-items 1
# ValidationError: invalid request body: json: cannot unmarshal string into Go
# struct field .MaxItems of type int

Every paginated IAM operation is affected — a caller that passes MaxItems at all gets an
error instead of a page — as is CreateRole --max-session-duration.

Why

Same root cause as #639, one layer along. IAM speaks the AWS query protocol, so
ParseAWSRequest flattens the form body into AWSRequest.Params, a map[string]string
(parser.go:44), and server.go:583-589 rebuilds req.Body as json.Marshal(req.Params).
Every value in that JSON object is therefore a string: {"MaxItems":"1"}.

parseIAMBody (iam_plugin.go:2572) is a plain json.Unmarshal, and the handlers declare

MaxItems int `json:"MaxItems"`

so encoding/json refuses the string outright. #639 fixed the list parameters, which
unmarshaled to nil silently; an integer is louder — it fails the whole request.

Affected declarations: iam_plugin.go:361, 411, 639, 738, 862, 998, 1124, 1301, 1465, 1906, 2220, 2399 and iam_groups.go:101, 252.

Why no test catches it

The same structural blind spot as #561/#610/#636/#639: iamRequest
(iam_plugin_test.go:40) hand-marshals a body containing a real JSON number, so the unit
suite never traverses the query → params → JSON path a real client takes. The IAM e2e journeys
that do go through the SDK never pass MaxItems — pagination is asserted at the unit level,
where the number is real.

This was found by probing ListUsers(MaxItems: 1) through the SDK while implementing #579,
not by any existing test.

Fix

A number type in emulator/iam_query.go (the query-protocol decoder #639 added) that accepts
either a JSON number or a JSON string, used for every IAM integer field. A boolean equivalent
too, so ListPolicies' OnlyAttached (#497) is not built with the defect already in it.

Acceptance criteria

  • MaxItems sent over the wire paginates instead of returning 400, on every paginated IAM
    operation.
  • CreateRole accepts MaxSessionDuration over the wire and reports it back from GetRole.
  • An IAM boolean parameter decodes from the wire, so IAM: ListPolicies ignores Scope and PathPrefix and never lists bundled managed policies #497 does not recreate this.
  • A malformed integer is ValidationError 400 naming the parameter, not a JSON-decoder
    message.
  • An e2e journey drives an integer IAM parameter through the SDK, so the class stays covered.

Activity

  1. added
    type: bug
    area: iam
    priority: high
    on Aug 14, 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: iampriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions