Skip to content
OAuth / SSO Write-up Advanced

MSRC – Joint security research write up – Azure AD Consent bypass disclosure with Kim Jamia – Q1/2022

A combination of the knownClientApplications and preAuthorizedApplications attributes in Azure AD allowed a multi-tenant application to obtain user tokens without the user's consent. An attacker could bypass the consent framework and gain access to user attributes and refresh tokens for the application's scopes.

Joosua Santasalo Follow

Published on securecloud.blog

{{media:0}}

Joosua Santasalo (@SantasaloJoosua), Kim Jämiä (@KimJamia), on securecloud.blog

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a short write-up of an MSRC case concerning the Azure AD consent framework for multi-tenant applications. The behaviour in scope was a bypass of that consent framework: a multi-tenant application could obtain user tokens without the user ever being asked to consent, and without any service principal being created in the victim tenant.

The report describes the outcome of the bypass as getting user attributes with an access token, plus a refresh token for the scopes of the application.

From the original on securecloud.blog

The case was the author's first collaboration with co-contributor Kim Jämiä.

Setup

The bypass relies on two attributes of an app registration manifest, combined across two app registrations:

  • knownClientApplications
  • preAuthorizedApplications

The report does not describe the tenant setup, accounts or tooling used beyond the login parameters and manifest fragments shown below.

Finding it

The author first came across the behaviour by accident at the end of 2021, but assumed it was a misconfiguration on their own side, because requesting additional scopes later appeared to "fix" the behaviour.

In early 2022 Kim Jämiä independently discovered the same behaviour and also assumed it was publicly known quirky behaviour. Both researchers confirmed that this should not be the desired behaviour, since it allows bypassing consent and does not result in any service principal in the victim tenant. They decided to submit it to MSRC as a case.

Exploitation

Step 1: Understand the combination

The bypass is a combination of the knownClientApplications and preAuthorizedApplications attributes, which allowed bypassing consent for third-party scopes defined using those two attributes across two app registrations.

In the initial submission the author noted that, looking at the documented explanation, the behaviour seems by design, but results in an edge case where multi-tenant applications can get user tokens without any consent being initiated.

The relevant documentation text quoted in the report for preAuthorizedApplications reads:

preAuthorizedApplications do not require the user to consent to the requested permissions. Permissions listed in preAuthorizedApplications do not require user consent. However, any additional requested permissions not listed in preAuthorizedApplications require user consent

Step 2: Configure the login request

The login parameters used in the example are:

Text
resource:"41f71e46-cf85-474b-8c6d-09e5b653592a",
scope:"https://api-26965.thx.dewi.red/hacked offline_access profile openid email",
client_id:"41f71e46-cf85-474b-8c6d-09e5b653592a",
redirect_uri,
response_mode:"query",
response_type:"code",
endpoint:2,
tenantId:"common",

The request targets the common tenant, uses the authorisation code flow (response_type:"code", response_mode:"query"), and requests offline_access, profile, openid and email alongside a scope on the https://api-26965.thx.dewi.red/hacked resource. The client_id and resource are the same application identifier.

Step 3: Configure the first app registration

The preAuthorizedApplications attribute in the manifest was set as follows:

JSON
"preAuthorizedApplications":[{"appId":"abcdefg2-000a-1111-a0e5-812ed8dd72e8","permissionIds":["8748f7db-21fe-4c83-8ab5-53033933c8f1"]}],

This lists a client application (appId) and the permission IDs that are pre-authorised for it, so those permissions do not require user consent.

Step 4: Configure the second app registration

The knownClientApplications attribute in the manifest was set as follows:

JSON
"knownClientApplications":["41f71e46-cf85-474b-8c6d-09e5b653592a"],

The report does not explain this attribute further.

Step 5: Obtain tokens without consent

The bypass allowed user tokens to be obtained without consent being initiated, and without a service principal in the victim tenant. The tokens included an access token for reading user attributes and a refresh token for the application's scopes.

Root cause

The behaviour comes from the design of the two manifest attributes. preAuthorizedApplications removes the consent requirement for the permissions it lists. When third-party scopes are defined using both attributes across two app registrations, the consent step is skipped entirely for a multi-tenant application.

The report frames this as an edge case of documented, by-design behaviour rather than a coding mistake: the documentation itself states that permissions in preAuthorizedApplications do not require user consent. The gap is that the combination lets a multi-tenant application reach user tokens with no consent initiated and no service principal recorded in the victim tenant.

Impact

Under these conditions, a multi-tenant application can obtain user tokens without any consent being initiated, and can get user attributes with an access token plus a refresh token for the scopes of the application. Because no service principal is created in the victim tenant, there is no artefact there recording that the application was granted access.

Fix

Microsoft proactively addressed the issue and released a fix on 3/17.

  1. Register two applications and set preAuthorizedApplications on the resource app to list the client app and its permission IDs, then set knownClientApplications on the client app to reference the resource app. Send an authorisation request with tenantId:"common" and check whether a consent prompt appears. A positive result is tokens returned with no prompt and no service principal in the tenant.
  2. Request additional scopes beyond those listed in preAuthorizedApplications in the same login request. A positive result is that the extra scopes are still granted without consent; per the documentation quoted above, they should require it.
  3. Repeat the login with a fresh user who has never consented to the application. A positive result is an access token and refresh token issued on first contact, with no consent record created in that user's tenant.
  4. Vary the resource and scope values in the request while keeping the two manifest attributes in place. A positive result is that consent is bypassed for scopes other than the ones explicitly listed, which would show the bypass is not limited to a single permission set.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Microsoft runs a service called Azure AD that handles logging in for companies and their apps. When an app wants to read something about you, such as your name or email address, Azure AD is supposed to stop and ask you first: "Do you allow this app to see this?" That question is called consent.

This report is about a way to skip that question. Two researchers, Joosua Santasalo and Kim Jämiä, found that by setting up two app registrations in a particular way, an app could get hold of your data without you ever being asked. The app also left no trace in your company's Azure AD that it had been given access.

Microsoft's security response team (MSRC) handled the case, and a fix was released on 17 March. The report does not describe what the fix changed.

From the original on securecloud.blog

This was the author's first piece of work together with Kim Jämiä.

The words you need first

Before the steps make sense, here are the ideas they rest on. Each one is explained from scratch.

  • Azure AD / Entra ID: Microsoft's cloud service that stores user accounts for organisations and checks passwords when people sign in. Think of it as the reception desk of an office building: it checks who you are and which doors you are allowed through.
  • Tenant: one organisation's own separate copy of Azure AD. Every company gets its own tenant, with its own users and its own settings. Two tenants cannot see each other's users by default.
  • App registration: a record in a tenant that describes an application: its name, its ID, where it may send users after login, and what it is allowed to ask for. It is like registering a visitor at the reception desk so the building knows who they are.
  • Multi-tenant application: an app registration that is designed to be used by many organisations at once, not just the one that created it. A public note-taking app that any company can adopt is a typical example.
  • Client and resource: in a login, the client is the app the user is signing in to. The resource (also called the API) is the service that holds the data the client wants to read. The client asks the resource's permission system for a key.
  • API: an interface one program uses to talk to another. When an app shows your calendar, it is not reading a database directly; it is asking a calendar API, which answers with data.
  • Scope: a named permission that says exactly what an app may do, for example read your profile or read your email. Scopes are written as strings, often looking like a URL.
  • Token: a short piece of text that proves something. After you log in, Azure AD hands the app a token instead of your password. Anyone holding the token can use it until it expires, so it works like a cloakroom ticket: show the ticket, get the coat, no questions asked.
  • Access token: the token an app shows to an API to prove it is allowed in. It is presented with every request for data.
  • Refresh token: a longer-lived token an app can swap for a new access token when the old one expires. It is what lets an app keep working after you close the browser, without asking you to log in again.
  • Consent: the screen where Azure AD lists the permissions an app wants and you click Accept. Without consent, the app should not receive tokens for those permissions.
  • Service principal: the local record, inside a tenant, that an app gets when it is used there. It is the tenant's own copy of the app, and it is what records that the app has been granted access. If no service principal exists, the tenant has no note that the app was ever allowed in.
  • Manifest: a JSON document that describes an app registration's settings. Administrators can edit it directly, which is how the two attributes below are set.
  • Attribute: one named setting inside that manifest.
  • preAuthorizedApplications: a manifest attribute that lists other apps and permissions which are pre-approved, meaning users are never asked to consent to them.
  • knownClientApplications: a manifest attribute that tells Azure AD that one app is a known companion of another, so their consent is handled together.
  • Authorisation code flow: the standard browser login dance. The browser is sent to Azure AD, the user signs in, Azure AD redirects back to the app with a short-lived code, and the app exchanges that code for tokens.
  • common tenant: a special value meaning "whichever organisation the user belongs to", rather than one fixed tenant. It is what makes a multi-tenant app work for users from any company.
  • Broken authorisation: the general name for this kind of flaw. The login works, the user is genuine, but the check on what the app is allowed to do is missing or can be sidestepped.

