1. Resources
  2. Detection rules
  3. Role Passed to CloudFormation or Glue (PassRole Escalation)

Role Passed to CloudFormation or Glue (PassRole Escalation) detection rules

An attacker with iam:PassRole hands a more privileged role to CloudFormation or to AWS Glue, then has the service create resources or run code with that role's permissions.

Platform
AWS
Severity
High
Log source
AWS CloudTrail
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
The iam:PassRole permission on a privileged role that trusts CloudFormation or Glue, plus the right to create a stack, an endpoint, a job or a session.
Impact
The service creates resources or runs code with the passed role's permissions, which is full account control if the role can modify IAM.
Response
Delete or roll back the stack, endpoint, job or session, revoke the active sessions of the passed role, and contain the principal that made the call.
Mitigation
Scope iam:PassRole to specific role ARNs with iam:PassedToService, and keep CloudFormation service roles and Glue roles least-privilege.
CloudTrail events
CreateStackUpdateStackCreateChangeSetStartBuildStartBuildBatchCreateProjectUpdateProjectRunTaskStartTaskCreateDevEndpointUpdateDevEndpointCreateJoband 6 more in the rules below
Threat groups
None listed in MITRE ATT&CK for this technique

How the attack works

Many AWS services act with a role that the caller passes to them, and the caller needs iam:PassRole on that role. Whoever may pass a privileged role to a service that does work on request gets that role's permissions without ever assuming it. Two services make this especially direct. CloudFormation accepts a service role on CreateStack, UpdateStack and CreateChangeSet, and then creates, changes and deletes the resources of the template with the role's credentials instead of the caller's. AWS Glue runs code under a role: a development endpoint (CreateDevEndpoint) is an environment for developing scripts that the creator reaches over SSH with a key they supply, a job (CreateJob) runs a script, and an interactive session (CreateSession) runs statements, each with the role named in the request.

Both services also have a path that needs no PassRole at all. AWS documents that CloudFormation keeps using the service role of a stack for every later operation, and that other users who may operate on the stack use the role whether or not they hold iam:PassRole. In Glue, UpdateDevEndpoint adds an SSH public key to an existing endpoint, which gives the caller a shell where the endpoint's role is already attached.

iam:PassRole is a permission, not an API call, and AWS states that no CloudTrail record is generated for it: the role appears only in the call that gave it to the service. CloudFormation and Glue log all of their API actions in CloudTrail. AWS's example records for CreateStack and UpdateStack show requests without a service role, so the CloudFormation rule reads the role from the field that the API parameter RoleARN becomes, and says so. The Glue rules match event names only. These paths come from published lists of AWS privilege escalation methods, and no incident report was used for this page. The same step exists in other services that run code under a role, and the page has rules for three of them: an ECS task run with a task role override, a CodeBuild build started with a service role or build specification override, and a SageMaker notebook instance, which runs with an execution role and with the scripts of its lifecycle configuration. For CodeBuild AWS publishes an example record of CreateProject that shows the role in responseElements.project.serviceRole.

What an attacker needs

  • Credentials for a principal allowed iam:PassRole on a privileged role that trusts cloudformation.amazonaws.com or glue.amazonaws.com.
  • For CloudFormation, cloudformation:CreateStack, UpdateStack or CreateChangeSet. For Glue, glue:CreateDevEndpoint, glue:CreateJob with the right to start the job, or glue:CreateSession with the right to run statements.
  • For the variants without PassRole, the right to update a stack that already has a privileged service role, or glue:UpdateDevEndpoint on an endpoint that already has a privileged role.

Impact

The attacker makes the service act with the passed role. Through CloudFormation that means creating or changing any resource the role may manage, including IAM users, roles and policies. Through Glue it means running code that can call AWS with the role's credentials. If the role is an administrator or can modify IAM, the result is full control of the account.

Detection rules

CloudFormation Stack Created or Updated with a Service Role

