<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ojasveer Singh Saini  on Medium]]></title>
        <description><![CDATA[Stories by Ojasveer Singh Saini  on Medium]]></description>
        <link>https://medium.com/@ojasveersinghsaini?source=rss-9aa441e168f1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VnzTQg6Rl-jFgy4_</url>
            <title>Stories by Ojasveer Singh Saini  on Medium</title>
            <link>https://medium.com/@ojasveersinghsaini?source=rss-9aa441e168f1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:54:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ojasveersinghsaini/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Unintended Privilege Escalation in CloudGoat’s vulnerable_cognito Scenario]]></title>
            <link>https://medium.com/@ojasveersinghsaini/unintended-privilege-escalation-in-cloudgoats-vulnerable-cognito-scenario-11275de60c9d?source=rss-9aa441e168f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/11275de60c9d</guid>
            <category><![CDATA[cloudgoat]]></category>
            <category><![CDATA[cloud-misconfiguration]]></category>
            <category><![CDATA[aws-cognito]]></category>
            <category><![CDATA[cloud-hacking]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Ojasveer Singh Saini ]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 07:16:02 GMT</pubDate>
            <atom:updated>2026-02-17T07:16:02.141Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello guys, welcome back to another (very late, i know 😓) blog. Another one of CloudGoat’s scenario: <em>vulnerable_cognito.</em></p><p>But with a <em>twist: </em>While solving the lab, I actually found an unintended way to escalate the privileges, and reach the intended goal for the scenario, completely different from the intended path, an attack-path that has never been documented before. Read on to find how I did it!</p><h3>What is Cognito?</h3><p>Before we move on to the task, first lets understand what AWS Cognito service is, its functions, and how could misconfiguration in it could be exploited.</p><p>Amazon Cognito is AWS’s managed identity service that provides authentication, authorization, and user management for web and mobile applications. It helps developers implement login systems without having to build identity infrastructure from scratch. It can also support authentication and authorization from third party app and OAuth too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*sjwMg32rouJETHYe.png" /></figure><p>Cognito has two components:</p><ol><li><strong>User Pools:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vuK_xZKji1cc5X6A.png" /></figure><p>User Pools handle <strong>authentication</strong>.</p><p>They are essentially a managed user directory that:</p><ul><li>Stores users and their attributes</li><li>Handles signup and login flows</li><li>Issues JWT tokens (ID token, Access token, Refresh token)</li><li>Supports custom attributes and groups</li></ul><p>When a user successfully authenticates against a User Pool, Cognito returns signed JWT tokens that the application can use to verify identity.</p><p><strong>2. Identity pools</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*o_MKJ-ciUlF3ufqo.png" /></figure><p>Identity Pools handle <strong>authorization to AWS resources</strong>.</p><p>While User pool handles the <em>‘Who’ </em>part, like, <strong>“Who is this user?”</strong>, Identity pool handles <em>‘What’</em> part: <strong>“What permissions does this user has?”</strong></p><p>An Identity Pool exchanges valid authentication tokens (for example, from a User Pool) for temporary AWS credentials via AWS STS. These credentials are associated with an IAM role.</p><h3>Where Misconfigurations happen?</h3><p>Because Cognito separates authentication and authorization, developers often assume that:</p><ul><li>If a user reaches a certain page, they must already be authorized.</li><li>If a custom attribute exists, it must have been validated.</li><li>If the frontend restricts navigation, backend enforcement is unnecessary.</li></ul><p>But as we know, we never trust the frontend 😅.</p><p>Common Cognito misconfigurations include:</p><ul><li>Over-permissive Identity Pool roles</li><li>Client-side trust of user attributes</li><li>Missing backend validation of role eligibility</li><li>Incorrect mapping between User Pool claims and IAM roles</li></ul><p>When any of these occur, the result is often <strong>privilege escalation</strong>, where a normal user obtains access to higher-privileged IAM roles.</p><p>And one of these misconfigurations was exactly what I exploited to get to the intended goal, without following the supposed path!</p><h3>Setting up the scenario</h3><p>First, lets whitelist our IP, and then setup the scenario.</p><p>Whitelist IP command: cloudgoat config whitelist — auto</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X6icpvUaI7w_Ho-o2Gwnow.png" /></figure><p>Setup the scenario using: cloudgoat create vulnerable_cognito</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*jGDeyh2GkWyGIfuht-P1fA.png" /></figure><p>It wont take much time to set up. Once its done, you’ll get the following output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9OeKeuaUI_KbqntS9BpzeQ.png" /></figure><p>Open the link in a browser, you’ll see a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kc-hP_Pduk9-DrdKYnXZCQ.png" /></figure><p>And the associated sign-up page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*UUeQZPF5oIn-C9ZC7xA57Q.png" /></figure><p>Lets check their source code first for anything interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*ExDbf9zbVxlWJoJSBhZSxA.png" /><figcaption>Login Page Source Code Finding</figcaption></figure><p>So, in the login page source code, we can find the hardcoded <em>UserPoolId </em>and <em>ClientId </em>of the Cognito setup on the cloud that is being used by the supposed company.</p><p>We can also see that a custom attribute has also been defined, named ‘<em>access’, </em>which would have actually been used in the intended path to escalate our privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*n9IThNRrsDsAW7WzOHecxg.png" /></figure><p>On the signup page source code, we can see that the backend (or more likely, frontend) just accepts emails from the domain ecorp.com.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Y1jRLU5SkJeW6su1C3ZfRQ.png" /></figure><p>So now, we need to look for another way to get in, to sign up and log in. Fortunately, this is where the hardcoded config info we found earlier would come in handy. Lets switch back to our home turf, the Terminal 😎</p><p>After referencing the AWS Cognito docs, I found that it provides a utility to sign-up users using the AWS-CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9YBHeacxIC_yfrE5He5jdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSlfT_KaQJIHrUwF2vTerg.png" /></figure><p>So we can this reference to sign up our user manually via the CLI, using the following command:</p><p>aws cognito-idp sign-up --client-id &lt;client_id&gt; --username &lt;email-id&gt; --password &lt;password&gt; --region us-east-1 --user-attributes &#39;{&quot;Name&quot;:&quot;given_name:, &quot;Value&quot;: &quot;john&quot;}, {&quot;Name&quot;: &quot;family_name&quot;, &quot;Value&quot;: &quot;doe&quot;}&#39;</p><p>The reason for including the user-attributes parameters is because this is what is expected for a new user entry at the backend, as can be seen from the source code of the pages seen till now.</p><p>Once you enter this command, you’ll get a response, including details about a confirmation code delivery, user confirmation status among other things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ILjJWO-qQSDcGCsZeXQyw.png" /><figcaption>Sign-up user using AWS CLI</figcaption></figure><p>But we still cannot login, as we are still not confirmed. For this, we will have to provide a confirmation code, which would be delivered to us via the email we provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*CmtCymnWQMcCaG8I6PHN-A.png" /></figure><p>Use this code and submit back to the backend again using this command:</p><p>aws cognito-idp confirm-sign-up --client-id &lt;client_id&gt; --username &lt;email_id&gt; --confirmation-code &lt;code&gt; --region us-east-1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PwcYaLES9pmFW1Ggg6S3yw.png" /></figure><p>You can also reference the AWS docs for syntax reference:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QgMq77sEPsMw8-LBvG7Zrg.png" /></figure><p>On successful confirmation, you won’t receive a response back, but you are now confirmed and can now sign in using the credentials you supplied earlier.</p><p>On logging in, we are directed to a reader.html page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoNYwwSLHm4DQBcmiUHtQA.png" /></figure><p>Now, here is where I deviated from the intended path. As per the scenario, we had to decode our received signed JWT token, which we’ll see has a custom attribute named access . We would go on to change our access level, followed by capturing AWS access credentials and then enumerate the permissions we have.</p><p>What I did was, I navigated straight to admin.html page, which technically shouldn&#39;t have been accessible in the first place, but apparently, maybe due to a misconfiguration in the scenario, the admin page is being served without validating the user access level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Hr0D0fkRtDZt3EuJiousQ.png" /></figure><p>Open the Developer Tools and go to the Network tab. Refresh the page, and you’ll see some network request populate the screen. And one of them, it turns out, actually carries out the very AWS access credentials we needed to find out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pPRaAoNdJwsVi0k6mwSoA.png" /></figure><p>You can also confirm that are access level is still reader level bby capturing the JWT received and decoding its value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCodS3EMWXl8qOTbKEg1Gg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3I3wBTUeHsb-X9fnmOlQSQ.png" /></figure><p>Now, we can just configure a profile with these credentials, and see if they are valid or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Fyasx3q1UzmQp8lYfPG7aQ.png" /></figure><p>Now, to enumerate the IAM permissions we have, we can use a Pacu module, iam__bruteforce_permissions .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*WDt4hwJBDcP6lrRBEIRFwg.png" /></figure><p>At this point, the obvious question is:</p><blockquote>Are these credentials actually equivalent to those obtained through the intended attribute-escalation path?</blockquote><p>To verify this, I performed IAM permission enumeration on:</p><ol><li>Credentials obtained via the unintended /admin.html path</li><li>Credentials obtained via the official custom attribute escalation flow</li></ol><p>Using Pacu’s iam__bruteforce_permissions module, I compared the effective permissions associated with both sets of credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPG_15jKk-iQXU9PtoF7qw.png" /><figcaption>Two different profiles configured in Pacu, for the different AWS keys received, showing same permissions.</figcaption></figure><p>This confirms that the unintended path does not grant partial access — it fully bypasses the attribute validation step while still achieving the scenario’s final objective.</p><h3>Root Cause Analysis of the Scenario</h3><p>The core issue lies in a breakdown of the trust boundary between authentication and authorization.</p><p>While Cognito correctly authenticates users via the User Pool, the authorization logic — specifically determining whether a user should receive elevated AWS credentials — is not enforced server-side before issuing Identity Pool credentials.</p><p>Instead:</p><ul><li>The /admin.html route is accessible without validating the user&#39;s custom:access attribute.</li><li>The frontend triggers an aws-sdk.js call that retrieves temporary AWS credentials.</li><li>The Identity Pool returns credentials regardless of whether the user’s attribute indicates sufficient privilege.</li></ul><p>This effectively renders the attribute-based authorization check unnecessary.</p><p><strong>Lessons Learned:</strong></p><p>This scenario highlights several important architectural lessons:</p><ul><li>Authentication does not imply authorization.</li><li>Identity Pools must strictly validate claims before issuing IAM credentials.</li><li>Client-side route restrictions are not security controls.</li><li>Attribute-based access control must be enforced server-side.</li></ul><h3>Responsible Disclosure</h3><p>This unintended privilege escalation path has been responsibly reported to the official CloudGoat repository maintainers via a GitHub issue.</p><p>At the time of writing, I am awaiting their response.</p><p>— — —</p><p>Hope you all enjoyed the walkthrough, especially a never before seen attack path! Thanks for reading. See you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11275de60c9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Pentesting: Conquering the Cloudgoat Beanstalk Secrets Challenge]]></title>
            <link>https://medium.com/@ojasveersinghsaini/aws-pentesting-conquering-the-cloudgoat-beanstalk-secrets-challenge-b1f9ec880813?source=rss-9aa441e168f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1f9ec880813</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Ojasveer Singh Saini ]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 16:53:53 GMT</pubDate>
            <atom:updated>2025-07-30T16:53:53.526Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGq88hiB7BlB_FM5v0Enpw.png" /></figure><p>Hey everyone, I am back with another writeup on a yet another Cloudgoat scenario. Let’s dive right in.</p><p>But, first, a bit of theory. What is Beanstalk, or more explicitly, Elastic Beanstalk in AWS? Put simply, EB is a PaaS by AWS which abstracts the underlying infrastructure, allowing the developers to focus on just the application code. In simple words, you simply upload the code, and AWS EB handles the provisioning of the underlying resources, like EC2, load-balancers, etc.</p><p>Now, lets get started with the fun part. The hacking stuff :)</p><p>First, lets whitelist our IP for Cloudgoat.</p><pre>cloudgoat config whitelist --auto</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*esDP-XgYWfhz9XYFDs59oA.png" /><figcaption>Whitelisting IP to access Cloudgoat instance</figcaption></figure><p>Now, lets create our instance:</p><pre>cloudgoat create beanstalk_secrets</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*C-Jm5xmF4otz3wpjUvKMgQ.png" /></figure><p>It will take a few minutes to create, so grab a glass of water, or stretch your legs a bit. At the end, you will get an access key and secret key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*aixlMRQSGjqkglP7KdHsjw.png" /></figure><p>Configure your AWS CLI to use these credentials. You can also confirm the credentials are valid with <em>sts:GetCallerIdentity</em> action</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*h0sMv52HviKOdm8cRt6z5g.png" /></figure><h3>Enumeration</h3><p>Lets start with some IAM enumeration. Though we know the challenge is about beanstalk, and the info we want would most probably be there only, it never hurts to search for other info.</p><p>Searching for other users and groups…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysUMteYlxp2JEmdFw-MQ6Q.png" /></figure><p>Trying to enumerate policies and roles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Po7F_IWufYVCMtXCNP6Qqw.png" /></figure><p>and nothing…</p><p>Well, it was expected. Let’s start with EB enumeration now.</p><p>First, lets enumerate the EB environment first.</p><pre>aws elasticbeanstalk describe-environments --profile beanstalk_low</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GI4AxgAR49KmC3RIX39CLQ.png" /></figure><p>So, this worked. We have got some basic information about the environment running, particularly, the <em>EnvironmentName </em>and <em>ApplicationName</em>, which will come in handy in the next step of enum.</p><p>Sometimes there can be some juicy stuff in there. Run the following command to get configuration settings for the particular environment and application.</p><pre>aws elasticbeanstalk describe-configuration-settings --application-name cgidr1cowz90n7-app --environment-name cgidr1cowz90n7-env --profile beanstalk_low</pre><p>It will give a long list of things, but scrolling through it, we will find something really interesting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73mykJy80yQDJWCV7YSJrw.png" /></figure><p>Jackpot! We found another access key and secret key. This could potentially allow us to escalate our privileges. Lets create another AWS CLI profile using these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*JGFUVnMcYzULlxqNH9ChVA.png" /></figure><p>Let’s do some enumeration using this ID:</p><p>Users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*L90Xtl6DWZEy5vxaxiCNcQ.png" /></figure><p>Policies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*hpLXYOADBOTtu0Io4BU__Q.png" /></figure><p>Corresponding policy document:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngxsaUTdIw_WzqEseYdjQw.png" /></figure><p>Aha! And we have struck gold. We have a dangerous permission on our hands. We can create Access Keys for any user (as indicated by the <em>star)</em>, including the admin user. So, lets create access key for admin user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*zrlMCHfaJTTSl82rnrC-IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*cytQWRj3R0N3Zv4czlEPrg.png" /></figure><p>Now that we have admin access to the account, we have access to everything. We know from the scenario description, that the flag is in the Secrets Manager. So, lets enumerate that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*nZc7FJToa4cXfBFRgoZJQQ.png" /></figure><p>Access the flag using the below command:</p><pre>aws secretsmanager get-secret-value --secret-id arn:aws:secretsmanager:us-east-1:&lt;account_id&gt;:secret:cgidr1cowz90n7_final_flag-1bQged --region us-east-1 --profile beanstalk_admin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zsG7JCSQvRpO-AowjNdqQQ.png" /></figure><p>Don’t forget to destroy the instance, lest you will incur AWS charges.</p><pre>cloudgoat destroy beanstalk_secrets</pre><h3>Conclusion</h3><p>This scenario was a fanstastic demonstration of a common, yet critical, cloud misconfiguration. We started with a low-privilege user, discovered sensitive credentials carelessly stored in Elastic Beanstalk configuration, and leveraged a dangerous IAM permission (<em>iam:CreateAccessKey</em>) to escalate our way to full admin access.</p><p>The key takeaway from this is simple: Never put credentials or sensitive information in environment variables or config files. Always use dedicated services such as Secrets Manager for storing them. That will save you from a security nightmare.</p><p>Hope you enjoyed the walkthrough! See you next time! 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1f9ec880813" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privilege Escalation in AWS via Key Rotation — A Cloudgoat Scenario Walkthrough]]></title>
            <link>https://medium.com/@ojasveersinghsaini/privilege-escalation-in-aws-via-key-rotation-a-cloudgoat-scenario-walkthrough-42a0db68a430?source=rss-9aa441e168f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/42a0db68a430</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Ojasveer Singh Saini ]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 11:24:06 GMT</pubDate>
            <atom:updated>2025-06-16T11:53:00.972Z</atom:updated>
            <content:encoded><![CDATA[<h3>Privilege Escalation in AWS via Key Rotation — A Cloudgoat Scenario Walkthrough</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*BpAyvmNqyExOCtoU69T9Qw.jpeg" /></figure><p>Hey everyone, welcome to my walkthrough. This post is to document my learning about what I learnt. Hope you find it interesting, and it helps you out if you are stuck in it.</p><p>Now, before we get into the actual walkthrough, lets first discuss what exactly is Cloudgoat.</p><p>Cloudgoat is <em>“Rhino Security Labs’ ‘vulnerable by design’ cloud deployment tool.” </em>That is, it is an open source cloud deployment tool for vulnerable by design cloud scenarios to practice your cybersec skills for cloud hacking. It allows you to deploy highly realistic, vulnerable cloud scenarios, to hone your cyber skills, across AWS and Azure. A full documentation about Cloudgoat can be found <a href="https://github.com/RhinoSecurityLabs/cloudgoat">here</a>.</p><p>In this walkthrough, I am going to focus on a particular Cloudgoat scenario, that is, <strong><em>iam_privesc_by_key_rotation</em></strong><em>.</em> This scenario involves exploiting insecure IAM permissions of the account to which we have the initial access via Cloudgoat, to escalate to root/admin access and find the flag in the Secrets Manager.</p><p>Let’s first set up the Cloudgoat scenario with the following commands.</p><pre>cloudgoat config whitelist --auto</pre><p>This will whitelist your IP so you can access the AWS environment.</p><pre>cloudgoat create iam_privesc_by_key_rotation</pre><p>This will create the cloudgoat scenario in your AWS account. make sure you have created your AWS account and configured it with Cloudgoat. This process can take a few minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*oUurVuDRz2Y0ZyKmknHwTQ.png" /></figure><p>At the end we are provided with the access key and secret key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FYfu5vhTvpEIaC5NSes07A.png" /></figure><p>Go ahead and configure your AWS CLI to use these credentials. We can also verify that these credentials work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*3sikW8Uuxy6Z4z-aLuGE3g.png" /></figure><p>Now comes the first part that any one should do before looking to exploit any vulnerabilities: Reconnaissance and Enumeration.</p><blockquote>Recon and Enumeration are the two most important steps anyone should do. Without it, you will struggle, <strong>a lot.</strong> Without it, you are just blindly shooting your shots, in the dark.</blockquote><p>First, lets check for other users associated with the account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*2-ltI4RSrdJ0XVwhk3IdJA.png" /></figure><p>I seem to have found an interesting user, <em>developer. </em>My<em> </em>first thought was maybe we can pivot using him later on, as a potential attack path. Though, our main goal is the admin user, we can come to it later if we get stuck somewhere.</p><p>Next, lets enumerate the policies our current user has, both managed and inline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*I3BhkfaLAVSKgiSsZG-e0w.png" /></figure><p>Inspecting their policy documents…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DuMs4OXwU3akRvXkYXuFWA.png" /></figure><p>Nothing much to go on here, just a standard AWS policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzhRnNlNep9UKh7_bI7FBA.png" /></figure><p>Now this — this is a goldmine. Our current user has some dangerous permissions. They have the permission to create, update or delete the access key of <strong><em>any user</em></strong>, as long as the target user has the ‘developer’ tag assigned to them. And we also have the ability to create Virtual MFA devices, which will come in handy when we need to bypass MFA security, if any.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*2ws5Z8e3S3MF6lfnOQaFjA.png" /></figure><p>We can see in this picture that our user also has the permissions to tag any user, due to the wild card(*) in the Resource field.</p><blockquote>Consider this a rule of thumb: whenever you see a wildcard(*) anywhere. Pay VERY close attention to it. It might just be your way in.</blockquote><p>Before moving on, lets enumerate for roles too.</p><pre>aws iam list-roles --profile manager</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*WWdlctRW3_HezsxBfQdLJw.png" /></figure><p>And we found a role that can be assumed which will allow us to view the secrets in the Secret Manager.</p><p>After all this, our attack path is clear: escalate to admin using the overly permissive IAM permission to create a new key for us, assume the role, and find out the flag in the Secret Manager.</p><p>Let’s start!</p><p>First, lets update the target user(admin) to have the tag of the<em> ‘developer’.</em></p><pre>aws iam tag-user --user-name admin_cgiduyfqqh0sxv -tags &#39;{&quot;Key&quot;:&quot;developer&quot;,&quot;Value&quot;:&quot;true&quot;}&#39; --profile manager </pre><p>If successful, this will return no output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*aD9N6Fw4qrQt0bqyOgXQwQ.png" /></figure><p>Now that admin user had the ‘developer’ tag, I proceeded to use our overly permissive IAM permissions to create a new access key for the admin user. First lets list and remove an existing key, because a user can only have two access keys at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*UsvSCqlsiotbZ8hTw7v4Iw.png" /></figure><p>Now, lets create a new access key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*zs3KlztvfdGtgnysE5QPDQ.png" /></figure><p>We can verify that these credentials are valid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*DWy1FxreKAGXzgn4uToA9w.png" /></figure><p>Now, lets try to assume the role to access the secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t58tWufp6Ujim7aKuOn_2w.png" /></figure><p>Welp… That’s a road block. We know we did nothing wrong, so what are we missing? I’ll be honest, I was stuck on this for a quite a while, and had to research for almost an hour and go over my previous findings before I realized where the problem was.</p><p>While enumerating the roles, the we saw that the role we want to assume requires the use of MFAAuth, which is essentially, MFA authentication. I was again stumped for a while and so had to take some help from ChatGPT on how to move forward. I found the best way to move forward was to create a virtual MFA device, something which is in the capabilities provided by the AWS CLI.</p><p>Lets create a virtual MFA device using the manager profile.</p><pre>aws iam create-virtual-mfa-device --virtual-mfa-device-name cloudgoat_virtual_mfa --outfile QRCode.png --bootstrap-method QRCodePNG --profile manager</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xh6hdktNPq7uTqQbw7c83Q.png" /></figure><p>Scan the output QR code with any authentication app(e.g. <em>Authy, Google Authenticator, etc.) </em>and put two consecutive TOTP(Time-based OTP) in the command below:</p><pre>aws iam enable-mfa-device \<br>    --user-name admin_cgidtv5y3gox0w \                            <br>    --serial-number arn:aws:iam::&lt;serial_number&gt;:mfa/cloudgoat_virtual_mfa \<br>    --authentication-code1 &lt;code_1&gt;\<br>    --authentication-code2 &lt;code_2&gt;\<br>    --profile manager</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*3i_QN8ODlnhtyQA33yd4uw.png" /></figure><p>On successful execution, no output is returned. Now let’s try again to assume the role, but this time, using the virtual MFA device we created. Remember to add a new TOTP in the command below, not the ones you used previously.</p><pre>aws sts assume-role --role-arn arn:aws:iam::&lt;serial_number&gt;:role/cg_secretsmanager_cgiduyfqqh0sxv --role-session-name secret --profile admin --serial-number arn:aws:iam::&lt;serial_number&gt;:mfa/cloudgoat_virtual_mfa --token-code 538471</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWzHC4S0V7uS3t2XJjJNIg.png" /></figure><p>And we have done it! We now have assumed the role which will allow us to access the secrets in the secret manager. Lets reconfigure our AWS CLI admin profile to use these new credentials.</p><p>Edit the ‘ /.aws/credentials ’ file. And don’t forget to add the session token too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoIfBYVgju2scTwjmB_b0w.png" /><figcaption>Hey everyone, welcome to my walkthrough. This post is to document my learning about what I learnt. Hope you find it interesting, and it…</figcaption></figure><p>We can verify that these credentials work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*G1kC4y2yLcDIRd-w50Dipw.png" /></figure><p>Now, lets finish this. List the secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVHIzsn3ssfgpS6tvIl0sQ.png" /></figure><p>Final step: Access the secret for the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6AJ0Gm9zSqhw_YBMCuBMCQ.png" /></figure><h3><strong>Conclusion:</strong></h3><p>In this scenario, we saw how overly permissive and mismanaged IAM peermissions and overlooked trust relationships can lead to privilege escalation — specifically via key-rotation abuse.</p><p>This revealed the importance of:</p><ol><li>Privilege of Least Principle</li><li>Monitoring access key usage and and rotation</li><li>Enforcing MFA rigorously.</li></ol><p>Hope you had fun reading this, and it helped you out if you were stuck somewhere. See y’all next time. Happy Hacking! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42a0db68a430" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>