The timeline

  1. The issue was first submitted to MSRC in the first quarter of 2022.
  2. Microsoft addressed it proactively, and a fix was released on 17 March.

The report gives no further dates and no bounty figure.

What was in scope

The scope was the consent framework for multi-tenant apps: the part of Azure AD that decides whether a user is asked before an app receives tokens.

The result of the bypass, as described, was twofold:

  • user attributes could be read with an access token;
  • a refresh token was issued for the scopes of the application.

In everyday terms: the app got both the key to the room (the access token) and a way to cut new keys later (the refresh token), without the reception desk ever asking the visitor whether they were allowed in.

How it was found

The author came across the behaviour by accident at the end of 2021. At first it looked like a mistake in their own setup, because when they later requested additional scopes, the odd behaviour seemed to go away. That is a common trap: a problem that disappears when you change something looks like your own misconfiguration rather than a flaw in the service.

In early 2022, Kim Jämiä found the same behaviour independently and also assumed it was a known quirk that everyone lived with. The two compared notes and agreed on two points:

  • this should not be the intended behaviour, because it lets an app skip consent;
  • it leaves no service principal in the victim tenant, so the organisation has no record that the app was granted access.

That combination is what made it worth reporting to MSRC.

Why the two settings together cause the problem

The bypass is a combination of knownClientApplications and preAuthorizedApplications, used across two app registrations. Each setting is reasonable on its own. The problem appears when third-party scopes are defined using both at once.

In the initial submission, the author wrote that, judged by the documentation, the behaviour looks intentional, but produces an edge case in which multi-tenant applications can get user tokens without any consent being started.

The documentation quoted in the report for preAuthorizedApplications says:

preAuthorizedApplications do not require the user to consent to the requested permissions. Permissions listed in preAuthorizedApplications do not require user consent. However, any additional requested permissions not listed in preAuthorizedApplications require user consent

Read that carefully, because it is the heart of the case. The first two sentences say: anything on this list is granted silently. The last sentence says: anything not on the list still needs consent. The finding is that the combination of the two attributes allowed consent to be bypassed for third-party scopes defined using them.

Step 1: The login request

The researchers built a login request with these parameters:

Text
resource:"41f71e46-cf85-474b-8c6d-09e5b653592a",
scope:"https://api-26965.thx.dewi.red/hacked offline_access profile openid email",
client_id:"41f71e46-cf85-474b-8c6d-09e5b653592a",
redirect_uri,
response_mode:"query",
response_type:"code",
endpoint:2,
tenantId:"common",

Line by line:

  • resource names the API whose data the app wants. Here it is given as an application identifier, the long string with dashes. That same identifier is used as the client_id, so the app is asking for a token to itself.
  • scope lists the permissions being requested, separated by spaces. offline_access is the permission that asks for a refresh token. profile, openid and email are the basic identity permissions that tell the app who the user is. The first entry, https://api-26965.thx.dewi.red/hacked, is a custom permission on the researchers' own API.
  • client_id identifies the application making the request. It matches resource above.
  • redirect_uri is where Azure AD sends the browser back after login. The report shows the name only, not a value.
  • response_mode:"query" says the result should come back in the URL's query string, the part after the question mark.
  • response_type:"code" selects the authorisation code flow: the browser first receives a short code, which the app then trades for tokens.
  • endpoint:2 is shown as written; the report does not explain it further.
  • tenantId:"common" sends the login to the shared endpoint that serves every organisation, which is how a multi-tenant app reaches users in tenants it has never met.

Why this step matters: this is the exact request a victim's user would be sent through. If a consent screen appears, the framework is working. If tokens come back without one, it is not.

Step 2: The first app registration

The preAuthorizedApplications attribute was set like this:

JSON
"preAuthorizedApplications":[{"appId":"abcdefg2-000a-1111-a0e5-812ed8dd72e8","permissionIds":["8748f7db-21fe-4c83-8ab5-53033933c8f1"]}],