Detects CloudFormation CreateStack, UpdateStack and CreateChangeSet calls that pass a service role. Without a role CloudFormation works with a temporary session made from the caller's own credentials, which is no escalation. With a role it creates, changes and deletes the resources of the template with the role's credentials, and AWS documents that it keeps using that role for every later operation on the stack. The caller needs iam:PassRole on the role, and the question for triage is whether the role can do more than the caller. The role is read from requestParameters.roleARN, which is the RoleARN parameter of the CloudFormation API with its first letter in lower case, the form AWS's example records use for other parameters (templateURL, stackName). Those examples show requests without a role, so confirm the field in your own events. An update of a stack that already has a service role carries no role and is not matched (see the detection logic on the page). It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: CloudFormation Stack Created or Updated with a Service Role
id: aa585051-36e1-44fc-89e6-59a899908ef6
status: experimental
description: >-
  Detects CloudFormation CreateStack, UpdateStack and CreateChangeSet calls
  that pass a service role. Without a role CloudFormation works with a
  temporary session made from the caller's own credentials, which is no
  escalation. With a role it creates, changes and deletes the resources of
  the template with the role's credentials, and AWS documents that it keeps
  using that role for every later operation on the stack. The caller needs
  iam:PassRole on the role, and the question for triage is whether the role
  can do more than the caller. The role is read from
  requestParameters.roleARN, which is the RoleARN parameter of the
  CloudFormation API with its first letter in lower case, the form AWS's
  example records use for other parameters (templateURL, stackName). Those
  examples show requests without a role, so confirm the field in your own
  events. An update of a stack that already has a service role carries no
  role and is not matched (see the detection logic on the page).
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-servicerole.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-api-logging-cloudtrail.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: cloudformation.amazonaws.com
    eventName:
      - CreateStack
      - UpdateStack
      - CreateChangeSet
    requestParameters.roleARN|exists: true
  condition: selection
falsepositives:
  - Deployment pipelines and infrastructure-as-code tools that deploy every stack with a service role, which is a recommended practice. Add the pipeline roles to a filter_* selection on userIdentity.arn and keep alerting on stacks that people or unknown roles create with a role.
level: medium

False positives

  • Deployment pipelines and infrastructure-as-code tools that deploy every stack with a service role, which is a recommended practice. Add the pipeline roles to a filter_* selection on userIdentity.arn and keep alerting on stacks that people or unknown roles create with a role.

CodeBuild Build Started with a Service Role or Buildspec Override

Detects StartBuild and StartBuildBatch calls to AWS CodeBuild that override the service role or the build specification of the project. A build runs the commands of its build specification with the service role of the project. The serviceRoleOverride parameter, which AWS describes as the name of a service role for this build that overrides the one specified in the build project, lets the caller choose another role, and buildspecOverride replaces the commands. With the first a principal that may pass a privileged role runs a build under it. With the second a principal that may only start builds runs its own commands under the role the project already has, with no iam:PassRole. Both fields follow the request parameters of the CodeBuild API reference and do not come from an example record, so confirm them in your own events. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: CodeBuild Build Started with a Service Role or Buildspec Override
id: 137c4e46-0da3-4232-9f10-3a1255c18b28
status: experimental
description: >-
  Detects StartBuild and StartBuildBatch calls to AWS CodeBuild that
  override the service role or the build specification of the project. A
  build runs the commands of its build specification with the service role
  of the project. The serviceRoleOverride parameter, which AWS describes as
  the name of a service role for this build that overrides the one
  specified in the build project, lets the caller choose another role, and
  buildspecOverride replaces the commands. With the first a principal that
  may pass a privileged role runs a build under it. With the second a
  principal that may only start builds runs its own commands under the role
  the project already has, with no iam:PassRole. Both fields follow the
  request parameters of the CodeBuild API reference and do not come from an
  example record, so confirm them in your own events.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html
  - https://docs.aws.amazon.com/codebuild/latest/userguide/understanding-service-name-entries.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection_event:
    eventSource: codebuild.amazonaws.com
    eventName:
      - StartBuild
      - StartBuildBatch
  selection_role:
    requestParameters.serviceRoleOverride|exists: true
  selection_buildspec:
    requestParameters.buildspecOverride|exists: true
  condition: selection_event and (selection_role or selection_buildspec)
falsepositives:
  - Pipelines and developer tools that start builds with an inline build specification, for example to reuse one project for several jobs. Add those roles to a filter_* selection on userIdentity.arn and keep alerting on overrides by people or unknown roles.
level: medium

