Cross-Tenant Information Disclosure: Unraveling Microsoft Connections, Custom Connectors, and OAuth 2.0 in Power Automate
A cross-tenant information disclosure vulnerability in Microsoft Power Automate allowed an attacker to create a custom connector using the client ID of a legitimate Microsoft application (e.g., Teams or SharePoint) and a controlled token URL, then trick a victim into visiting a consent link to leak an OAuth authorization code. The attacker could exchange this code for an access token and link it to their own connection, gaining access to the victim's data in that application.
Published on fatnassifiras.medium.com
This article is about a vulnerability I recently discovered in the Microsoft Power Automate Platform, which involved chaining exploits between two authentication features.
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
Microsoft Power Automate is an automation platform that lets users build workflows across external services. Two features matter here: Connections and Custom Connectors.
Connections are the bridges that let Power Automate talk to external services such as Microsoft 365, Dropbox or Salesforce. Custom Connectors let you build your own bridge to a service that is not natively supported, so Power Automate can interact with your own systems or APIs. The important design detail, stated in the write-up, is that connections are built on top of custom connectors: the Power Automate team pre-built the most common applications, but the custom connector feature is public so users can connect to anything else.
Both features rely on OAuth 2.0. In the code flow, the client is redirected to the authorisation server, the user authenticates and consents, and the browser is redirected back to the original page with a code. The client then exchanges that code for an access token over a back-channel, sending the code together with its client_secret. The extra code step exists as a security layer: a captured code is useless without the client secret.

The write-up focuses on the code flow only.
Setup
The researcher used the public connections and custom connectors features. The researcher used a server under his control as a webhook to receive leaked codes, and a web page to host the exploit links.
Finding it
The researcher walked through the normal connection creation flow and captured the requests. Clicking Create on the connections page triggers a request to create a consent link; the server then sends a GET request to that consent link; the user is redirected to an authentication pop-up; and after choosing an account, three further requests finish the OAuth 2.0 flow.


In the second part of the flow there are back-and-forth redirects between the client and the authorisation server to exchange the code for what the write-up calls the final code (normally the access token; here it is also called a code, so the write-up distinguishes it as final code). The write-up notes that a normal scenario would use one request, but here the domain changed from global to Canada, which the researcher attributes to load balancing to reach the closest authorisation server. Once the final code is obtained, a POST request is sent to the confirmConsentCode endpoint to link the final code with the connection.
One request stood out: the POST request that creates the consentLink, because its body contains a redirectUrl parameter, meaning the caller controls where the flow redirects. The researcher tried two ideas against it.
- Change
redirectUrlto a controlled server (the typical OAuth 2.0 attack) and send the link to the victim to leak the code. This failed: as soon as the system flags that the URL is changed, it displays a warning to the victim.

- CSRF the victim by sending the
consentLinkwith the default URL, assuming that if the victim finished the flow their account would be linked to the attacker's connection. This also failed: after the victim chose an account, the screen froze on a loading page.

The researcher attributes this to front-end behaviour: the flow was not initiated from the victim's browser, so the front-end does not know which requests to initiate at each point. Promises handling the flow only work if the victim clicked Create in their own browser, keeping front-end and back-end in sync.
Exploitation
The way in is the custom connector feature. Creating a custom connector offers many options; the write-up uses the most basic one, a blank custom connector with OAuth 2.0 selected.

After clicking continue, a page asks for the required information.

The Security tab is the interesting part: it accepts OAuth 2.0 details of your own application, including Client ID and Client Secret. The client_id is a fixed, unique identifier for a client application in OAuth 2.0. The researcher asked what would happen if the Microsoft Teams client_id were specified there.
Step 1: Create the custom connector with a foreign client_id
The fields were filled as follows:
client_idwith Microsoft Teams.client_secretwith anything, as it does not matter.authorization_urlwithhttps://login.windows.net/common/oauth2/authorize, a known authorisation server that is aware of the Microsoft Teamsclient_idand will generate a code for it.token_urlwith a controlled server, to leak the code: in the code flow the client sends the code to the token endpoint in exchange for the access token, so pointing that endpoint at the attacker's server delivers the code.refresh_urldoes not matter.

