<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Madhu on Medium]]></title>
        <description><![CDATA[Stories by Madhu on Medium]]></description>
        <link>https://medium.com/@madhusm?source=rss-46164bf6c0da------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*47wcN4BbEqNpVEV7SAcCkQ.png</url>
            <title>Stories by Madhu on Medium</title>
            <link>https://medium.com/@madhusm?source=rss-46164bf6c0da------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:08:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madhusm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Compromising a vulnerable GCP, INE-Labs GCPGoat walkthrough. Part-2]]></title>
            <link>https://medium.com/google-cloud/compromising-a-vulnerable-gcp-ine-labs-gcpgoat-walkthrough-part-2-1674abd16a40?source=rss-46164bf6c0da------2</link>
            <guid isPermaLink="false">https://medium.com/p/1674abd16a40</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <dc:creator><![CDATA[Madhu]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 16:03:57 GMT</pubDate>
            <atom:updated>2023-01-02T06:32:31.761Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Everyone, welcome back and if you haven’t checked out previous post have a quick look at <a href="https://medium.com/google-cloud/compromising-a-vulnerable-gcp-ine-labs-gcpgoat-walkthrough-part-1-90090ed0448b">here</a>.</p><p>Since we have access info to all instances currently operating in the project through developer-vm, we must now determine how to gain access to admin-vm. We should obtain all metadata information for the VMs from the dev VM. Let’s use the command below to view the metadata for both instances.<br>“gcloud compute instances descript developer-vm”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNVzii_8HDvBQCuela6rGA.png" /></figure><p>The reason we were able to run gcloud compute commands on developer-vm is now clear after taking a quick look at the details above. The VM has compute api access added to the scopes, and because the default service account to which it is bound has editor permissions by default on the project.<br>Looking at the account connected to admin-vm, it appears to be the project’s admin account.</p><p>Let’s try leveraging the dev-compute VM’s compute API access to gain access to the admin VM. As a result, in order to access a virtual machine, we must add our public ssh key to the VM’s metadata. let’s do try adding keys to the compute metadata for grant access to all of the project’s virtual machines.</p><p>Create new file and add public key in format “username:ssh_key_goes_here” <br>Run below commands to add sshkeys to compute metadata on project level</p><pre>gcloud compute project-info add-metadata-from-file=ssh-keys=filename<br>gcloud compute project-info describe --format=&quot;value(commonInstanceMetadata[items][ssh-keys])&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*gIGGoGmzw5bUlodFkNc1Xg.png" /></figure><p>Once we added our ssh key to the compute metadata we are able to ssh into the admin-vm now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*chZ_941j1BnFG3vfkTGgsg.png" /></figure><p>So we have access to the VM and got the project name and list of IAM bindings on the project as below and looks to be the service account binded to the VM has owner permissions on the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_TRFotK-TKq3DxcPN910w.png" /></figure><p>So with above permissions we should be able to add our account to the project for console access and it did worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNMN0x98uRhs3b5RVnWTTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*unPSpvsz5lNf_eify3_4CQ.png" /></figure><p>So we have compromised the Project and gained previleged access.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQVgCZ7EsgfrB9GLcMa%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQVgCZ7EsgfrB9GLcMa%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FQVgCZ7EsgfrB9GLcMa%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bff74eac78f57c5063205e2b5be0e5d/href">https://medium.com/media/7bff74eac78f57c5063205e2b5be0e5d/href</a></iframe><p><strong>What we should learn from this?</strong></p><p>Let’s quickly examine what factors contributed to the attack and what best practise implementation would have prevented it.<br>-) Bucket permissions with setIAMPolicy set to allusers<br> Always check that no bucket is exposed to allUsers/allAuthenticated at the IAM level. If a bucket must be exposed to the public, check that only the storage.objects.get object viewer permission is set, and nothing else.<br>-) Storing sensitive files like private keys in bucket accessible to users internally.<br>Use secrets manager and restrict access to it to only certain svc accounts instead of keeping sensitive keys on cloud storage.<br>-) Default compute engine account used for instance.<br>Enforce org policy(“Automatic IAM Grants for Default Service Accounts”) to avoid provision of default svc account which comes with editor role by default. Instead create new service account and have only limited permissions needed and limited scopes on the VM.(<a href="https://medium.com/google-cloud/organization-policies-that-needs-to-be-enforced-to-tighten-your-gcp-security-f3bfb724e9dd">Ref</a>)<br>-) Avoid Service Account with owner previlges permissions<br>Setting svc acc with owner permissions on a project is not a good idea. Because having access to an svc account with high privileges would always result in problems and abuse.<br>-) Enforce org policy for “Domain restricted sharing”<br>By default all workspace domain accounts are allowed to be added in IAM polocies. It’s good to limit only certain domain accounts are only to be allowed on same. <a href="https://medium.com/google-cloud/organization-policies-that-needs-to-be-enforced-to-tighten-your-gcp-security-f3bfb724e9dd">Ref</a></p><p>Hope this was helpful for learning on setting up some standards on GCP and thanks to INE-Labs for GCPGoat. See you soon again.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQzBCAqOgAYscVNh0r3%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQzBCAqOgAYscVNh0r3%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FQzBCAqOgAYscVNh0r3%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/903e1a12da1c8e47a641e35c3b1abbe5/href">https://medium.com/media/903e1a12da1c8e47a641e35c3b1abbe5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1674abd16a40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/compromising-a-vulnerable-gcp-ine-labs-gcpgoat-walkthrough-part-2-1674abd16a40">Compromising a vulnerable GCP, INE-Labs GCPGoat walkthrough. Part-2</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compromising a vulnerable GCP, INE-Labs GCPGoat walkthrough. Part-1]]></title>
            <link>https://medium.com/google-cloud/compromising-a-vulnerable-gcp-ine-labs-gcpgoat-walkthrough-part-1-90090ed0448b?source=rss-46164bf6c0da------2</link>
            <guid isPermaLink="false">https://medium.com/p/90090ed0448b</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <dc:creator><![CDATA[Madhu]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 06:08:43 GMT</pubDate>
            <atom:updated>2023-01-02T06:32:09.510Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Everyone,</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxUySTMO8XWIRjp0w4o%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxUySTMO8XWIRjp0w4o%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FxUySTMO8XWIRjp0w4o%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="235" frameborder="0" scrolling="no"><a href="https://medium.com/media/7482a31e274b0bca71267944e131d6f8/href">https://medium.com/media/7482a31e274b0bca71267944e131d6f8/href</a></iframe><p>As we start the new year, it’s important to remember the ever-evolving nature of cybersecurity and the need to constantly stay up-to-date on the latest threats and best practices.</p><h4><strong>What this article is all about?</strong></h4><p>Today we’ll go over GCPGoat: A Damn Vulnerable GCP Infrastructure by #INE-Labs, which challenges compromising the application and gaining admin access to the GCP where the application is hosted.<br><a href="https://github.com/ine-labs/GCPGoat">https://github.com/ine-labs/GCPGoat</a></p><h4>What we will learn with this?</h4><p>After we walk through the challenge and gain access to the environment, we will try to summarise how this could have been mitigated and what best practices for securing the GCP environment could have been implemented.</p><p>GCPGoat provides a variety of challenges, including application attacks and cloud misconfiguration, which will result in admin privileges for the Web-app and privileged access to the GCP project. We will focus solely on breaking down the steps that will lead to access to the GCP project where the application is hosted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*jmkhwvC1MImg0doBlqdbNw.png" /></figure><p>If you are in need of instructions on how to set up the GCPGoat application on your personal GCP account, you can find them at the end of this post; if you are just looking for a walkthrough, then let’s get started.<br>If the installation was successful, a cloud function URL of Web-app would be provided at the end, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*7hAYRsKjsf5ukJXUTAVN9Q.png" /></figure><p>Let’s take a look at the web app and the portal. The initial challenge is to get past the incorrectly configured bucket (Dev storage) on the same let’s crawl all the blogs on the portal and collect all calls being made, capturing the calls made while accessing the portal showed multiple calls made to storage Google api for objects access on bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*m6uJPOuZ9kvJxn1Uy8iMjQ.png" /></figure><p>The above-captured data shows that the bucket name was prod; let’s see if we can get all of the bucket’s objects.<br>Accessing the bucket to get all objects is denied, but individual objects can be accessed, indicating that the bucket has fine-grained ACLs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*C4Q1Bjmm1hYchH25jU_ZsQ.png" /></figure><p>After some reading and assistance, found a storage API document for testing bucket permissions <a href="https://cloud.google.com/storage/docs/json_api/v1/buckets/testIamPermissions">here</a>. This will enable you to determine whether the relevant permission is associated with the bucket when doing an unauthenticated or authenticated query.<br>We’re going to use an unauthenticated API call to check whether the bucket IAM permissions(<a href="https://cloud.google.com/storage/docs/access-control/iam-permissions">ref</a>) are mapped to “<a href="https://cloud.google.com/iam/docs/overview#all-users">allUsers</a>” on the same.</p><pre> curl \<br>  &#39;https://storage.googleapis.com/storage/v1/b/prod-blogapp-4b96f7070b93b339/iam/testPermissions?permissions=storage.objects.create&amp;permissions=storage.objects.delete&amp;permissions=storage.objects.get&amp;permissions=storage.objects.getIamPolicy&amp;permissions=storage.objects.list&amp;permissions=storage.objects.setIamPolicy&amp;permissions=storage.objects.update&amp;permissions=storage.buckets.delete&amp;permissions=storage.buckets.get&amp;permissions=storage.buckets.getIamPolicy&amp;permissions=storage.buckets.setIamPolicy&amp;permissions=storage.buckets.update&#39; </pre><pre>{<br>  &quot;kind&quot;: &quot;storage#testIamPermissionsResponse&quot;,<br>  &quot;permissions&quot;: [<br>    &quot;storage.objects.get&quot;<br>  ]<br>}</pre><p>Thus, we just have “storage.objects.get” for bucket “prod-blogapp-4b96f7070b93b339” which isn’t helpful for our further exploitation; instead, let’s find out if we have a dev bucket by simply changing the word “prod” to “dev” in the bucket name above.</p><p>Yes, we can access the dev bucket on the same and run testIamPermissions unauthenticated call, and obtain the bucket’s permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*94LRZwV_6PCz3AarwmG6Yw.png" /></figure><p>Despite the fact that we were unable to retrieve all of the objects in the dev bucket, there is an intriguing permission set to “allusers” highlighted above (storage.buckets.setIamPolicy). It appears that we can set IAM permissions to the bucket on the same, so let’s do so using the gsuitl command as shown below.<br>To guarantee there are no permissions/account overlap that are already present on the local setup, it is best to use a new docker instance with the <a href="https://hub.docker.com/r/google/cloud-sdk/">gcloud-sdk</a> when exploiting the permission in order to make unauthenticated calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*I6EBODP34D96aT38KnwJaw.png" /></figure><pre>gsutil iam ch allUsers:objectViewer gs://dev-blogapp-4b96f7070b93b339</pre><p>The above command will set the “storage object viewer” role to “allusers” which will set “storage.objects.lists” as well so we can get all objects in the bucket on the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*VnHCFGfH8yPWR3w04xhaRw.png" /></figure><p>Let’s list everything on the buckets and see if we have anything interesting. If you look in the shared directory, you’ll find some interesting files with the names config.txt and ssh keys directory at /shared/files/.ssh/<br>Let&#39;s dump them locally using command<br>“gsutil cp -r gs://dev-blogapp-4b96f7070b93b339/shared/files/* /tmp/”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*BUxeXSJHJYz-PQKzHZuRpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*FAqgLLRxoI6fFoVrfeCn7w.png" /></figure><p>after looking at the file config.txt, we can see the one of host with public IP address, username, and path to the ssh key file. It also appears that we can connect to the instance’s port 22 also.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*WqOzKqY2j8ALj-nw6NMFmQ.png" /></figure><p>But ssh is failed with permission denied error as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*Z-kGvI713bNgSz6OmK-ebA.png" /></figure><p>The ssh key file has overprivileged permissions, as indicated by the error above. Permissions to the ssh key private file should only be limited to the owner and no one else. Therefore, updating the file’s permissions and retrying the ssh did succeed, and I was able to connect to the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*L8bBtOfyIGWcTkOFTectOg.png" /></figure><p>After gaining access to the instance wasn’t able to run any sudo commands but however had access to execute gcloud CLI on the instance. <br>And found the instance is binded with default compute engine service account which comes with editor role by default, this allowed to get running instances on project via ‘gcloud compute instances list’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*LBPMl8X6QoUfV3wWvaFEfg.png" /></figure><p>So we have another instance with named ‘admin-vm’ on same project and we are currently on ‘developer-vm’ lets try get into ‘admin-vm’</p><p>To be continued on next article…</p><h3><strong>Tips on application setup</strong></h3><p>Follow through with the instructions given for the installation of the application on <a href="https://github.com/ine-labs/GCPGoat">GitHub</a>. The best approach would be running the steps over the cloud shell Terminal, running locally would face multiple challenges.</p><p>- If running locally ensure you have terraform installed on the same and gcloud SDK. <br> also if you already have multiple accounts set locally ensure the configurations are set to the respective project and account ID where the application needs to be hosted, confirm running “gcloud config configurations list”.<br>- Once you have the account set up with permissions on the creation of a new project follow the default installation steps mentioned <a href="http://Run terraform plan before apply to confirm the changes that going to be deployed, though the list is huge but would be good to grab to a file via command terraform plan -no-color &gt; output.txt. After terraform apply is completed successfully you would be given with a cloud function URL for web app which is vulnerable to attack for explotation.">here</a>.<br>- Run ‘terraform plan’ before apply to confirm the changes that going to be deployed, though the list is huge but would be good to grab to a file via command terraform plan -no-color &gt; output.txt.<br>- After terraform apply is completed successfully you would be given with a cloud function URL for web app which is vulnerable to attack for exploitation.</p><p>Hope by now if you are looking to host the application on your GCP for exploring is all set now, if you encountering any issues feel free to comment below on sharing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90090ed0448b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/compromising-a-vulnerable-gcp-ine-labs-gcpgoat-walkthrough-part-1-90090ed0448b">Compromising a vulnerable GCP, INE-Labs GCPGoat walkthrough. Part-1</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Before an attacker discovers your cloud, be aware of the endpoints you have exposed to the internet.]]></title>
            <link>https://medium.com/google-cloud/before-an-attacker-discovers-your-cloud-be-aware-of-the-endpoints-you-have-exposed-to-the-internet-17d26f1c0aab?source=rss-46164bf6c0da------2</link>
            <guid isPermaLink="false">https://medium.com/p/17d26f1c0aab</guid>
            <category><![CDATA[gcp-security-operations]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Madhu]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 03:13:57 GMT</pubDate>
            <atom:updated>2022-11-21T09:17:29.592Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*MSu4JNGg6H4n7aBZ0yeDhw.png" /></figure><p>Attackers constantly scan internet endpoints for susceptible services to access and breach. Once a public IP becomes active, keep in mind that attackers and different search engines starts to crawl it. It’s always a good idea to keep track of which endpoints on your cloud are accessible via the internet and audit those endpoints on a regular basis before a compromise becomes inevitable.</p><p>VPC services on GCP provide networking functionality to a variety of services such as VM/Kube services, CloudSQL, load balancers, and so on, which can be used to run services with attaching an external IP address to expose on the internet.</p><p>GCP helps with tracking/visibility with all lists of external addresses used on the project aligning with respective resources. Let’s see how we can leverage the available service and APIs for same to find the services the one which is exposed to the internet on the same.</p><p>With Navigation menu under “Networking” -&gt; “VPC network” and choose “IP addresses”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*ZTEF1p_nRGurS3UByAWqWQ.png" /></figure><p>We won&#39;t focus on reserved static addresses that aren&#39;t utilised by any resources; rather, we&#39;ll simply look through the list of &quot;External IP addresses&quot; used on the project that are accessible via the internet.<br>We will examine the ones used by instances and any other components, such as load balancers, Kube, or other services, regardless of the type “Static/Ephemeral”. <br>For access to the IP addresses service, having rights with “roles/compute.networkViewer” should be sufficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*akLxyogshYWWAxtJbUSzBQ.png" /></figure><p>With the above image it’s crucial to concentrate on the addresses that are utilized by services. The phrase “None” in “In use by” refers to addresses that are reserved and not used by any components, but you still have to pay for them.<br>To compile a list of addresses for all projects or specific projects on a given platform, you can utilize the compute <a href="https://cloud.google.com/compute/docs/reference/rest/v1/addresses">REST API</a>.</p><p>You may use the python script from the following github repository to make things even easier; for more information on usage <a href="https://github.com/smmadhu/gcp_external_ip_audit/blob/main/README.md">README.md</a></p><pre>git clone https://github.com/smmadhu/gcp_external_ip_audit.git</pre><p>Clone the repo and execute it locally using google application default login “gcloud auth application-default login” <a href="https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev">reference</a> or service account keys.<br>You can either use it to get the addresses for specific project or all projects within the org.</p><p><strong>So we have got all external address used on projects whats next?<br></strong> Once we have all the list of external IP address used on our GCP, scan for exposed ports on the internet and perform auditing for the reason on the exposed ports and endpoints. There might be a cases were sensitive services like ssh/sql ports could be opened by someone unintentionally. It’s good to know what ports are exposed and what service versions are running behind them to remideate known vulnerability on the services.</p><ul><li>Run a regular audit of used external IP addresses on projects.</li><li>Scan open’ed ports on all external addresses and services to check if there are any vulnerability service versions are being used.<br>Note: For global load balancer address there would multiple open ports while being scanned, more details can be found <a href="https://cloud.google.com/load-balancing/docs/https#open_ports">here</a>.</li><li>Perform Pentesting on the exposed services to find for any security vulnerability at application level as part of software development process.</li><li>Avoid limiting the exposure of the services to the internet if they are not really intended to do so.</li></ul><p>Note: With the gathered data above there would be addresses that are managed by google cloud itself like routers(used for cloud routers) and forwarding rules which contain esp/udp500/4500(used for VPN gateway addresses). These entries can be ignored for scanning.</p><p>By regularly monitoring and scanning exposed endpoints in our cloud environment, let’s make sure we aren’t the target of attacks.</p><p>Hope this was helpful…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17d26f1c0aab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/before-an-attacker-discovers-your-cloud-be-aware-of-the-endpoints-you-have-exposed-to-the-internet-17d26f1c0aab">Before an attacker discovers your cloud, be aware of the endpoints you have exposed to the internet.</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Organization policies that must be enabled to strengthen your google cloud security.]]></title>
            <link>https://medium.com/google-cloud/organization-policies-that-needs-to-be-enforced-to-tighten-your-gcp-security-f3bfb724e9dd?source=rss-46164bf6c0da------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3bfb724e9dd</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[security-policy]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[gcp-security-operations]]></category>
            <dc:creator><![CDATA[Madhu]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 12:16:14 GMT</pubDate>
            <atom:updated>2022-11-21T10:18:25.578Z</atom:updated>
            <content:encoded><![CDATA[<p>Greetings to all. Today, we&#39;ll explore how gcloud organization policy might help in establishing standards across the projects and see what would be the impact if no actions were taken.</p><p><strong>What is organization policy and why do I need to change them? <br> </strong>Organization policies are made up of constraints that define the set of rules and restrictions for using resources across the projects. There are a few policies that could potentially have an impact on the projects, leaving them enabled by default. We will see a few of them which can be helpful in tightening the security of the GCP environment.</p><p><strong>Note</strong>:- Changes to most of the organization policies will not affect the existing resources/permissions, they will be enforced only on new changes. However, there are very few policies that would revoke existing permissions as well, ensure to confirm the same before any policy enforcement.<br>Access the org policies via the below link<br><a href="https://console.cloud.google.com/iam-admin/orgpolicies/list?organizationId=">https://console.cloud.google.com/iam-admin/orgpolicies/list?organizationId=</a>your_gcp_org_id_here</p><p>Below are some of the policies that would be good to be enforced to secure the GCP.</p><p><strong>Disable the default network creations<br></strong> Having this enabled will create a default VPC network in new projects and below default firewall rules that exposes RDP and ssh port as well as ICMP on all instances in the network to the entire internet which could lead to an attack exposure if instances get attached with public IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkd0m7kgbRaE_TyhK9-pRg.png" /></figure><p>Ensure this org policy will be enforced to avoid the creation of a default network. If it is already being used in the current environment, ensure the above listed firewall rules are deleted on all existing projects. <br>Run the below command to audit all firewall rules across the projects and find any rule names that match above.</p><pre>gcloud asset search-all-resources --asset-types=compute.googleapis.com/firewall --scope=organizations/your_org_id_here --format=&quot;table(displayName,project)&quot;</pre><p><strong>Disable Automatic IAM Grants for Default Service Accounts<br> </strong>Having this enabled by default on your org policies will create a default service account for computing and cloud services that will have an editor role by default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*CtOch41H-hMQTO88QSBHNg.png" /></figure><p>surely hope you don’t want to provide access to any user as an editor who accesses the service account binded with the VM instance and any components which could be leveraged for taking various controls over the GCP project. Ensure this policy is enforced and recheck all your GCP project’s default service account privileges.</p><p>Below are the default service accounts that are created by gcloud<br>project-id@appspot.gserviceaccount.com<br>project-number-compute@developer.gserviceaccount.com <br>project-number@cloudservices.gserviceaccount.com<br>Read More on the default services <a href="https://cloud.google.com/iam/docs/service-accounts#default">here</a></p><p><strong>Enforce Public Access Prevention<br></strong> If you wanted to restrict someone from accidentally exposing the storage bucket publicly, this policy would help to mitigate such incidents. This will prevent the storage buckets from exposing them publicly. Also, enforcing this policy will revoke all existing buckets that have public permission allusers/allauthenticatedusers on the IAM level or ACL level.</p><p>If there are use cases to have objects exposed publicly and you can’t enforce this policy, do consider using fine-grained access for buckets, which will allow setting the permissions on the object level to the public rather than exposing the whole bucket to the public. Exposing the whole bucket to the public will leak the key identifiers of all objects in the bucket. Using fine-grained access you can programmatically enforce individual objects to the public. Refer to doc <a href="https://cloud.google.com/storage/docs/access-control/making-data-public#objects">here</a> on same.</p><p><strong>Domain restricted sharing<br> </strong>By default, all domain entities are allowed to be added in IAM policies in gcloud, like gmail.com or any other domain. Enabling this policy by enforcing principals that belong to the either allowed or deny customer ID workspace domains would avoid the addition of unwanted domain IDs. By adding your workspace ID in enforcement, you can limit the domains that belong to your workspace domains by selecting allow policy type.</p><p>To get the customer IDs for your own workspace refer <a href="https://support.google.com/a/answer/10070793?hl=en">here</a>.</p><p>Run an audit across your GCP org to find if there are any third-party domain ID’s been added to IAM policies and perform the cleanup.</p><pre>gcloud beta asset search-all-iam-policies --scope=organizations/your_gcp_org_id_here</pre><p><strong>Disable VM serial port access<br></strong> Access to VM serial port access doesn’t have IP restrictions. Anyone having instance ssh user and keys leads could get access to any person even without IAM access. Keeping this enforced would help ensure none of the VMs get VM serial port access enabled.</p><p><strong>Disable service account key creation<br> </strong>By default, the creation of service account keys will set the key to expire to “Jan 10000”, which will lead to having the key to authenticate SA forever and never expire. This policy should be enforced in order to prevent key misuse and to establish a standard key rotation policy in the organization to limit key creations.<br>We have earlier discussed the service account key’s best security practice <a href="https://medium.com/@madhusm/best-security-practice-for-service-account-on-gcloud-3146e977dad3">here</a></p><p><strong>Restrict Public IP access on Cloud SQL instances<br></strong> Choosing the default configurations on the creation of cloud SQL instance via console leads to having public IP attached. Though authorized networks are to be added specifically, having the SQL on the internal network is the best practice rather than getting them access via public IP. Enforcing this will help to reduce the Cloud SQL’s exposure over the public network.</p><p>I hope this will be helpful with auditing and enforcing some security standards in your GCP environment. See you soon again</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3bfb724e9dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/organization-policies-that-needs-to-be-enforced-to-tighten-your-gcp-security-f3bfb724e9dd">Organization policies that must be enabled to strengthen your google cloud security.</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best security practices for Service Account keys on Google Cloud]]></title>
            <link>https://medium.com/@madhusm/best-security-practice-for-service-account-on-gcloud-3146e977dad3?source=rss-46164bf6c0da------2</link>
            <guid isPermaLink="false">https://medium.com/p/3146e977dad3</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[service-account-key]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Madhu]]></dc:creator>
            <pubDate>Sun, 09 Oct 2022 14:13:24 GMT</pubDate>
            <atom:updated>2022-10-10T05:46:32.961Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfgyEvhTZ6DX9EBg6OD6Ag.png" /></figure><p>Today we are going to see what are the best security practices which can be implemented on service accounts and mitigating them on getting compromised.<br>Each company would have different standards on usage of service accounts(SA) for various needs. We will see multiple possible ways where we can implement the best security standards.</p><p><strong>Hey, why do I need to look for security practices for service account keys?<br></strong> Bad actors show no mercy when they get a key to door to find what’s there in the house isn’t it ? Assume having no restrictions on service account(SA) keys what an attacker could leverage permissions of the key over your cloud environment. Let’s act before its too late.</p><p><strong>So are we going to completely avoid on getting the Keys compromised ?<br></strong> No, we will try to secure the keys usage on GCP which can help with getting them on wrong hands via tightening from available org policies.<br>Let&#39;s see what standard practice we can do to restrict a service account(SA) misuse from org policies.</p><p>Below are the few SA policies available in the organisation policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loCH5T_9PlW5OXG9fsiD-g.png" /></figure><p>Shall we look into were this org policies can help us</p><p>-) <strong>Disable service account creation<br> </strong>Enforcing this policy on org will disable any new service account creations across projects which would lead to overhead operations for cloud ops on any requirement/need of new service account creation on projects.</p><p>-) <strong>Disable service account key creation<br> </strong>This policy would be interesting to tighten the standards for avoiding the misuse of service account keys.<br>By default, any new key creation on the SA in google cloud will set the default expiry to Jan 10000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*La9KMlnbduc9l9UXuJosGw.png" /></figure><p>So, we have the key to authenticate SA forever, and never expires would lead to getting the keys over to multiple hands unknowingly. Assume in this case the SA has privilege permission over a project or even at the org level, isn’t this might break the security standards one day? or is there any guarantee that keys aren’t going to transfer over hands?</p><p>Why not restrict this new key creation on SA and set control over keys generation?<br> If you agree, let’s look at how we can standardize the key creation by enforcing this policy.<br> So now let’s enforce this policy and see what will happen when creating a key for the SA</p><p>After enforcing we would see the below error while creating the SA key on the project. So we are good with this enforcing policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B17GFUbiMA3ZQNTtbzXE2A.png" /></figure><p>Hey, I have a requirement on the usage of the SA key how do I get one now?<br> User’s would always come with requirements when there are restrictions found, so let’s create a key for SA now but not with never expiry, it’s always good to have a key rotation for SA to avoid misusage. So we do have an option as “upload existing key” option on the SA Key page which we will be using same for temporary keys for SA.</p><p>we will use openssl tool to create a temporary key for SA, below is the command for same.</p><pre>openssl req -x509 -nodes -newkey rsa:2048 -days 90 -keyout private_key.pem -out public_key.pem -subj “/CN=unused”</pre><p>Execution of above command successfully will result below</p><pre>➭ openssl req -x509 -nodes -newkey rsa:2048 -days 90 -keyout private_key.pem -out public_key.pem -subj “/CN=unused”<br>Generating a 2048 bit RSA private key<br>…..+++<br>…………………………………………………………………+++<br>writing new private key to ‘private_key.pem’<br> — — -</pre><pre>➭ ls<br>private_key.pem public_key.pem</pre><p>The above command will create a key that will expiry in 90 days, we have two files created with the above command, private_key, and public_key.</p><p>Now we need to upload the public key file using the option “Upload existing key” SA Keys page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CysEeiiNG_MskIDW0kwnjQ.png" /></figure><p>Either we can upload the public key file or paste the key created via openssl Previously.<br>Once uploaded we can now see the key with a 90 days expiry as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwcwRz-HKrk3F9eq1sMPHA.png" /></figure><p>So let’s create a .json file for the SA using the key above which will be used to authenticate SA. Use the below documentation on the same and edit the code blocks directly on the docs page.<br> <a href="https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating">https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJXE0n5fdJaELX1zl4siTA.png" /></figure><p>Modify below parameters-<br>PROJECT_ID — project name where SA is created<br>KEY_ID — this is the key ID we see on the KEYS page of the SA<br>PRIVATE_KEY — this is the private key that needs to be added which was generated via the above OpenSSL command, ensure you remove the newline character from the file and consolidate it in a single line having only key characters.<br>SERVICE_ACCOUNT_EMAIL — This email ID for the SA account is available on the SA details page.<br>CLIENT_ID — This is the Unique ID of the SA which is available on the SA details page.</p><p>After you modify the above contents copy the code block and save it to a file in .json format.<br>So now we have keys that expire in 90 keys which bring in a mandatory key rotation policy for any use case of SA Keys.</p><p>-) <strong>Disable Service Account Key Upload<br> </strong>Enforcing this policy disables the previous feature that allows uploading public keys to service accounts where this constraint is set to `True`. By default, users can upload public keys to service accounts, this policy should be enforced considering a few aspects of any org like requirement or use case of keys, key generation policy for SA on projects etc.</p><p>We have now looked at the above default org policies which can put control on Service account keys but are controlling over SA keys only the best practice?<br> No…, how about using the SA without any keys?, yes we can authenticate to SA without having any keys generated for the same via using the SA directly mapped to a resource on google cloud.</p><p>As an example for a VM instance attach a needed service account that needs access to cloud resources from an instance application accordingly.<br> <a href="https://cloud.google.com/compute/docs/access/service-accounts#associating_a_service_account_to_an_instance">https://cloud.google.com/compute/docs/access/service-accounts#associating_a_service_account_to_an_instance</a><br> Cloud functions can also be invoked with dedicated SA on same.</p><p>Hope this would help with brainstorming the standard practice over SA on gcloud for you. See you soon again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3146e977dad3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>