False positives

  • Pipelines and developer tools that start builds with an inline build specification, for example to reuse one project for several jobs. Add those roles to a filter_* selection on userIdentity.arn and keep alerting on overrides by people or unknown roles.

CodeBuild Project Created or Updated

Detects CreateProject and UpdateProject calls to AWS CodeBuild. A build project carries a service role, and every build of the project runs its commands with that role. A principal that may pass a privileged role can create a project with it, or change the role, the source or the build specification of an existing project, and then run code under the role. AWS publishes an example record for CreateProject, in which the role of the new project is in responseElements.project.serviceRole. Project changes are deployment work in most accounts, so the rule matches the event names only and its level is low: scope it to callers outside the deployment roles and compare the service role with the caller. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelLowStatusExperimentalLog sourceAWS CloudTrail
title: CodeBuild Project Created or Updated
id: 85dfc1f3-af31-419e-a56e-bc6952f6be96
status: experimental
description: >-
  Detects CreateProject and UpdateProject calls to AWS CodeBuild. A build
  project carries a service role, and every build of the project runs its
  commands with that role. A principal that may pass a privileged role can
  create a project with it, or change the role, the source or the build
  specification of an existing project, and then run code under the role.
  AWS publishes an example record for CreateProject, in which the role of
  the new project is in responseElements.project.serviceRole. Project
  changes are deployment work in most accounts, so the rule matches the
  event names only and its level is low: scope it to callers outside the
  deployment roles and compare the service role with the caller.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/codebuild/latest/userguide/understanding-service-name-entries.html
  - https://docs.aws.amazon.com/codebuild/latest/userguide/cloudtrail.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: codebuild.amazonaws.com
    eventName:
      - CreateProject
      - UpdateProject
  condition: selection
falsepositives:
  - Infrastructure-as-code pipelines and developers who set up or change build projects. Useful only after the deployment roles are excluded with a filter_* selection on userIdentity.arn.
level: low

False positives

  • Infrastructure-as-code pipelines and developers who set up or change build projects. Useful only after the deployment roles are excluded with a filter_* selection on userIdentity.arn.

ECS Task Run with a Task Role Override

Detects RunTask and StartTask calls to Amazon ECS that override the task role. A task definition names the IAM role that the containers of a task can assume, and the overrides of a run request can replace it with another role for that one task. A principal that may pass a privileged role and run a task can therefore run a container under that role without registering anything new, which is rarer than a deployment and a direct PassRole escalation step. AWS documents that CloudTrail captures all ECS API calls. The override is read from requestParameters.overrides.taskRoleArn, which follows the taskRoleArn member of the overrides parameter in the ECS API reference: it does not come from an example record, so confirm the field in your own events. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: ECS Task Run with a Task Role Override
id: 5c83a6e7-3a8a-4082-98ca-faa9dfb046a2
status: experimental
description: >-
  Detects RunTask and StartTask calls to Amazon ECS that override the task
  role. A task definition names the IAM role that the containers of a task
  can assume, and the overrides of a run request can replace it with
  another role for that one task. A principal that may pass a privileged
  role and run a task can therefore run a container under that role without
  registering anything new, which is rarer than a deployment and a direct
  PassRole escalation step. AWS documents that CloudTrail captures all ECS
  API calls. The override is read from requestParameters.overrides.taskRoleArn,
  which follows the taskRoleArn member of the overrides parameter in the ECS
  API reference: it does not come from an example record, so confirm the
  field in your own events.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/logging-using-cloudtrail.html
  - https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskOverride.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: ecs.amazonaws.com
    eventName:
      - RunTask
      - StartTask
    requestParameters.overrides.taskRoleArn|exists: true
  condition: selection
falsepositives:
  - Schedulers and workflow tools that run one task definition with a different role for each job. They use the same roles every time, so add them to a filter_* selection on userIdentity.arn.
level: medium

False positives

  • Schedulers and workflow tools that run one task definition with a different role for each job. They use the same roles every time, so add them to a filter_* selection on userIdentity.arn.

Glue Development Endpoint Created or Updated

