Files
floci/tools
Priamo Germosen a5afece703 fix(iam): check iam:PassRole on the roles an API Gateway request names (#9597)
AWS's Service Reference lists iam:PassRole for twelve API Gateway
operations, each passing its roles to apigateway.amazonaws.com. Floci
checked none: API Gateway is authorized by HTTP method, the passed-roles
table left the namespace out, and no member naming a role has a name the
table's rule knows (credentials, authorizerCredentials, credentialsArn,
authorizerCredentialsArn). An update names its role as a patch
operation's value, and an import inside its OpenAPI definition.

The roles are now checked for the operation the request's route resolves
to, which the table is keyed by, from three readings. A new vendored
source, tools/aws/sources/apigateway-roles.json, written by its own
script from the API references and developer guide, gives what they
read:

- The members that take a role, by the resource type each describes:
  "To specify an IAM role for API Gateway to assume, use the role's
  Amazon Resource Name (ARN)". PutIntegration, CreateIntegration,
  CreateAuthorizer, CreateApi and UpdateApi read them, REST APIs' and
  HTTP APIs' alike.
- A REST API update's patch operation, which names the property it
  changes by its path ("the path for this property is /name"): the
  value of the one whose path names a role member of the resource the
  update returns, so UpdateIntegration reads
  patchOperations[path=/credentials].value, UpdateAuthorizer
  /authorizerCredentials and UpdateAccount /cloudwatchRoleArn. The
  table gains a list step selecting the elements whose field holds a
  value.
- An import's OpenAPI definition, JSON or YAML: the
  x-amazon-apigateway-integration credentials of each Operation object,
  the ANY method's included, and the x-amazon-apigateway-authorizer
  authorizerCredentials of each security scheme, OpenAPI 2's and 3's,
  where the guide says each extension sits. ImportRestApi and PutRestApi
  take the whole body as the definition, ImportApi and ReimportApi a
  body member. The definition is read as its service takes
  and reads it, through a new PassedRoleLookup hook given the whole body:
  API Gateway resolves a REST API definition's ${AWS::Region},
  ${AWS::AccountId} and ${AWS::Partition} before importing it, so a role
  written with them is checked too, and takes an HTTP API's from its
  body's body (the REST route's envelope) or Body (the JSON 1.1
  handler's), or else the whole body, which the REST route also takes.

A REST JSON model's member is also read by its botocore name where its
wire name differs: Floci serves HTTP APIs over JSON 1.1 too
(AmazonApiGatewayV2.*), whose bodies name members as botocore does
(CredentialsArn, Body), and its handler takes either spelling as the
same member.

apigateway joins the passed-roles namespaces with all twelve operations
read and nothing added to the hand lists.
2026-11-27 14:21:56 -04:00
..