Back to Blog
April 14, 2026

Stop Cloud Privilege Escalation with Pentesting

Imagine this. An attacker gets their hands on a single set of leaked AWS or Azure credentials. Maybe it was an engineer who accidentally pushed a .env file to a public GitHub repo, or perhaps a phishing email worked on a junior dev. On the surface, it doesn't look like a disaster. The credentials only belong to a low-level "Read Only" user or a limited service account with access to one small S3 bucket. You might think, okay, that's a nuisance, but they can't actually do anything.

But that’s where you're wrong. In a cloud environment, a "low-level" entry point is often just the first step in a chain of events called privilege escalation. Within minutes, that attacker isn't just looking at one bucket; they've found a way to assume a more powerful role, hijacked an administrative token, and now they have full control over your entire production environment. They can delete your backups, steal your customer database, or deploy crypto-miners that run up a six-figure bill in a weekend.

Cloud privilege escalation is different from traditional on-prem escalation. You aren't just looking for a buggy kernel or a misconfigured sudoers file. You're dealing with complex Identity and Access Management (IAM) policies, service-linked roles, and a dizzying array of cloud-native permissions that are almost impossible to track manually.

The only way to know if your "locked down" cloud is actually secure is to try and break into it. That’s where penetration testing comes in. By simulating these exact attack paths, you can find the holes before someone with bad intentions does.

What Exactly is Cloud Privilege Escalation?

Before we get into how to stop it, we need to be clear about what we're fighting. Privilege escalation is the act of gaining a higher level of permission than what was originally intended. In the cloud, this usually happens in two ways: vertical escalation and horizontal escalation.

Vertical Privilege Escalation

This is the classic "climbing the ladder" scenario. An attacker starts as a standard user and finds a path to become an Administrator. For example, they might discover they have the iam:CreatePolicyVersion permission. At first glance, that seems specific. But in reality, that permission allows them to change their own policy to grant themselves AdministratorAccess. Just like that, they've jumped from a restricted user to the king of the hill.

Horizontal Privilege Escalation

This is more of a "side-step." Here, the attacker doesn't necessarily get more power, but they get different power. They might move from one user account to another user account that has the same level of privilege but access to different data. If they are in a multi-tenant environment or a company with many separate project folders, horizontal movement allows them to scrape data from across the organization until they find a "juicy" account that allows for vertical escalation.

Why the Cloud Makes This Easier

In a traditional data center, movement is often limited by network segmentation (VLANs, firewalls). In the cloud, the primary perimeter isn't the network—it's Identity. If your IAM policies are too broad, the "network" is essentially open. One misconfigured role can act as a bridge, allowing an attacker to jump from a public-facing web server directly into your secrets manager.

Common Paths Attackers Use to Escalate Privileges

Attackers don't usually guess their way to the top; they follow known patterns. If you understand these patterns, you can build defenses against them.

1. Over-privileged Service Accounts

This is the most common culprit. Developers often give a virtual machine (like an EC2 instance or an Azure VM) a "Managed Identity" or an "IAM Role" so the app can talk to a database. To save time during development, they often give that role Contributor or PowerUser access.

If an attacker finds a Server-Side Request Forgery (SSRF) vulnerability in the web app, they can query the cloud metadata service (IMDS). This service literally hands over the temporary security credentials for the role attached to that machine. Now the attacker is operating with those high-level permissions from their own laptop.

2. The "PassRole" Trap

In AWS, the iam:PassRole permission is a frequent source of escalation. It allows a user to assign a role to a resource. If a user has iam:PassRole and the permission to create a new Lambda function, they can simply create a Lambda function, assign it the AdministratorAccess role, and then trigger that function to create a new admin user for themselves. They didn't have admin rights, but they had the right to give admin rights to a tool they controlled.

3. Misconfigured Trust Relationships

Cloud roles often have "trust policies" that define who can assume them. If a trust policy is too permissive—for example, allowing any authenticated user in the organization to assume a specialized "Backup" role—an attacker who compromises any single employee account can now jump into that Backup role, which likely has broad read access to every single piece of data in the cloud.

4. Token Theft and Session Hijacking

Cloud consoles use session tokens. If an attacker can steal a session cookie via XSS or find a developer's .aws/credentials file in a public snapshot, they don't need to crack a password. They simply "become" that user. If that user happens to be a DevOps engineer with high privileges, the game is over.