Detects CreateDevEndpoint and UpdateDevEndpoint calls to AWS Glue. A development endpoint is an environment for developing Glue scripts that runs with an IAM role and that its users reach over SSH with a key pair. CreateDevEndpoint takes the role (RoleArn) and the public key or keys of the people who may connect, so a principal that can pass a privileged role gets a shell with that role. UpdateDevEndpoint can add public keys to an existing endpoint, which gives the caller access to the role that is already attached and needs no iam:PassRole. AWS documents that all Glue actions are logged by CloudTrail and publishes no example record for these two, so the rule matches the event names only. Development endpoints are uncommon, which keeps the rule quiet: read the role and the keys of the request and ask the data team whether the endpoint is theirs. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: Glue Development Endpoint Created or Updated
id: 6155dde1-0aa5-4fb7-9731-8ae6d89c5426
status: experimental
description: >-
  Detects CreateDevEndpoint and UpdateDevEndpoint calls to AWS Glue. A
  development endpoint is an environment for developing Glue scripts that
  runs with an IAM role and that its users reach over SSH with a key pair.
  CreateDevEndpoint takes the role (RoleArn) and the public key or keys of
  the people who may connect, so a principal that can pass a privileged role
  gets a shell with that role. UpdateDevEndpoint can add public keys to an
  existing endpoint, which gives the caller access to the role that is
  already attached and needs no iam:PassRole. AWS documents that all Glue
  actions are logged by CloudTrail and publishes no example record for these
  two, so the rule matches the event names only. Development endpoints are
  uncommon, which keeps the rule quiet: read the role and the keys of the
  request and ask the data team whether the endpoint is theirs.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/glue/latest/dg/monitor-cloudtrail.html
  - https://docs.aws.amazon.com/glue/latest/webapi/API_CreateDevEndpoint.html
  - https://docs.aws.amazon.com/glue/latest/webapi/API_UpdateDevEndpoint.html
  - https://docs.aws.amazon.com/glue/latest/dg/dev-endpoints.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: glue.amazonaws.com
    eventName:
      - CreateDevEndpoint
      - UpdateDevEndpoint
  condition: selection
falsepositives:
  - Data engineers who still work with development endpoints, and updates that change libraries or arguments of an endpoint without touching its keys. Add the roles of that team to a filter_* selection on userIdentity.arn.
level: medium

False positives

  • Data engineers who still work with development endpoints, and updates that change libraries or arguments of an endpoint without touching its keys. Add the roles of that team to a filter_* selection on userIdentity.arn.

Glue Job or Interactive Session Created or Job Updated

Detects CreateJob, UpdateJob and CreateSession calls to AWS Glue. A job runs a script and an interactive session runs statements, each under the IAM role that the request names (the Role parameter, which is required for a new job and a new session). A principal that can pass a privileged role to Glue can therefore run code with that role, and a principal that can update a job can change what an existing job runs under the role it already has. AWS documents that all Glue actions are logged by CloudTrail and publishes no example record for these calls, so the rule matches the event names only. Every job deployment and every notebook session matches: scope the rule to callers outside the data engineering and deployment roles, or use it as a hunting query, and check what the role of the request can do compared with the caller. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelLowStatusExperimentalLog sourceAWS CloudTrail
title: Glue Job or Interactive Session Created or Job Updated
id: 75901d75-ccb7-422a-a3a0-9059cf7dcd65
status: experimental
description: >-
  Detects CreateJob, UpdateJob and CreateSession calls to AWS Glue. A job
  runs a script and an interactive session runs statements, each under the
  IAM role that the request names (the Role parameter, which is required for
  a new job and a new session). A principal that can pass a privileged role
  to Glue can therefore run code with that role, and a principal that can
  update a job can change what an existing job runs under the role it
  already has. AWS documents that all Glue actions are logged by CloudTrail
  and publishes no example record for these calls, so the rule matches the
  event names only. Every job deployment and every notebook session
  matches: scope the rule to callers outside the data engineering and
  deployment roles, or use it as a hunting query, and check what the role of
  the request can do compared with the caller.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/glue/latest/dg/monitor-cloudtrail.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: glue.amazonaws.com
    eventName:
      - CreateJob
      - UpdateJob
      - CreateSession
  condition: selection
falsepositives:
  - Every job deployment by pipelines and every interactive session that data engineers start from notebooks. Useful only after it is limited to callers outside those roles.
level: low

