Skip to content

IAM: UpdateAssumeRolePolicy is unimplemented, so a role's trust policy cannot be changed after CreateRole #594

Closed

Description

@scttfrdmn

What

iam:UpdateAssumeRolePolicy is not implemented. CreateRole is the only operation that can set a role's trust policy, so once a role exists its AssumeRolePolicyDocument cannot be changed.

Found while fixing #593, which assumed the document was "stored by CreateRole/UpdateAssumeRolePolicy" — the second half does not exist in the IAM operation switch.

Why it matters now

Before #593 this was invisible: nothing read the trust policy, so being unable to change it cost nothing. Now that AssumeRole evaluates it, the document is load-bearing and a consumer cannot correct or tighten one after creation. Two shapes this blocks:

  • IaC that creates a role and then narrows its trust policy in a second pass — a common CDK/Terraform update-in-place pattern; a test replaying that update silently keeps the original policy, so the tightening it is meant to verify is unobservable.
  • A test wanting to prove both halves of a confused-deputy gate on one role (assume with the ExternalId, tighten to another account, assume again and expect a denial) currently has to create two roles, which is not what the code under test does.

Acceptance criteria

  • UpdateAssumeRolePolicy accepts RoleName + PolicyDocument, replaces the stored AssumeRolePolicyDocument, and returns the empty response shape (UpdateAssumeRolePolicyResponse with only ResponseMetadata).
  • NoSuchEntity for an unknown role, with the message AWS uses.
  • MalformedPolicyDocument for a document that does not parse, matching how createRole validates today.
  • Read-back through GetRole reflects the new document, URL-decoded consistently with CreateRole's storage.
  • The new document takes effect on the next AssumeRole — a test that assumes successfully, tightens the policy to another account, and assumes again expecting AccessDenied (the STS: AssumeRole does not evaluate the role's trust policy, so no ExternalId or Principal condition is enforced #593 gate, exercised through an update rather than a second role).
  • Existing sessions minted under the old policy are unaffected; AWS does not revoke them, and substrate should not either.
  • docs/services.md row added (regenerate with make docs-reference); CHANGELOG entry under Added.

Verify request/response shape and error codes against the UpdateAssumeRolePolicy API reference rather than assumption.

Activity

  1. added
    area: iam
    area: server
    type: feature
    on Aug 9, 2026
  2. added this to the v0.96.0 milestone on Aug 9, 2026
  3. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    Milestoned v0.96.0, alongside #595.

    Confirmed the report against main (d905e92, v0.95.0): grep -rn UpdateAssumeRolePolicy emulator/ returns zero matches — the operation is absent from the IAM switch entirely, so it currently falls through to InvalidAction.

    The pattern to mirror

    createRole at iam_plugin.go:392-397 is the existing shape for this, and following it answers two of the acceptance criteria directly:

    var trustPolicy PolicyDocument
    if params.AssumeRolePolicyDocument != "" {
    	if err := json.Unmarshal([]byte(params.AssumeRolePolicyDocument), &trustPolicy); err != nil {
    		return iamErrorResponse("MalformedPolicyDocument", //nolint:nilerr
    			"AssumeRolePolicyDocument is not valid JSON.", http.StatusBadRequest), nil
    	}
    }

    Two details worth carrying across rather than rediscovering:

    1. The document is stored typed, not as a string. iam_types.go:38 declares AssumeRolePolicyDocument PolicyDocument, so the update unmarshals into the same type and the "URL-decoded consistently with CreateRole's storage" criterion is satisfied by reusing this path rather than by adding a decode step.
    2. PolicyDocument is what STS: AssumeRole does not evaluate the role's trust policy, so no ExternalId or Principal condition is enforced #593's gate reads, so an update that stores through this type takes effect on the next AssumeRole with no further wiring — which is what makes the tighten-then-deny test in the criteria straightforward to write.

    Unlike CreateRole, PolicyDocument is required on UpdateAssumeRolePolicy, so an absent one is MissingParameter/400 rather than an empty document — worth pinning, since the createRole code above treats empty as legitimate.

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: iamarea: servertype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions