NO_WILDCARD: How I discovered the Organization ID of any AWS Account
A researcher found that by creating a VPC Endpoint for EventBridge with a policy that used wildcards, they could determine the AWS Organization ID of any AWS account by observing which requests appeared in CloudTrail. This allowed correlating accounts to the same organization without authorization.
When I published how to find the AWS Account ID of any S3 bucket earlier in the year, I felt like I had just scratched the surface of a general technique which might yield even more interesting results with a bit more research. However, building Tracebit keeps me quite busy so I had to put security research on the…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
VPC Endpoints are a core building block of an AWS Data Perimeter. A VPC Endpoint Policy can restrict which IAM principals may reach a service through the endpoint, and S3 buckets can additionally be restricted by a Resource Policy so that they are only reachable via that endpoint. The interesting property, from a research point of view, is that VPC Endpoint policy denials are not written to CloudTrail.
The author's earlier work showed that this silence could be abused: by iteratively testing wildcards in an S3 VPC Endpoint Policy against the aws:ResourceAccount condition key, you could determine the account ID that owns an arbitrary S3 bucket. This write-up extends that idea to other AWS services and, ultimately, to a different condition key: aws:ResourceOrgId, the identifier of the AWS Organization an account belongs to.
An AWS Organization centralises management of many AWS accounts and has an identifier of the form o-a1b2c3d4e5. Even an org that segments workloads across many accounts will usually keep them under one, or a very small number of, organizations for billing and management. Being able to correlate accounts to an org without authorisation is therefore meaningful.

Setup
The technique needs three things:
- A service that supports a VPC Endpoint Policy and allows a cross-account call to a resource, whether or not that call is permitted.
- A predictable resource in the target account to aim requests at.
- A way to distinguish requests that passed the endpoint policy from those that did not, without the denials themselves being logged.
To narrow the field, the author asked AWS for the list of endpoint services that support VPC Endpoint Policies. At the time of writing there were 242 such services. Not all are useful: AWS Polly, for example, supports a VPC Endpoint Policy, but none of its API actions appear to allow referencing a resource in another account.

As a starting point for services likely to support cross-account access, the author used the list of AWS services that work with IAM and picked out those supporting resource-based policies. That misses some services (EBS snapshots support cross-account access, but not via resource policies), but it left around 25 services, including DynamoDB, Lambda and SQS.
Finding it
Having a service is not enough; you need a resource to target. In the S3 case the bucket of interest was already known. When all you have is an account ID, you have to guess which resources exist. Some guesses are reasonable, for example that a resource with a predictable name exists in account 123456789012; others are far less likely.
The resource the author settled on was the Default EventBridge Event Bus, because of three properties:
- It exists in every account, in every region.
- It cannot be deleted.
- It has an entirely deterministic ARN that differs only in the account ID segment.
That makes it a reliable target for any account ID you want to probe. The plan was to create a VPC Endpoint for EventBridge whose policy would let the author discover the Organization ID of an arbitrary Event Bus, and therefore of an arbitrary account, by sending a request with a different role session name for each candidate. Requests that passed the endpoint policy would appear in CloudTrail and reveal aws:ResourceOrgId.

Exploitation
Step 1: understand why denials are silent
The absence of CloudTrail entries for endpoint policy denials is deliberate, and the author's reasoning is that it prevents CloudTrail from becoming a data exfiltration channel. Consider a locked-down VPC with no internet access, an endpoint policy allowing only IAM principals from the correct account to reach S3, and only for one specific bucket, with the bucket's resource policy also requiring the endpoint. An attacker with credentials for that bucket still cannot copy data to their own bucket, because the endpoint policy restricts them to the one bucket.
CloudTrail would be an escape hatch: an attacker could bring their own credentials into the VPC, make requests that the endpoint policy denies, and if the request details were logged to the requester's CloudTrail, data could leave through something as simple as the user agent string. That is the author's explanation for why endpoint policy denials are not logged.

Step 2: pick a condition key and a target
For services other than S3, resources are not in a globally shared namespace, and the account ID is an explicit part of the ARN, so there is no puzzle about which account owns a resource. The interesting question becomes which other resource context keys can be discovered with the same wildcard technique.

With the Default EventBridge Event Bus as the target, the key to probe is aws:ResourceOrgId. The number of possible Organization IDs is far larger than the number of possible account IDs, which makes the search harder.
Step 3: split the search across endpoints
The maximum size of a VPC Endpoint Policy meant the candidate Organization IDs had to be split across three separate VPC Endpoints, with each request sent to the endpoint holding the relevant candidates. The author adapted the earlier S3 tooling and ran it against the target.
The result was that the Organization ID of any AWS account could be discovered within 5 minutes, and the target account had no way to prevent it.
Root cause
The technique relied on VPC Endpoint Policies accepting wildcards in condition values that reference system-generated identifiers, combined with the fact that endpoint policy denials are not logged. A wildcard in a policy turns the endpoint into an oracle: a request that matches produces a CloudTrail entry, a request that does not match produces nothing. Because the denial is invisible, the attacker learns one bit per request without leaving a trace in the target's logs.
The same property applied to aws:ResourceAccount for S3 and to aws:ResourceOrgId for EventBridge. The author notes there was nothing the target account could do to prevent it.
Impact
The technique allows correlating AWS accounts as belonging to the same AWS Organization. It can definitively confirm or deny that an account is associated with a given organization, which matters for orgs that would rather third parties could not associate their sandbox accounts with them.
A second example concerns AWS Canary Credentials, which Tracebit deploys at scale for customers. The author had previously identified that being able to determine which organization a set of credentials belongs to, without using the credentials at all, could make certain canary credentials much less effective. A technique that needs only a single Organization ID, rather than a potentially stale or incomplete list of account IDs, would make such attacks considerably more powerful.
Fix
AWS made significant changes intended to prevent this technique, the earlier S3 technique and obvious variants. Wildcards are now prevented in several locations in a VPC Endpoint policy. The documentation now states:
- You can't use wildcard characters (* or ?) or numeric condition operators with global context keys that reference system-generated identifiers (for example, aws:PrincipalAccount or aws:SourceVpc).
- When you use a string condition operator, you must use at least six consecutive characters before you include a wildcard character.
- When you specify an ARN in a resource or condition element, the account portion of the ARN can include an account ID or a wild card, but not both.
Attempting to create such a policy now returns a new NO_WILDCARD error.

The author notes that a wildcard is still permitted after six consecutive characters and wonders whether there is an obscure reason to keep supporting that. The timeline was four weeks from finding to fix:
| Date | Event |
|---|---|
| 4 June | Finding reported to AWS security |
| 12 June | AWS indicated changes were underway (and that the author should not attempt a live demo at fwd:cloudsec) |
| 2 July | AWS confirmed the IAM team were rolling out the NO_WILDCARD change; by this point it appeared to be deployed to the entire aws partition |
| 12 July | AWS confirmed the documentation had been updated |
The finding was also reported to a vendor offering AWS Canary Credentials who could have been particularly affected.
Variants to test
The general pattern is: find a service with a VPC Endpoint Policy, find a resource in the target account whose ARN is predictable, and probe a system-generated condition key with wildcards while watching for the requests that survive into CloudTrail.
- Other default resources. The author asks whether anyone has collected a list of default resources beyond the Default VPC. Any resource that exists in every account, cannot be deleted and has a deterministic ARN is a candidate target. A positive result is a request that passes the endpoint policy and appears in CloudTrail, revealing the condition key value for the target account.
- Other resource context keys. The same oracle can be pointed at keys other than
aws:ResourceAccountandaws:ResourceOrgId. A positive result is a request that passes the endpoint policy and appears in CloudTrail, revealing the condition key value. - Services with resource-based policies. The author's shortlist of around 25 services (DynamoDB, Lambda, SQS and others) is a starting point for services likely to permit cross-account references. A positive result is a service where a cross-account call can be constructed at all, whether or not it is authorised.
- Services without resource-based policies. EBS snapshots support cross-account access without resource policies, so the resource-policy filter is not exhaustive. A positive result is any service where a cross-account reference is possible by another mechanism.
- The six-character window. Wildcards are still permitted after six consecutive characters.
Thanks
The author credits Nick Frichette and Rami McCarthy for their advice in preparing the post.
What happened, in plain words
Imagine you have a membership card for a gym chain. The card has a number on it, and that number tells the gym's computer which branch you belong to. Now imagine that the gym's front desk will answer one very simple question for anyone who asks: "does this card number start with these digits?" It answers yes or no, and it never writes down that it was asked. If you can ask that question as many times as you like, with different guesses, you can eventually work out the full card number without ever being a member.
That is roughly the shape of the bug described here, but with cloud computers instead of gyms. Amazon Web Services (AWS) is a company that rents out computers, storage and other services over the internet. Customers rent these services inside something called an AWS account, which is a container for everything a customer owns on AWS. Each account has a long number, its account ID, and accounts can be grouped into an AWS Organization, which is a way of managing many accounts together for billing and administration. Each organization also has an identifier, the Organization ID, which looks like o-a1b2c3d4e5.
The researcher, Sam Cox, found a way to learn the Organization ID of any AWS account, without permission and with nothing the target could do to prevent it. He did it by exploiting a feature called a VPC Endpoint, which is a private doorway that lets computers inside a customer's private network reach AWS services. Each doorway can have a rule attached, a VPC Endpoint Policy, saying who may pass through it. The trick was that when a request is refused at the doorway, AWS does not write the refusal into its logging service, CloudTrail. Silence, in other words, is the signal: if a request shows up in the logs, it passed the rule; if nothing appears, it did not. By crafting rules with wildcards (the * character, meaning "anything here") and watching which requests survived into the logs, the researcher could ask the doorway yes/no questions about the target account's Organization ID.

The diagram above shows the general idea: a VPC Endpoint Policy is used as the thing being tested, and the answer comes back through whether a request appears in CloudTrail.
This was not the first time he had done something like this. Earlier in the year he had published a technique for finding the AWS account ID behind any S3 bucket (S3 is AWS's file storage service, and a bucket is a folder-like container in it). That earlier work felt like scratching the surface, and he suspected the same idea could go further. Building his company, Tracebit, kept him busy, so the deeper research waited until he was preparing a talk for a cloud security conference called fwd:cloudsec. Preparing that talk pushed him to answer the big open questions, and in doing so he found this new issue. AWS then made significant changes to how VPC Endpoints behave, which, in his words, seems to have ended the fun for this kind of information discovery.
What a VPC Endpoint policy is, and why refusals are silent
The earlier blog post covers the full background, so this one only summarises it. The essential point: you could work out the aws:ResourceAccount condition key (in plain terms, the account ID that owns a resource) by repeatedly testing wildcards in S3 VPC Endpoint Policies. The reason it worked is that when an S3 VPC Endpoint policy refuses a request, that refusal is not recorded in CloudTrail.
Why would AWS deliberately not log those refusals? The researcher's explanation is that logging them would turn CloudTrail into a way of smuggling data out of a locked-down network. VPC Endpoints are a crucial building block when a company sets up a Data Perimeter, which is a set of boundaries designed to keep sensitive data inside the company's own network and accounts. Picture a private network with no internet access at all, where the endpoint policy only lets people from the "correct" account reach S3, and only for one specific bucket. The bucket itself may also have a Resource Policy (a rule attached directly to the resource) saying it can only be reached through this endpoint.
Now suppose an attacker gets inside that network with stolen credentials that do allow access to the bucket. They still cannot copy the data out to their own bucket, because the endpoint policy restricts them to the one bucket in question. But CloudTrail could be an escape hatch. If the attacker brings their own credentials into the network and makes requests that the endpoint policy refuses, and if the details of those requests were written to the attacker's own CloudTrail, then data could leave through something as simple as the user agent (the text a browser or tool sends to identify itself with each request). The researcher believes this is why CloudTrail does not log VPC endpoint policy denials.

The image above illustrates that S3 does not deliver CloudTrail logs to the requester or the bucket owner for VPC endpoint requests when the VPC endpoint policy denies them.
Why other services are different
S3 is unusual because bucket names live in one globally shared namespace: anyone in the world can see that a bucket called, say, my-photos exists, but not who owns it. Most other AWS services do not work like that. Their resources live inside a single account, and the account ID is written explicitly into the resource's ARN (Amazon Resource Name, the unique address of a resource, which includes the account ID as one of its segments). So for those services there is no puzzle about which account a resource belongs to: it is right there in the address.
That raises a different question: which other pieces of information about a resource could be discovered with the same wildcard trick? AWS exposes a set of resource context keys, which are named pieces of information about a resource that can be referenced in rules, such as its account, its organization, or its tags.

The image above lists some of the resource context keys that might be discovered using the same technique.
Extending the technique to arbitrary AWS services felt fairly straightforward in principle, but getting a reliable setup for services other than S3 took longer than expected. By the time he had it working, he had a definite goal: find a way to discover the AWS Organization ID of an arbitrary third-party AWS account.
The hunt for the Organization ID
An AWS Organization lets a company manage many AWS accounts centrally. Each organization has an identifier of the form o-a1b2c3d4e5. The significance is this: even a careful company that splits its workloads across many separate accounts will usually keep them all under one organization, or a very small number, for billing and management. So if you can link an account to an organization without permission, you learn something the company may not want you to know.
To find candidate services, the researcher asked AWS for the list of endpoint services that support VPC Endpoint Policies. At the time of writing there were 242 of them. That is far too many to try one by one, so he narrowed the field. For the technique to work at all, he needed to be able to make a cross-account call: a request from one account that refers to a resource in another account, whether or not that request is ultimately allowed. AWS Polly, a text-to-speech service, is an example of a service that supports a VPC Endpoint Policy but does not appear to offer any API action that can reference a resource in another account, so it was no use.

The image above notes that only some AWS services support resource-based policies.
As a starting point, he used the list of AWS services that work with IAM (AWS's identity and permissions system) and picked out the ones that support resource-based policies, since those are the most likely to allow some form of cross-account access. This filter certainly misses some services: EBS snapshots, for instance, support cross-account access but not through resource policies. Still, it left around 25 services, including popular ones such as DynamoDB, Lambda and SQS.
Default resources: you need something to aim at
Having a suitable service is not enough. You also need a resource in the target account to send requests to. In the S3 case, the bucket of interest was already known. But when all you have is an account ID, you have to guess which resources exist. Some guesses are reasonable: if you are targeting account 123456789012, there is a fair chance that a resource with a predictable name exists there. Other guesses are far less likely to pay off.
One resource stood out: the Default EventBridge Event Bus. EventBridge is AWS's event routing service, and a bus is the channel through which events flow. The default bus has three properties that make it ideal:
- It exists in every account, in every region.
- It cannot be deleted.
- It has an entirely deterministic ARN, which differs only in the account ID segment.
In other words, if you know an account ID, you know exactly the address of a resource that is guaranteed to be there. That is exactly what the technique needed. The plan was to create a VPC Endpoint for EventBridge with a policy that would let him discover the Organization ID of an arbitrary Event Bus, and therefore of an arbitrary account, by sending a request with a different role session name for each candidate. A role session name is a label attached to a temporary set of credentials; it appears in the logs, so it can be used to tell requests apart. Requests that passed the endpoint policy and then appeared in CloudTrail would reveal aws:ResourceOrgId.

The image above shows the idea of sending a request with a different role session name for each possibility, so that whichever request survives into CloudTrail reveals the value.
This was more complex than the S3 version, because there are far more possible Organization IDs than account IDs. The maximum size of a VPC Endpoint Policy meant the candidates had to be split across three separate VPC Endpoints, and each request had to be sent to the endpoint holding the relevant candidates. He adapted his earlier code and tried it. The result: the Organization ID of any AWS account could be discovered within 5 minutes, and there was nothing the target account could do to prevent it.
Why it worked
The technique relied on a combination of two things. First, VPC Endpoint Policies accepted wildcards in condition values that refer to system-generated identifiers. Second, endpoint policy denials are not logged. Together, those turn the endpoint into an oracle: a system you can ask yes/no questions and get reliable answers from. A request that matches the policy produces a CloudTrail entry; a request that does not match produces nothing. Because the refusal is invisible, the attacker learns one bit of information per request without leaving a trace in the target's logs. The same property applied to aws:ResourceAccount for S3 and to aws:ResourceOrgId for EventBridge. There was nothing the target account could do to prevent it.
Impact
The technique allows someone to correlate AWS accounts as belonging to the same AWS Organization. It can definitively confirm or deny that an account is associated with a given organization. That matters for companies that would rather third parties could not link their sandbox accounts (throwaway accounts used for testing) back to them.
A second example concerns AWS Canary Credentials, which Tracebit deploys at scale for its customers. A canary credential is a decoy: a set of credentials planted where an attacker might find them, so that if they are ever used, the defender knows an intrusion has happened. The researcher had previously identified a concerning use case: being able to determine which organization a set of credentials belongs to without using the credentials at all. That could make certain canary credentials much less effective. A technique that needs only a single Organization ID, rather than a potentially stale or incomplete list of account IDs, would make such attacks considerably more powerful.
Disclosure and fix
As soon as he discovered the technique, the researcher reported it to AWS Security. The finding was also reported to a vendor offering AWS Canary Credentials, who could have been particularly affected. AWS indicated that it intended to fix the issue, and ultimately made significant changes intended to prevent this technique, the earlier S3 technique, and any obvious variants from being created.
AWS now prevents wildcards from being used in several places in a VPC Endpoint policy. The documentation for VPC Endpoint policies now includes these new rules:
- You can't use wildcard characters (* or ?) or numeric condition operators with global context keys that reference system-generated identifiers (for example, aws:PrincipalAccount or aws:SourceVpc).
- When you use a string condition operator, you must use at least six consecutive characters before you include a wildcard character.
- When you specify an ARN in a resource or condition element, the account portion of the ARN can include an account ID or a wild card, but not both.
In practice, if you try to create such a policy today, you get a brand new NO_WILDCARD error message:

The image above shows the error message indicating that the condition key aws:ResourceOrgId with the value o-??????z??? is at risk of NO_WILDCARD.
This was effectively the change the researcher anticipated during his talk. One aspect he finds intriguing is that a wildcard is still permitted after six consecutive characters. He wonders whether there is some obscure reason to keep supporting that.
He also notes that while the Default VPC (the network AWS creates for you automatically) is well known, he had not given much thought before this research to which other default resources might exist in an AWS account, and he would be interested if anyone has collected a list.
He was impressed with the speed of the fix: four weeks from finding to fix.
| Date | Event |
|---|---|
| 4 June | Finding reported to AWS security |
| 12 June | AWS indicated changes were underway (and that he should not attempt a live demo at fwd:cloudsec) |
| 2 July | AWS confirmed the IAM team were rolling out the NO_WILDCARD change; by this point it appeared to be deployed to the entire aws partition |
| 12 July | AWS confirmed the documentation had been updated |
He is not sure whether this finding was considered more significant than the earlier S3 finding. There is certainly something interesting about the fact that there was no possible mitigation. Perhaps, he suggests, this was the straw that broke the camel's back, because it demonstrated the wider application of the technique.
Variants to test
The general pattern is: find a service with a VPC Endpoint Policy, find a resource in the target account whose ARN is predictable, and probe a system-generated condition key with wildcards while watching for the requests that survive into CloudTrail.
- Other default resources. The researcher asks whether anyone has collected a list of default resources beyond the Default VPC. Any resource that exists in every account, cannot be deleted and has a deterministic ARN is a candidate target. A positive result is a request that passes the endpoint policy and appears in CloudTrail, revealing the condition key value for the target account.
- Other resource context keys. The same oracle can be pointed at keys other than
aws:ResourceAccountandaws:ResourceOrgId. A positive result is a request that passes the endpoint policy and appears in CloudTrail, revealing the condition key value. - Services with resource-based policies. The shortlist of around 25 services (DynamoDB, Lambda, SQS and others) is a starting point for services likely to permit cross-account references. A positive result is a service where a cross-account call can be constructed at all, whether or not it is authorised.
- Services without resource-based policies. EBS snapshots support cross-account access without resource policies, so the resource-policy filter is not exhaustive. A positive result is any service where a cross-account reference is possible by another mechanism.
- The six-character window. Wildcards are still permitted after six consecutive characters.
Thanks
The researcher credits Nick Frichette and Rami McCarthy for their advice in preparing the post.
Glossary
- AWS: Amazon Web Services, a company that rents out computing, storage and other services over the internet.
- AWS account: a container for everything a customer owns on AWS, identified by a long number called the account ID.
- Account ID: the numeric identifier of an AWS account.
- AWS Organization: a way of managing many AWS accounts together for billing and administration.
- Organization ID: the identifier of an AWS Organization, of the form
o-a1b2c3d4e5. - VPC: Virtual Private Cloud, a private network inside AWS where a customer's computers run.
- VPC Endpoint: a private doorway that lets computers inside a VPC reach AWS services without going over the public internet.
- VPC Endpoint Policy: a rule attached to a VPC Endpoint saying who may pass through it and to what.
- CloudTrail: AWS's logging service, which records actions taken in an account.
- S3: AWS's file storage service; a bucket is a container in it.
- Resource Policy: a rule attached directly to a resource, saying who may access it and how.
- Data Perimeter: a set of boundaries designed to keep sensitive data inside a company's own network and accounts.
- User agent: the text a browser or tool sends with each request to identify itself.
- ARN: Amazon Resource Name, the unique address of a resource, which includes the account ID as one of its segments.
- Resource context key: a named piece of information about a resource (such as its account or organization) that can be referenced in rules.
- Condition key: a named value used in a rule to decide whether a request is allowed, such as
aws:ResourceAccountoraws:ResourceOrgId. aws:ResourceAccount: the condition key holding the account ID that owns a resource.aws:ResourceOrgId: the condition key holding the Organization ID that a resource's account belongs to.- Cross-account call: a request from one account that refers to a resource in another account.
- IAM: AWS's identity and permissions system, which decides who can do what.
- IAM principal: an identity (a user or role) that can make requests to AWS.
- Resource-based policy: a policy attached to a resource rather than to an identity.
- EventBridge: AWS's event routing service; a bus is the channel through which events flow.
- Default EventBridge Event Bus: the bus that exists automatically in every account and region, cannot be deleted, and has a predictable ARN.
- Role session name: a label attached to a temporary set of credentials, which appears in logs and can be used to tell requests apart.
- Wildcard: the
*character (and?), meaning "anything here", used in rules to match many values at once. - Oracle: a system you can ask yes/no questions and get reliable answers from, which is what the endpoint became.
- Bit: the smallest unit of information, a single yes/no answer.
- Exfiltration: secretly moving data out of a network.
- Canary credential: a decoy set of credentials planted where an attacker might find them, so that any use signals an intrusion.
- Sandbox account: a throwaway account used for testing.
- Default VPC: the network AWS creates automatically in an account.
- EBS snapshot: a saved copy of a disk volume in AWS.
- Partition: a separate instance of AWS's cloud; the main one is called
aws. NO_WILDCARD: the error AWS now returns when a VPC Endpoint policy tries to use a wildcard in a place where it is no longer allowed.