Step 2: Start a test connection and capture the code
After creating the connector, the Test tab allows creating a new connection to test the connector. The flow looks exactly like the normal connection creation flow, because connections are built on top of custom connectors.

After choosing an account in the authentication pop-up, the code arrived in the webhook.

The authorisation server was tricked into generating an OAuth 2.0 code under the Microsoft Teams application, and the code was leaked by injecting the controlled server as the token URL.
Step 3: Deliver the consent link to the victim
To attack someone, the attacker sends the consentLink as it is, with the default URL from the response, without tampering with it. Once the victim follows the link, the attacker receives a code tied to the victim's account session and belonging to the Microsoft Teams client application.
Step 4: Exchange the leaked code for the final code
The leaked code is not yet an access token. The connection creation flow is reused here. Request number 23303 is responsible for exchanging the code with the final code.


Giving it the code returns the final code in the Location header.
Step 5: Link the final code to the attacker's connection
The final code is then used in a POST request to link it with the connection object.

The write-up speculates that the final code is an identifier for the access token, used only in the backend and not visible to the user.
The full attack scenario
- The attacker initiates a connection creation process and captures and saves two requests: the one that exchanges the code for the final code, and the one that links the final code with the connection.
- He creates a custom connector with the
client_idof the application he wants to compromise the user in. It has to be the same application he created a connection to in the first step. - He gets the
consentLinkfrom theTesttab by trying to create a new connection to that custom connector. - He puts the link on his web page and induces the user to visit it.
- As soon as the user visits the page, the code arrives in the webhook.
- He uses it with the first captured request to exchange it for the final code.
- He links the final code with the connection created in the first step.
For example, to compromise a victim's APP_1 account, the attacker first creates a connection to APP_1, then a custom connector with the APP_1 client_id. The exploit page can embed as many links as wanted; the researcher built one that took over both SharePoint and Teams, leaking their codes and giving access to whatever information the victim had access to.

Root cause
The custom connector feature lets a user supply an arbitrary client_id together with an arbitrary token_url. The custom connector accepts an arbitrary client_id together with an arbitrary token_url. The authorisation server, which does know the Microsoft Teams client_id, happily issues a code for it, and the platform then sends that code to the attacker-controlled token URL as part of the code exchange. The code is therefore delivered to the attacker's controlled server.
The earlier defences did not help: tampering with redirectUrl is detected and shown to the victim, and replaying the default consentLink without the victim's browser initiating the flow breaks the front-end state handling.
Impact
An attacker can obtain OAuth 2.0 codes tied to a victim's account session for an application whose client_id the attacker chooses, then exchange and link them to a connection the attacker controls. In the researcher's demonstration this gave access to the victim's SharePoint and Teams data, meaning whatever information the victim had access to. The victim has to visit the attacker's page and complete the authentication and consent pop-up; the attacker must first create a connection to the same application and capture the two linking requests.
Fix
The write-up states that the MSRC team handled and fixed the issue but does not describe the change.
Variants to test
- On other platforms with custom connector or bring-your-own-OAuth features, supply a well-known first-party
client_idwith an attacker-controlled token URL. A positive result is a code arriving at the controlled endpoint after a user consents. - Try the same with other OAuth grant types or endpoints (for example device code or implicit) where the platform accepts user-supplied URLs. A positive result is a token or code delivered to the attacker's server.
- Test whether the consent link can be replayed across sessions or users without the front-end state, looking for a flow that completes rather than freezing. A positive result is a completed link between the victim's authorisation and the attacker's connection.
- Check whether
redirectUrlvalidation can be bypassed (for example with path or host variations) instead of being flagged. A positive result is a redirect to the attacker's server without the warning page. - Test whether the final code can be linked to a connection created by a different user or tenant. A positive result is access to the victim's resources through the attacker's connection.
What happened, in plain words
A security researcher found a way to trick Microsoft Power Automate, a website that helps people automate tasks between different online services, into handing over a special password-like string that belonged to someone else's account. The trick used two features of the site: Connections and Custom Connectors. By combining them, the researcher could make the site ask Microsoft's login system for a temporary code, receive that code on a server he controlled, and then turn it into access to data in services such as SharePoint and Microsoft Teams.
The victim had to click a link, log in and consent in the pop-up. Everything else happened behind the scenes. This article walks through the whole story from the beginning, explaining every term as it appears, so you can follow it even if you have never studied security.
The product and the two features
Power Automate is a Microsoft service. You use it to say things like "when an email arrives, save the attachment to my cloud drive" or "when a form is submitted, post a message in a chat". To do that, Power Automate needs permission to talk to other services on your behalf. It does this through two kinds of building blocks.
Connections are the bridges. A connection is a saved permission that lets Power Automate talk to an outside service such as Microsoft 365, Dropbox or Salesforce. Think of it like a key you have already handed to a trusted assistant: the assistant can now open the door to that service whenever your workflow needs to.
Custom Connectors are a way to build your own bridge to a service that Power Automate does not already support. If you have your own internal system or a small web service, you can describe it to Power Automate and it will let your workflows talk to it. The write-up points out an important design detail: connections are built on top of custom connectors. The Power Automate team pre-built the most common applications for you, but the custom connector feature is public so anyone can connect to anything else.
Both features rely on a protocol called OAuth 2.0, which is the standard way websites ask for permission to access your account somewhere else without ever seeing your password.
What OAuth 2.0 is and how it works
OAuth 2.0 is a widely used security protocol. It lets one application (here, Power Automate) access resources on another service on your behalf, without exposing your login credentials. The everyday comparison is a hotel key card: you do not give the hotel your house key, you get a temporary card that opens only the doors you are allowed to open, and it can be cancelled.