What each part does:

  • preAuthorizedApplications is the list of apps that are pre-approved.
  • appId identifies the client application that is being pre-approved.
  • permissionIds lists the specific permissions that client is allowed to use without any user being asked.

In plain words: this line tells Azure AD, "if this particular app asks for this particular permission, let it through silently." On its own that is a normal administrative convenience, used when one app you own calls another app you own.

Step 3: The second app registration

The knownClientApplications attribute was set like this:

JSON
"knownClientApplications":["41f71e46-cf85-474b-8c6d-09e5b653592a"],

What each part does:

  • knownClientApplications is a manifest attribute shown in the report.
  • The value inside the list is the identifier of that companion app, the same identifier that appeared as client_id and resource in the login request.

In plain words: this line names the client app as a known companion of the resource app.

Step 4: Getting tokens with no consent

With the two registrations configured this way, user tokens could be obtained without consent being initiated, and without a service principal in the victim tenant.

The tokens included an access token for reading user attributes and a refresh token for the application's scopes.

Nobody at the second building was ever asked, and nobody there can look at the log afterwards and see that the visit happened.

Why it works

The behaviour comes from how the two attributes are designed. preAuthorizedApplications removes the consent requirement for the permissions it lists. knownClientApplications is one of the two attributes involved. When third-party scopes are defined using both attributes across two app registrations, the consent step is skipped entirely for a multi-tenant application.

The report treats this as an edge case of documented, intentional behaviour rather than a coding mistake, because the documentation itself says permissions in preAuthorizedApplications need no user consent. The gap is that the combination lets a multi-tenant app reach user tokens with no consent started and no service principal recorded in the victim tenant.

What an attacker could get

Under these conditions, a multi-tenant application can obtain user tokens without any consent being started, and can read user attributes with an access token plus a refresh token for the application's scopes. Because no service principal is created in the victim tenant, there is no artefact there recording that the application was granted access.

The fix

Microsoft addressed the issue proactively and released a fix on 17 March.

These are the checks the report sets out, in the same order. Each one needs two app registrations you control, set up as in Steps 2 and 3.

  1. Set preAuthorizedApplications on the resource app to list the client app and its permission IDs, and set knownClientApplications on the client app to reference the resource app. Send an authorisation request with tenantId:"common" and watch for a consent prompt. A positive result is tokens returned with no prompt and no service principal in the tenant.
  2. Ask for additional scopes beyond those listed in preAuthorizedApplications in the same login request. A positive result is that the extra scopes are still granted without consent, even though the documentation quoted above says they should require it.
  3. Repeat the login with a fresh user who has never consented to the application. A positive result is an access token and refresh token issued on first contact, with no consent record created in that user's tenant.
  4. Change the resource and scope values in the request while keeping the two manifest attributes in place. A positive result is that consent is bypassed for scopes other than the ones explicitly listed, which would show the bypass is not limited to one permission set.

Glossary

  • Access token: a token an app shows to an API to prove it may read data.
  • API: an interface one program uses to ask another program for data or actions.
  • App registration: the record in a tenant describing an application and what it may ask for.
  • Attribute: a single named setting inside an app registration's manifest.
  • Authorisation code flow: the browser login sequence where a short code is exchanged for tokens.
  • Azure AD (Entra ID): Microsoft's cloud service for user accounts and sign-in.
  • Broken authorisation: a flaw where the check on what a user or app is allowed to do is missing or can be bypassed.
  • Client: the app the user is signing in to.
  • common tenant: the shared login endpoint that serves users from any organisation.
  • Consent: the screen where a user approves the permissions an app requests.
  • knownClientApplications: a manifest attribute linking a client app to a resource app so their consent is handled together.
  • Manifest: the JSON document holding an app registration's settings.
  • MSRC: Microsoft Security Response Center, the team that handles security reports about Microsoft products.
  • Multi-tenant application: an app registration designed to be used by many organisations.
  • preAuthorizedApplications: a manifest attribute listing apps and permissions that are approved in advance, with no user prompt.
  • Refresh token: a longer-lived token an app can exchange for new access tokens without the user logging in again.
  • Resource: the API that holds the data the client wants.
  • Scope: a named permission describing exactly what an app may do.
  • Service principal: the local record of an app inside a tenant, which shows the app has been granted access there.
  • Tenant: one organisation's separate instance of Azure AD.
  • Token: a piece of text that proves an identity or permission, used instead of a password.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.