False positives

  • Every job deployment by pipelines and every interactive session that data engineers start from notebooks. Useful only after it is limited to callers outside those roles.

SageMaker Notebook Instance Created or Its Lifecycle Configuration Changed

Detects CreateNotebookInstance, UpdateNotebookInstance, CreateNotebookInstanceLifecycleConfig and UpdateNotebookInstanceLifecycleConfig calls to Amazon SageMaker AI. A notebook instance runs with an IAM execution role (the RoleArn parameter), and a lifecycle configuration holds scripts that run on the instance when it is created or started. A principal that may pass a privileged role can create a notebook with it, and a principal that may change a notebook or its lifecycle configuration can have its own script run under the role the notebook already has. AWS documents that CloudTrail captures all SageMaker AI API calls and publishes no example record for these four, so the rule matches the event names only and its level is low. Read the role and the lifecycle configuration name from the request, and check what the role can do compared with the caller. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelLowStatusExperimentalLog sourceAWS CloudTrail
title: SageMaker Notebook Instance Created or Its Lifecycle Configuration Changed
id: a77bd6c4-c993-4e1d-9720-876ba28cdbde
status: experimental
description: >-
  Detects CreateNotebookInstance, UpdateNotebookInstance,
  CreateNotebookInstanceLifecycleConfig and
  UpdateNotebookInstanceLifecycleConfig calls to Amazon SageMaker AI. A
  notebook instance runs with an IAM execution role (the RoleArn parameter),
  and a lifecycle configuration holds scripts that run on the instance when
  it is created or started. A principal that may pass a privileged role can
  create a notebook with it, and a principal that may change a notebook or
  its lifecycle configuration can have its own script run under the role
  the notebook already has. AWS documents that CloudTrail captures all
  SageMaker AI API calls and publishes no example record for these four, so
  the rule matches the event names only and its level is low. Read the role
  and the lifecycle configuration name from the request, and check what the
  role can do compared with the caller.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/sagemaker/latest/dg/logging-using-cloudtrail.html
  - https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateNotebookInstance.html
  - https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-sagemaker-notebookinstancelifecycleconfig.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: sagemaker.amazonaws.com
    eventName:
      - CreateNotebookInstance
      - UpdateNotebookInstance
      - CreateNotebookInstanceLifecycleConfig
      - UpdateNotebookInstanceLifecycleConfig
  condition: selection
falsepositives:
  - Data science teams that create notebooks and maintain their lifecycle scripts, and the pipelines that deploy them. Add those roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.
level: low

False positives

  • Data science teams that create notebooks and maintain their lifecycle scripts, and the pipelines that deploy them. Add those roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Stack that already has a service role changed by a principal outside the deployment roles

Detection hypothesisCompares with an earlier valueNeeds your own lists

A stack keeps its service role for every later operation, and whoever may update the stack uses the role without passing it. That update carries no role in the request, so it can only be found by knowing which stacks have a role and who normally deploys them.

  1. Build a list of the stacks that have a service role. The stack description returned by CloudFormation carries it as RoleARN.
  2. Collect UpdateStack, CreateChangeSet, ExecuteChangeSet and DeleteStack events from cloudformation.amazonaws.com and read the stack in requestParameters.stackName.
  3. Alert when the stack is on the list and the caller in userIdentity.arn is not one of the roles that deploy it.

EventsUpdateStackCreateChangeSetExecuteChangeSetDeleteStack

LimitsIt needs an inventory of stacks with their roles and a list of deployment roles, both kept current. The request may name the stack by its name or by its ID. An emergency change by an administrator looks the same.

Role passed to CloudFormation or Glue is on your list of privileged roles

Detection hypothesisNeeds your own lists

Pipelines pass ordinary deployment and data roles all day. The call that matters is the one that passes an administrator or IAM-capable role, and only your own list of privileged roles tells the two apart.

  1. Collect CreateStack, UpdateStack and CreateChangeSet events from cloudformation.amazonaws.com and CreateDevEndpoint, CreateJob and CreateSession events from glue.amazonaws.com.
  2. Read the role of the request: the RoleARN parameter for CloudFormation, RoleArn for a development endpoint, Role for a job or a session.
  3. Compare it with your list of privileged roles and alert on a match.

EventsCreateStackUpdateStackCreateChangeSetCreateDevEndpointCreateJobCreateSession