The image above is a reference to the official OAuth 2.0 specification (RFC 6749, section 4.1), which the write-up links to.
There are 3 flows in OAuth 2.0. In this context we only care about the code flow. Here is how it works, step by step:
- The flow begins when the application sends your browser to the authorisation server. That is the login system of the service you want to connect to (for example, Microsoft's login page).
- You authenticate there, if you are not already logged in, and you consent to the authorisation request. Consent means you click a button that says something like "Yes, let this app access my account".
- After you consent, the authorisation server sends your browser back to the original page, and it includes a short-lived code in the address.
- The application (Power Automate) then takes that code and exchanges it for an access token by talking directly to the authorisation server, in a request your browser never sees. This is called a back-channel.
- Once the authorisation server validates everything, it generates the access token. An access token is like the key card: a string the application can show to the service to prove it has permission.
The write-up includes a bonus explanation of why there is an extra step of getting a code and then exchanging it for a token, when another flow could return the token directly. The extra step is a security layer. Imagine someone standing behind you at a coffee shop and capturing the code while you authorise access, or you using a shared computer. With the code flow, even if someone captures the code, they cannot do anything with it. To exchange it for an access token, the client needs to send both the code and its client_secret to the authorisation server securely. The client_secret is a secret known only by the client and the authorisation server, and the exchange happens over a back-channel you never see.
A client_secret is like the PIN that goes with a bank card: the card number alone is not enough, you need the PIN too. The client_id is the card number: a fixed, unique identifier for a client application in OAuth 2.0.
Watching a normal connection being created
Creating a connection is straightforward. You go to the connections page, pick an application, and go through the whole OAuth 2.0 flow from signing in to consenting. Once you choose an application to connect with and click the Create button, the flow starts.

The image above shows the connection authentication flow. The steps are:
- Clicking the Create button triggers a request to create a consent link.
- A GET request from the server is sent to that consent link that was returned in the response.
- You are redirected to a small authentication pop-up to authenticate yourself.
- Once you choose which account you want to use, three other requests are initiated to finish the OAuth 2.0 flow.

The image above shows the rest of the flow. In this part there are a couple of back-and-forth redirects between the client and the authorisation server to exchange the code with the final code. The write-up calls it the final code because in this platform the access token is also referred to as a code, so the author distinguishes it. In other words, final code = access token.
In a normal scenario this should be one request, but here it seems to be load balancing: the domain was global at first and then changed to Canada. The researcher thinks this is to make sure you deal with the closest authorisation server for performance reasons.
Once the final code is obtained, a POST request is sent to the confirmConsentCode endpoint to link the final code with the connection. In a normal flow, this would be using the access token returned from the authorisation server to access resources from the resource server. The resource server is the service that actually holds your data, such as the Teams servers.
An endpoint is simply a web address that a program can send a request to. A POST request is one type of request; it is used when you are sending data to the server, as opposed to a GET request, which is used when you are asking for a page or data.
The first idea: change the redirect URL
Out of all the requests in the normal flow, one caught the researcher's attention: the POST request in the first image, the one responsible for creating the consentLink. Its body contains a redirectUrl parameter, which means the caller controls where the flow redirects. A parameter is a piece of information you send along with a request, like a field in a form.
So the researcher thought of two things.
- Change the
redirectUrlto a server he controlled. This is the typical OAuth 2.0 attack: if you can make the service send the code to your own server, you can capture it. He then sent the link to the victim to leak the code. Unfortunately, that did not work, because as soon as the system flags that the URL is changed, it displays the following to the victim:

The image above shows the warning the victim sees when the redirect URL has been tampered with. This obviously exposes the attacker, because the victim sees that something is wrong.
- The second idea was to CSRF the victim by just sending him the
consentLinkwith the default URL, assuming that if he finishes the flow his account will get linked to the attacker's connection and thus the attacker can access his information. CSRF stands for Cross-Site Request Forgery. In plain words, it is when an attacker makes your browser send a request you did not intend to send, using the fact that you are already logged in. This did not work either, because at some point after the victim chose which account to authenticate with, the screen froze at a loading page:

The image above shows the loading page where the flow got stuck. The researcher says this is related to front-end stuff, because the flow was not initiated from the victim's browser. The front-end is the part of the website that runs in your browser, as opposed to the back-end, which runs on the server. Consequently, the front-end does not know what to do: it does not know which requests to initiate at every point. Usually there are some promises that handle this, but they only work if the victim himself clicked the Create button at the first step from his browser, so that front-end and back-end are synced together. That was not the case here.
A promise is a programming concept: it is a placeholder for a result that will arrive later, like a ticket you get at a repair shop. The front-end uses promises to know what to do when each step of the flow finishes. If the flow did not start in that browser, there is no ticket, and the front-end waits forever.
So it looked like a dead end. But the researcher knew there was something, and that something was the custom connectors feature.
The custom connector feature
Creating a custom connector is quite complicated, because you have many options for how you want to connect Power Automate to your custom app. The write-up uses the most basic one: it creates a blank custom connector and then selects OAuth 2.0. The researcher believes that if you understood the connections part, just reading how a custom connector is created would make you notice the issue.
Before describing the custom connector creation process, one thing to know is that connections are built on top of custom connectors. The Power Automate team collected the most common and used applications and made them ready for us. But they still made the custom connectors feature public so that we can connect to other applications.

The image above shows the starting point of the custom connector creation. Once you click on continue, you are redirected to another page where you fill in the required information.

The image above shows that information page. What happens in the Security tab is what really interests us. There you can provide OAuth 2.0 details of your custom application, including Client ID and Client Secret.
The client_id is a fixed, unique identifier for a client application in OAuth 2.0. So the researcher thought: what would happen if I specify the Microsoft Teams client_id there? That is what this attack is about.
Step 1: Create the custom connector with a foreign client_id
The fields were filled as follows:
client_idwith Microsoft Teams.client_secretwith anything, as it does not matter.authorization_urlwithhttps://login.windows.net/common/oauth2/authorize, since that is a known authorisation server and is aware of the Microsoft Teamsclient_id, so it should be registered there. Thus, it will happily generate a code for us.token_urlwith a controlled server, to leak the code. In the OAuth 2.0 code flow, after obtaining the code, the client sends a request to the authorisation server's/tokenendpoint, presenting the code received from the authorisation server in exchange for the access token (the final code). But here we are putting our controlled server, so it is not really an authorisation server URL. It is just to get the code.refresh_urldoes not matter.

The image above shows how the form looks after filling in the information. The authorization_url is the address of the login system that will show the consent screen. The token_url is the address the platform will call to exchange the code for the final code. By pointing that second address at his own server, the researcher arranged for the code to be delivered to him.
Step 2: Start a test connection and capture the code
Finally, the connector is created, and the researcher jumps into the Test tab.

The image above shows the Test tab, where you can make a new connection to test if your custom connector is working. If you look closely, it looks exactly like the flow of creating a connection, because connections are built on top of custom connectors.
After choosing an account in the authentication pop-up, the researcher received the code in his webhook.

The image above shows the leaked code in the server logs. A webhook is simply a URL on your own server that another system will call when something happens. It is like leaving a forwarding address at the post office: anything sent there ends up with you.
So the feature was broken. The authorisation server was tricked into generating an OAuth 2.0 code under the Microsoft Teams application, and the code was leaked by injecting the controlled server as the token URL.
Step 3: Deliver the consent link to the victim
Now, to attack someone, the attacker just sends him the consentLink as it is, with the default URL from the response, without even the need to tamper with it. Once the victim follows the link, the attacker gets a code that is tied to the victim's account session and belongs to the Microsoft Teams client application.
A session is the period during which you are logged in. The code is tied to the victim's session, which is why it represents the victim's account and not the attacker's.
At this point you might ask why the normal connections were discussed at all, if the exploit is in custom connectors. The answer is the next question: what can you do with that code, since you need an access token at the end to access things? The final code is that access token in this context.
Step 4: Exchange the leaked code for the final code
The connection creation final process is shown again in the image below.

Request number 23303 is the one responsible for exchanging the code with the final code. It looks like the following:

As you can see, you give it the code and it returns the final code in the Location header. A header is extra information attached to a request or a response, like the label on a parcel. The Location header normally tells the browser where to go next; here it carries the final code.
And then finally that code is used in a POST request that looks like the following, to link it with the connection object:

The write-up adds a note to avoid confusion about the final code seen in the image above. If the researcher had to guess how things work in the background, he would say the final code is an identifier for the access token, but it is just used in the backend. We do not see it.
The full attack scenario
The attack scenario looks like the following:
- The attacker initiates a connection creation process, during which he captures and saves two requests: the one responsible for exchanging the code with the final code (access token), and the one used to link that final code with the connection.
- Then he creates a custom connector with the
client_idof whatever app he wants to compromise the user in. Note that it has to be the same app he created a connection to in the first step. - Then he gets the
consentLinkfrom theTesttab by trying to create a new connection to that custom connector. - He puts the link on his web page and induces the user to visit it.
- As soon as the user visits the page, the attacker receives the code in his webhook.
- He uses it with the first captured request as an exchange for the final code.
- Then he links the final code with the connection created in the first step.
To make things clear, let us say you want to compromise the victim's APP_1 account. Then you have to first create a connection to APP_1, then a custom connector with the APP_1 client_id.
The exploit web page would look like the following:

The image above shows the exploit page. The researcher made an exploit to take over both SharePoint and Teams. You can embed as many links as you want, leak their codes, and then you have access to whatever information the victim had access to.
Why it worked
The custom connector feature lets a user supply an arbitrary client_id together with an arbitrary token_url. The custom connector accepts an arbitrary client_id together with an arbitrary token_url. The authorisation server, which does know the Microsoft Teams client_id, happily issues a code for it, and the platform then sends that code to the attacker-controlled token URL as part of the code exchange. The code is therefore delivered to the attacker's controlled server.
The earlier defences did not help. Tampering with redirectUrl is detected and shown to the victim, and replaying the default consentLink without the victim's browser initiating the flow breaks the front-end state handling.
What an attacker could do
An attacker can obtain OAuth 2.0 codes tied to a victim's account session for an application whose client_id the attacker chooses, then exchange and link them to a connection the attacker controls. In the researcher's demonstration this gave access to the victim's SharePoint and Teams data, meaning whatever information the victim had access to. The victim has to visit the attacker's page and complete the authentication and consent pop-up. The attacker must first create a connection to the same application and capture the two linking requests.
The fix
The write-up states that the MSRC team handled and fixed the issue, but it does not describe the change.
Other things worth testing
- On other platforms with custom connector or bring-your-own-OAuth features, supply a well-known first-party
client_idwith an attacker-controlled token URL. A positive result is a code arriving at the controlled endpoint after a user consents. - Try the same with other OAuth grant types or endpoints (for example device code or implicit) where the platform accepts user-supplied URLs. A positive result is a token or code delivered to the attacker's server.
- Test whether the consent link can be replayed across sessions or users without the front-end state, looking for a flow that completes rather than freezing. A positive result is a completed link between the victim's authorisation and the attacker's connection.
- Check whether
redirectUrlvalidation can be bypassed (for example with path or host variations) instead of being flagged. A positive result is a redirect to the attacker's server without the warning page. - Test whether the final code can be linked to a connection created by a different user or tenant. A positive result is access to the victim's resources through the attacker's connection.
Takeaways from this vulnerability
- The researcher spent around three days trying to demystify the flow of each feature and connect the dots. Give it time.
- Without a solid understanding of the OAuth 2.0 protocol, he would not have been able to exploit the vulnerability. RFCs are really helpful. An RFC is a document that describes how internet standards work.
The researcher thanks the MSRC team for handling and fixing the issue, as well as some fellows from the community for reviewing the draft of this write-up.
Glossary
- Access token: a string that proves an application has permission to access a service on your behalf, like a temporary key card.
- API: an interface that lets one program talk to another, like a menu you order from.
- Authorisation server: the login system of a service that checks who you are and asks for your consent.
- Back-channel: a direct server-to-server communication that your browser does not see.
- Client: the application asking for permission, here Power Automate.
- Client ID (
client_id): a public, fixed, unique identifier for an application in OAuth 2.0, like a card number. - Client secret (
client_secret): a secret known only by the application and the authorisation server, like the PIN that goes with a card. - Code: a short-lived string the authorisation server gives back after you consent, which the application exchanges for an access token.
- Code flow: the OAuth 2.0 flow where a code is issued first and then exchanged for a token over a back-channel.
- Connection: a saved permission that lets Power Automate talk to an external service.
- Consent: your explicit agreement that an application may access your account.
- Consent link: a URL that, when visited, starts the consent process.
- CSRF (Cross-Site Request Forgery): an attack that makes your browser send a request you did not intend, using your existing login.
- Custom connector: a user-built bridge between Power Automate and a service that is not natively supported.
- Endpoint: a web address that a program can send requests to.
- Final code: the write-up's name for the access token in this platform.
- Front-end: the part of a website that runs in your browser.
- Back-end: the part of a website that runs on the server.
- GET request: a request used to ask for a page or data.
- POST request: a request used to send data to a server.
- Header: extra information attached to a request or response, like a label on a parcel.
- Location header: a header that normally tells the browser where to go next.
- OAuth 2.0: a widely used protocol that lets one application access resources on another service on your behalf without exposing your password.
- Parameter: a piece of information sent along with a request, like a form field.
- Promise: a programming placeholder for a result that will arrive later.
- Redirect URL (
redirectUrl): the address the browser is sent to after a step finishes. - Resource server: the service that holds the data being accessed.
- RFC: a document that describes how an internet standard works.
- Session: the period during which you are logged in.
- Token URL (
token_url): the address the application calls to exchange a code for an access token. - Webhook: a URL on your own server that another system calls when something happens.