Why Automated Scanning Isn't Enough

You've probably used a cloud security posture management (CSPM) tool. These are great for finding "low-hanging fruit" like open S3 buckets or disabled MFA. But CSPMs are generally "static." They look at a configuration and say, "This looks wrong."

Privilege escalation is "dynamic." It's about the relationship between different permissions. A CSPM might tell you that User A has iam:CreatePolicyVersion, and it might not even flag it as a high risk because that's a common permission for some admins. However, a penetration tester looks at User A and asks: “Can this user use this specific permission to change their own role and become an admin?”

The answer to that question requires a chain of logic:

  1. Check current permissions $\rightarrow$ 2. Identify "dangerous" permissions $\rightarrow$ 3. Test if those permissions can be used to modify the current identity $\rightarrow$ 4. Execute the escalation.

Automated tools struggle with this chain. They see the individual bricks, but they don't see the bridge the attacker is building. This is why manual and semi-automated penetration testing—the kind offered by platforms like Penetrify—is non-negotiable for serious security.

How Penetration Testing Stops Escalation

Pentesting doesn't just find bugs; it validates your entire security model. Here is how a structured pentesting approach specifically kills privilege escalation paths.

Mapping the Attack Surface

A pentester starts by mapping out every entry point. This includes public APIs, forgotten dev environments, and third-party integrations. By finding the "weakest" entry point, they can simulate how a real attacker would enter your system.

Testing the "Blast Radius"

Once an entry point is found, the tester tries to determine the blast radius. If they compromise a small microservice, can they reach the database? Can they modify the network configuration? By documenting exactly how far they can go, they show you the real-world impact of your IAM settings.

Identifying "Shadow Admin" Privileges

There are users in your system who aren't labeled as "Admins" but effectively are. These are called "Shadow Admins." They might have the ability to reset passwords or modify group memberships. A pentester will hunt for these hidden paths that your audit logs might be ignoring.

Validating Monitoring and Alerting

The most dangerous part of privilege escalation is that it's often silent. Many companies only realize they've been breached when their data appears on a leak site. A pentest tests your SOC (Security Operations Center). Did your alerts fire when a low-level user suddenly started calling CreateUser or AttachUserPolicy? If not, you have a visibility problem that is just as dangerous as the permission problem.

A Step-by-Step Guide to Hardening Your Cloud Permissions

While pentesting finds the holes, you need a strategy to plug them. You can't just remove every permission—your developers will stop being able to work. Instead, focus on these specific hardening steps.

1. Implement a Strict "Least Privilege" Model

Stop using managed policies like AdministratorAccess or PowerUserAccess for human users. Create custom policies that grant only the specific actions required for a job.

  • Bad: Giving a developer s3:* access.
  • Good: Giving a developer s3:GetObject and s3:PutObject only for the specific buckets they need for their project.

2. Use Permission Boundaries (AWS Example)

Permission boundaries are a powerful way to stop escalation. A boundary is a policy that sets the maximum permissions an identity can have. Even if a user has a policy that grants them AdministratorAccess, if their Permission Boundary says they cannot touch IAM settings, they are blocked. This effectively kills the iam:PassRole and iam:CreatePolicyVersion attack vectors.

3. Enforce Just-In-Time (JIT) Access

Why does an engineer need Admin access 24/7? They don't. Implement a system where users have zero permanent privileges. When they need to do a specific task, they request elevated access, which is granted for a limited window (e.g., 2 hours) and then automatically revoked. This shrinks the window of opportunity for an attacker who steals a credential.

4. Audit Your Service Roles

Go through every single VM, Lambda function, and Container. Ask: Does this need a role? And if it does, does it have too much power? Use tools to analyze "last used" permissions. If a service role has 50 permissions but has only used 5 of them in the last 90 days, strip the other 45.

5. Lock Down the Metadata Service

If you're using AWS, move to IMDSv2. Unlike IMDSv1, it requires a session-oriented token, which makes it significantly harder for an attacker to use an SSRF vulnerability to steal cloud credentials.

Comparison: Static Analysis vs. Penetration Testing

To better understand why you need a combined approach, let's look at how these two methods handle a typical privilege escalation scenario.

