# Why FDEs should never hold a customer's cloud access keys

> When the cloud platform issues short-lived tokens to your service, you are left holding no secret that can leak or needs rotating.

Original: https://fdetimes.net/en/guides/fde-managed-identity-no-customer-keys/

Datadog's State of Cloud Security 2025 report found that 59% of IAM users on AWS, 55% of Google Cloud service accounts and 40% of Microsoft Entra ID applications are using keys or credentials more than a year old.

FDEs run into this in their first week with a customer. Your service needs to read data in their cloud, and the quickest route is to ask for an access key and paste it into a config file. That key can easily outlive the engagement, drift beyond the control of whoever issued it, and become the hardest question to answer at the security review.

One skill spares you from holding any key at all: letting the cloud platform itself confirm who your workload is, then issue it short-lived tokens. On Azure the mechanism is called managed identity.

AWS and Google Cloud have equivalents. Once you know how it works, you have a tidy answer for the security review and a lighter handover, because when you leave there are no secrets in your hands that need revoking.

## The identity lives on the machine, not in a file

Microsoft describes managed identity as a way for applications to obtain Microsoft Entra tokens without managing any credentials. The identity is attached to a resource. When code running on that resource needs to reach Storage or Key Vault, it asks the platform for a token rather than reading a password from anywhere.

There are two kinds of managed identity. A system-assigned identity lives and dies with its resource: delete the VM and Azure deletes the accompanying service principal too. A user-assigned identity is a standalone resource that can be attached to several machines. At a customer, choose user-assigned, because the trust configuration and permissions survive when you rebuild the VM.

On a VM, tokens are requested from the IMDS endpoint at `169.254.169.254`. The request must carry the header `Metadata: true`, which Microsoft says is a mitigation against SSRF attacks: the idea is that a request tricked into leaving a web application will usually not carry that header.

```bash
curl -s -H "Metadata: true" \
  "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://storage.azure.com/"
```

## A worked example from start to finish

Take a hypothetical case. Your company's document-processing service runs on a VM in your own Azure tenant. The customer wants the service to read files from a Blob container in their tenant. The two tenants are different, so the managed identity cannot be granted permissions on the other side directly.

Microsoft offers a route that needs no secret. You create an app registration in the same tenant as the managed identity, make it a multitenant application, and add a federated credential so the app trusts that managed identity. The customer's admin provisions the app into their tenant and grants it exactly one role on exactly the container it needs to read.

Once that is set up, your code needs only two steps at runtime. First it asks the managed identity in your tenant for a token, then it presents that token as an "assertion" to obtain the app's token in the customer's tenant:

```python
from azure.identity import ManagedIdentityCredential, ClientAssertionCredential
from azure.storage.blob import BlobServiceClient

mi = ManagedIdentityCredential(client_id="<MI_CLIENT_ID>")

def assertion():
    return mi.get_token("api://AzureADTokenExchange/.default").token

cred = ClientAssertionCredential(
    tenant_id="<CUSTOMER_TENANT_ID>",
    client_id="<APP_CLIENT_ID>",
    func=assertion,
)
blobs = BlobServiceClient("https://<account>.blob.core.windows.net", credential=cred)
```

This code contains no secret strings. The three values in angle brackets are all IDs, harmless if exposed. Because the role sits in the customer's tenant, revocation is in their hands and does not depend on any key you hold.

That said, as the next section explains, role changes can take several hours to apply, so do not promise the customer that access disappears instantly.

**Key point:** A key you never hold cannot leak from your side.

## Three places you will lose an afternoon

The first trap is silent failure. If you get the issuer, subject or audience of a federated credential wrong, Azure still creates it successfully, with no warning. According to Microsoft, the error only surfaces when the token exchange fails. So run the exchange right after configuring it, rather than waiting for demo day.

The second trap is timing. The managed identity infrastructure caches tokens per resource URI for about 24 hours, so when you add a group or change a role, the change may take several hours to apply.