LimitsIt needs a maintained list of privileged roles. The role parameters come from the API references, and AWS publishes no example record that shows them, so confirm the fields in your own events first.

ECS task definition registered with a task role by a principal outside the deployment roles

Detection hypothesisNeeds your own listsSequence of events

A task definition names the IAM role that the containers of the task can assume. Every deployment registers one, so the event alone says nothing. A registration by a principal that does not deploy services, followed by a task that runs it, is code running under a role its author chose.

  1. Collect RegisterTaskDefinition events from ecs.amazonaws.com and read the task role of the request (the taskRoleArn parameter of the API) and the caller in userIdentity.arn.
  2. Leave out the roles of your deployment pipelines.
  3. For the rest, compare the task role with your list of privileged roles, and look for a RunTask or CreateService event by the same caller that uses the new task definition.

EventsRegisterTaskDefinitionRunTaskCreateService

LimitsIt needs a list of deployment roles and of privileged roles. The task role parameter comes from the ECS API reference and not from an example record, so confirm the field in your own events first.

Triage

  • Identify the caller (userIdentity.arn), the source IP address and the user agent. Is it a deployment pipeline or a data engineering role that normally does this?
  • Find the role that was passed and check what it can do compared with the caller. For CloudFormation it is the service role of the stack named in requestParameters.stackName.
  • For CloudFormation, read the template of the stack or the change set and look at the resources it creates, with priority on IAM resources.
  • For a Glue development endpoint, check who supplied the public key and whether anyone in the data team asked for the endpoint. For a job or a session, read the script location or the statements and check what ran.
  • Review CloudTrail for the calls made by the role's sessions after the event, which show what the service did on the caller's behalf.

Response

Once the attack is confirmed:

  1. Stop the service from acting for the attacker. Delete the stack or roll it back to the last version the pipeline deployed, delete the development endpoint or remove the unknown public key, and stop and delete the job or session.
  2. Revoke the active sessions of the passed role, so that credentials already obtained through the service stop working.
  3. Review CloudTrail for what the role's sessions did, and remove what they created, such as users, access keys, roles and policy changes.
  4. Contain the principal that made the call, and take away its iam:PassRole on the privileged role.
  5. Check the other stacks, endpoints and jobs that use the same role for changes nobody deployed.

Mitigation

  • Scope iam:PassRole to specific role ARNs and add the condition key iam:PassedToService, so that a role meant for one service cannot be passed to another. Never allow it on Resource "*".
  • Give CloudFormation service roles only the permissions their stacks need, because AWS documents that everyone who may operate on the stack uses the role.
  • Restrict stack operations on stacks with privileged service roles to deployment pipelines.
  • Allow glue:CreateDevEndpoint, glue:UpdateDevEndpoint and glue:CreateSession only to the data engineers who need them, and keep Glue roles limited to the data they process.
  • Do not let administrator roles trust cloudformation.amazonaws.com or glue.amazonaws.com.

Frequently asked questions

Why can I not alert on iam:PassRole directly?

`iam:PassRole` is a permission, not an API call, and AWS states that no CloudTrail logs are generated for it. To see which role was passed to which service, you have to read the event that created or modified the resource that received the role. That is why each service needs a rule of its own on its create and update calls.

Can someone use a stack's service role without having iam:PassRole?

Yes. AWS documents that once a service role is specified, CloudFormation always uses it for all operations on that stack, that it cannot be removed, and that other users who may operate on the stack use the role whether or not they have `iam:PassRole`. An update of such a stack carries no role in the request, so the rule on this page does not match it.

Why are the Glue rules on event names only?

AWS documents that all Glue actions are logged, and its example records show other actions. The role and the public key are request parameters of the Glue API reference, and no AWS example shows them in a record. A development endpoint is rare enough to alert on by name. Jobs and sessions are everyday work in data teams, so that rule is a low-level one to scope.

Do other services have the same escalation path?

Yes. Any service that accepts a role and then does work on request can be used this way, and the library has a separate page for Lambda and one for EC2 instance profiles. This page covers CloudFormation and Glue in depth and has rules for ECS task role overrides, CodeBuild builds and SageMaker notebook instances. For other services, look at the create and update calls that take a role.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.