Feature Static Analysis (CSPM) Penetration Testing (e.g., Penetrify)
Detection Method Checks config against a checklist. Actively tries to exploit the config.
Context Low. Sees a "policy." High. Sees a "path to admin."
False Positives High. Flags things that aren't actually exploitable. Low. If the tester got admin, it's a real risk.
Speed Fast, continuous. Slower, point-in-time or periodic.
Outcome A list of "non-compliant" settings. A proven attack chain with remediation steps.
Focus Hygiene and Compliance. Adversarial Resilience.

Real-World Scenario: The "DevOps" Leap

Let me give you a concrete example of how privilege escalation actually happens in the wild, and how a pentest would have caught it.

The Setup: A company has a "DevOps" role that is used by a CI/CD pipeline (like Jenkins or GitHub Actions). This role has the ability to update the code on a set of production servers. Because it's a "DevOps" role, it has the iam:PassRole permission so it can attach the correct roles to new EC2 instances it spins up.

The Attack:

  1. An attacker finds a vulnerability in a third-party plugin used by the CI/CD pipeline.
  2. They gain execution rights within the CI/CD environment.
  3. They notice the pipeline's role has iam:PassRole and ec2:RunInstances.
  4. The attacker creates a new "shadow" EC2 instance. They assign the OrganizationAccountAccessRole (which is a full Admin role) to this new instance.
  5. The attacker SSHs into the new instance, queries the metadata service, and grabs the Admin token.
  6. Result: Full account takeover.

How Pentesting Stops This: A penetration tester wouldn't just see "the CI/CD role has PassRole" and tick a box. They would actually execute this flow. They would show the security team: "Look, I started in a third-party plugin and ended up as your Root Administrator in 15 minutes."

This creates a "lightbulb moment" for the organization. Suddenly, iam:PassRole isn't just a technical detail in a policy—it's a gaping hole in their security.

The Role of Penetrify in Your Security Strategy

Managing cloud permissions is a nightmare. Between the thousands of possible actions in AWS/Azure/GCP and the constant change in your infrastructure, it's impossible to keep everything perfect. You need a way to test your defenses without having to build a massive internal "Red Team."

This is where Penetrify comes in.

Penetrify is a cloud-native platform that bridges the gap between "checking a box for compliance" and "actually being secure." Instead of relying on a static scanner that gives you a 200-page PDF of "potential" issues, Penetrify provides a way to identify, assess, and remediate real vulnerabilities through a mix of automated and manual testing.

Why Penetrify works for this problem:

  • Cloud-Native Architecture: You don't need to install clunky hardware or open dangerous firewall ports to get tested. It's all delivered via the cloud.
  • Simulating Real Attacks: Penetrify doesn't just look for misconfigurations; it simulates how an attacker would actually move through your environment to escalate privileges.
  • Scalability: Whether you have one AWS account or fifty, the platform allows you to scale your testing across multiple environments simultaneously.
  • Actionable Remediation: Finding the hole is only half the battle. Penetrify gives you the guidance needed to actually fix the IAM policy or the trust relationship so the hole stays closed.
  • Continuous Assessment: Security isn't a one-time event. As you deploy new code and change your infrastructure, new escalation paths emerge. Penetrify helps you maintain a continuous security posture.

Common Mistakes Companies Make When Fighting Escalation

Even when companies know about privilege escalation, they often implement "fixes" that don't actually work. Avoid these common pitfalls.

1. Relying Only on MFA

Multi-Factor Authentication (MFA) is great for stopping an attacker from logging into the console. But MFA does nothing to stop privilege escalation once a session token is stolen or a service role is hijacked. If an attacker is using a stolen access_key and secret_key via the CLI, they aren't hitting the MFA prompt.

2. The "Admin for Everyone" Culture

In many fast-growing startups, everyone has Admin access because "it just makes things move faster." The logic is: we trust our employees. But security isn't about trust; it's about limiting the damage a compromised account can do. If your lead dev gets phished and they have Admin access, the attacker has Admin access. Period.

3. Ignoring "Read-Only" Roles

Many teams ignore accounts with ReadOnlyAccess because they think "they can't change anything." This is a huge mistake. Read-only access allows an attacker to map your entire network, find secrets stored in environment variables, discover other vulnerable roles, and identify the exact path they need to take to escalate. Read-only access is the reconnaissance phase of the attack.