There is currently no way to force an earlier token refresh. Ask the customer to grant access a day before go-live, and remember that revoking access does not take effect immediately either.

The third trap is the security boundary. Microsoft is explicit: any code running on a VM can request tokens for every managed identity attached to that machine.

Anyone who can install or run code on the machine can use all of the identity's permissions, even if they have no direct access to the target resource.

Do not let a shared VM carry an identity with write access to customer data.

One more limitation belongs in the discovery session. Using a managed identity as a federated credential works across tenants but not across clouds. If the customer runs on Microsoft's US government cloud or its China cloud, token requests from the global cloud will fail, and you will have to deploy inside their cloud.

## The same idea on every cloud

The principle is not unique to Azure. AWS's IAM guidance says plainly not to give third parties an IAM user with long-term keys, and to use an IAM role with temporary credentials instead. Google Cloud says Workload Identity Federation removes the maintenance and security burden that comes with service account keys.

| Environment | Keyless mechanism | What you must get right |
|---|---|---|
| Azure, cross-tenant | Managed identity + federated credential on a multitenant app | The app must be in the same tenant as the identity and provisioned into the customer's tenant |
| AWS | IAM role and temporary credentials | An External ID unique to each customer, generated by the provider, checked in the trust policy |
| Google Cloud | Workload Identity Federation | Issue no service account keys |
| GitHub Actions | OIDC exchanged for short-lived tokens | Do not copy cloud credentials into GitHub secrets |

The AWS row has a detail that is often done backwards. The External ID guards against the confused deputy problem, and AWS requires the value to be unique across customers and controlled by the provider. If customers choose their own, one customer could enter another customer's ID and trick your service into opening a role that is not theirs.

## Putting it to work at your first customer

In discovery, ask which cloud the customer uses, which tenant, whether it is the global cloud or a government cloud, and who has the authority to grant roles. Then write a one-page description of the identity flow: which workload, where it runs, which resource it requests tokens for, and the narrowest role it needs.

A page like that shows the customer's admin exactly what they are granting, and is far easier to approve than a request for "Contributor access, please".

Next, build the flow in your own test environment first and run the token exchange until it succeeds. Only then send the customer the list of what they need to do. Grant access a day early so the 24-hour cache does not slow you down, and give each workload its own identity.

For your career, this is an easy skill to demonstrate. When reading FDE job ads, if the description mentions deploying into customer environments or cloud accounts, you will most likely need exactly this skill.

On a CV, a line such as "deployed into customer tenants without any long-lived credentials" is worth more than a list of cloud certifications. In interviews, be ready to draw the token flow from machine to resource.

A successful project is one where, when you leave, the customer does not have to hunt down and rotate any key you once held.

**Try this week:**

- Audit the repo and CI configuration of your current project, list every long-lived cloud credential, and note beside each one the keyless mechanism that could replace it
- In a test Azure tenant, create a VM with a user-assigned managed identity, call the IMDS endpoint for a token, then read a blob without any secret
- Move one GitHub Actions workflow that uses a cloud secret over to OIDC

## Sources

- [Managed identities for Azure resources - Microsoft Learn](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)

- [Use managed identities on a virtual machine to acquire access token - Microsoft Learn](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token)

- [Best practice recommendations for managed system identities - Microsoft Learn](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/managed-identity-best-practice-recommendations)

- [Configure an application to trust a managed identity - Microsoft Learn](https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-config-app-trust-managed-identity)

- [Access to AWS accounts owned by third parties - AWS IAM User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html)

- [The confused deputy problem - AWS IAM User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)

- [Workload Identity Federation - Google Cloud IAM documentation](https://docs.cloud.google.com/iam/docs/workload-identity-federation)

- [OpenID Connect - GitHub Docs](https://docs.github.com/en/actions/concepts/security/openid-connect)

- [State of Cloud Security | Datadog](https://www.datadoghq.com/state-of-cloud-security-2025/)
