Skip to content
PATHBREAK
Attack paths Compliance How it works Attack map Pricing Blog
EnglishEspañolFrançaisDeutsch日本語한국어العربية
Log in Request a demo
Attack paths Compliance How it works Attack map Pricing Blog
EnglishEspañolFrançaisDeutsch日本語한국어العربية
Log in Request a demo
The Pathbreak Attack Map for AWS / EC2
Privilege escalation EC2 T1578

Hijack EC2 user-data

Can rewrite an instance's user-data and run code as its instance-profile role.

Grants escalation only in combination. All of these are needed together:

ec2:ModifyInstanceAttributeec2:StartInstancesec2:StopInstances
Key takeaway

ec2:ModifyInstanceAttribute can rewrite an instance's user-data and run code as its instance-profile role, but only when it is held together with ec2:StartInstances, ec2:StopInstances. Held together they reach administrator access.

ModifyInstanceAttribute runs as its role 01 Attacker principal 02 Existing compute 03 Its role 04 Administrator
How an attacker moves from this permission.
Explore this in Pathbreak

Why it is dangerous

A principal can stop the instance, rewrite its user-data with ec2:ModifyInstanceAttribute, and start it again; on boot the instance runs the attacker's user-data script as its already-attached instance-profile role, no iam:PassRole needed. A privileged instance profile means arbitrary code execution as that role: full privilege escalation against a box that was already trusted.

In MITRE ATT&CK terms this maps to T1578, Modify Cloud Compute Infrastructure, under the privilege escalation tactic. AWS records it in CloudTrail as ModifyInstanceAttribute, StopInstances, StartInstances. The call is loud in CloudTrail and stands out from normal activity.

Detection

ModifyInstanceAttributeStopInstancesStartInstances

Prerequisites

An existing instance with an instance profile; permission to stop/modify/start it.

MITRE ATT&CK

T1578 · Modify Cloud Compute Infrastructure

Tactic

Privilege Escalation

Breaking the path

A control that would remove it: Restrict ec2:ModifyInstanceAttribute on instances with attached instance profiles.

Whether to apply it depends on how the permission is used in your environment, so it is a business decision rather than an automatic fix. The same permission can be load-bearing in one account and pure risk in another.

Pathbreak confirms whether this path resolves in your account, ranks it against the others by how much it opens up, and uses your threat model and business context to show which paths are worth cutting.

Questions

What does ec2:ModifyInstanceAttribute allow?

Can rewrite an instance's user-data and run code as its instance-profile role.

What else is needed for ec2:ModifyInstanceAttribute to be dangerous?

It becomes an escalation only when held together with ec2:StartInstances, ec2:StopInstances. On its own it is not enough, which is what makes the combination easy to miss.

How is hijack EC2 user-data detected?

Watch for ModifyInstanceAttribute, StopInstances, StartInstances in CloudTrail. The call is loud in CloudTrail and stands out from normal activity.

How do you break this path?

A control that would remove it is: Restrict ec2:ModifyInstanceAttribute on instances with attached instance profiles. Whether to apply it depends on how the permission is used in your account, so it is a business decision rather than an automatic fix.

Which MITRE ATT&CK technique is this?

T1578, Modify Cloud Compute Infrastructure, under the privilege escalation tactic.

Related paths

Same servicePass role to EC2 fleetiam:PassRoleSame servicePass role to EKS node groupiam:PassRoleSame serviceInject user-data into EC2 launch templateec2:CreateLaunchTemplateVersionSame serviceHijack instance role via Instance Connectec2-instance-connect:SendSSHPublicKeySame servicePass role to Auto Scaling groupiam:PassRoleSame servicePass role to EC2iam:PassRole

References

  • https://attack.mitre.org/techniques/T1578/

Find this in your own account

We run a read-only scan of one AWS account and show you which of these paths exist, ranked by blast radius, with the change that breaks each one. First validated paths within the hour.

Request a free scan Watch the 7-minute walkthrough
PATHBREAK

Validated AWS attack paths, and the change that breaks each one.

Platform

Overview Attack paths How it works Pricing Attack map Threat actors Demo pathbreak-audit

Company

About Request a demo hello@pathbreak.io

Registered office

60 High Street
Wimbledon
London, England
SW19 5EE

Pathbreak Ltd · Company No. 17265710
© 2026 Pathbreak Ltd. All rights reserved.
Terms Privacy Security Trust
pathbreak.io