4. Patching the Symptom, Not the Cause

If a pentester finds an escalation path, don't just block that one specific action. Look at why that permission was there in the first place. If a user had too much power, it's usually because your role-creation process is flawed. Fix the process, not just the policy.

A Checklist for Your Next Cloud Security Review

If you're heading into a security audit or planning a pentest, use this checklist to identify where your privilege escalation risks are highest.

Identity & Access Management (IAM)

  • Do all human users have a unique identity (no shared accounts)?
  • Are there any users with AdministratorAccess or FullAccess policies?
  • Have you audited all roles with iam:PassRole or iam:CreatePolicyVersion?
  • Are there any "Shadow Admins" (users who can modify roles but aren't admins)?
  • Is MFA enforced for all console users?

Compute & Service Roles

  • Do your EC2/VM instances use the most restricted roles possible?
  • Have you moved to IMDSv2 to prevent SSRF-based token theft?
  • Are Lambda functions limited to only the specific resources they need?
  • Have you checked for "over-privileged" third-party integrations (SaaS tools)?

Monitoring & Visibility

  • Do you have alerts for high-risk IAM calls (e.g., CreateUser, AttachUserPolicy)?
  • Are your cloud audit logs (CloudTrail, Activity Logs) being stored in a separate, immutable account?
  • Do you review "Last Accessed" data to prune unused permissions?
  • Can your SOC detect horizontal movement between accounts?

Frequently Asked Questions (FAQ)

How often should I conduct penetration testing for cloud privilege escalation?

It depends on your rate of change. If you're deploying new infrastructure daily or changing your IAM roles weekly, you should be doing continuous or monthly assessments. At a minimum, a deep-dive pentest should happen quarterly or after any major architectural change.

Can't I just use a tool like Prowler or ScoutSuite?

Those are excellent tools for auditing and finding misconfigurations. But remember, they are scanners. They tell you that a door is unlocked. A penetration test tells you that if an attacker walks through that door, they can find the keys to the safe in the next room. You need both: scanners for daily hygiene and pentesting for real-world validation.

Will a penetration test break my production environment?

A professional pentest, especially one managed through a platform like Penetrify, is designed to be safe. Testers use controlled methods to prove a vulnerability exists without causing downtime. However, it's always best to perform the most aggressive tests in a staging environment that mirrors production.

What is the "blast radius" and why does it matter?

The blast radius is the total amount of damage an attacker can do once they compromise a single point in your system. If one compromised Lambda function allows an attacker to delete your entire database, you have a massive blast radius. The goal of stopping privilege escalation is to shrink that blast radius to as close to zero as possible.

Is privilege escalation common in Azure and GCP, or just AWS?

It is universal. While the names of the permissions differ (e.g., "Role-Based Access Control" in Azure vs. "IAM" in AWS), the fundamental logic is the same. Misconfigured roles, over-privileged service accounts, and token theft happen across all major cloud providers.

Actionable Takeaways: Where to Start Today

If you're feeling overwhelmed by the complexity of cloud IAM, don't try to fix everything at once. Start with these three high-impact moves:

  1. Audit your "PassRole" permissions. Search your IAM policies for iam:PassRole or similar permissions in Azure/GCP. If you see them assigned to non-admin users, treat it as a high-priority risk.
  2. Enable IMDSv2. If you're on AWS, this is one of the fastest ways to stop a very common attack vector (SSRF) from turning into a full-scale breach.
  3. Schedule a professional assessment. Stop guessing if your permissions are correct. Use a service like Penetrify to get a real-world view of your security posture. It’s much cheaper to pay for a pentest now than to pay for a ransomware recovery later.

The cloud offers incredible agility, but that agility comes with a cost: complexity. When your identity layer becomes too complex to understand, it becomes a playground for attackers. By proactively hunting for privilege escalation paths, you turn the tables, forcing the attacker to deal with a hardened environment where every step is monitored and every privilege is earned.

Don't wait for a breach to find out where your holes are. Secure your cloud, limit your blast radius, and get a professional eye on your infrastructure today.

Ready to see if your cloud is actually secure? Visit Penetrify to start identifying and fixing your privilege escalation risks before someone else finds them.

Back to Blog