Skip to content

Commit 0611060

Browse files
authored
Merge pull request #269 from HackTricks-wiki/update_Full_Disclosure__A_Third__and_Fourth__Azure_Sign-I_20260319_185745
Full Disclosure A Third (and Fourth) Azure Sign-In Log Bypas...
2 parents 0172f07 + 34568ac commit 0611060

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

src/pentesting-cloud/azure-security/az-basic-information/az-tokens-and-public-applications.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,83 @@ Entra ID is Microsoft's cloud-based identity and access management (IAM) platfor
3838
- Cannot securely authenticate to the authorization server.
3939
- **Security Implication:** An attacker can impersonate a public client application when requesting tokens, as there is no mechanism for the authorization server to verify the legitimacy of the application.
4040

41+
### ROPC / Password Grant
42+
43+
The OAuth2 **Resource Owner Password Credentials** (**ROPC**) flow uses a direct `POST` to `https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token` with `grant_type=password`, a **username**, **password**, a **client_id**, and the requested **scope**. In Entra ID this is mainly interesting for **public clients** because the attacker can reuse Microsoft first-party client IDs or any other allowed public client without needing a secret.
44+
45+
```bash
46+
curl -X POST "https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token" \
47+
-H "Content-Type: application/x-www-form-urlencoded" \
48+
--data-urlencode "client_id=f05ff7c9-f75a-4acd-a3b5-f4b6a870245d" \
49+
--data-urlencode "client_info=1" \
50+
--data-urlencode "grant_type=password" \
51+
--data-urlencode "username=user@corp.com" \
52+
--data-urlencode "password=Password123!" \
53+
--data-urlencode "scope=https://graph.microsoft.com/.default"
54+
```
55+
56+
If the credentials are valid and the flow is allowed, Entra can return **access tokens** and sometimes **refresh tokens** that are immediately usable against Microsoft Graph or the target resource.
57+
58+
### Entra ID Sign-In Log Bypass Classes
59+
60+
Some historical Entra ID bugs allowed **password validation** or even **full token issuance** without generating the expected **Entra ID sign-in log** entry. These cases were fixed, but the techniques are still useful to understand how auth pipelines can fail in ways that leave **downstream token use visible** while the **upstream sign-in telemetry is absent**.
61+
62+
#### 1. Foreign-tenant endpoint for stealth password validation
63+
64+
If the request is sent to the token endpoint of a **different tenant GUID**, Entra may still validate whether the submitted password is correct for the supplied username before the flow fails because the user does not exist in that foreign tenant. Historically this allowed:
65+
66+
- **Password spraying / credential validation** without a corresponding sign-in log in the victim tenant
67+
- A response difference that reveals whether the password step succeeded
68+
- No token issuance, but less telemetry than a normal failed logon
69+
70+
#### 2. Force a post-password failure
71+
72+
If a parameter used **after** credential validation is invalid, such as an invalid `client_id`, the overall transaction may fail even though the password was already correct. Historically this produced a **failed** login view while hiding that the password guess succeeded.
73+
74+
The pattern to remember is:
75+
76+
- **Password check succeeds**
77+
- A later validation step fails
78+
- The log represents the final transaction state but not the successful password-validation step
79+
80+
#### 3. Trigger logging failure with oversized-but-valid values
81+
82+
The most dangerous class is when the request remains syntactically valid, authentication succeeds, **tokens are returned**, but some **logged field** is large enough to break the logging pipeline. Reported examples included:
83+
84+
- Repeating valid scopes thousands of times, such as `openid openid openid ...`
85+
- Supplying an excessively long but still accepted **User-Agent** header
86+
87+
This suggests a general class of issues where:
88+
89+
1. Entra validates credentials and request syntax
90+
2. The token is issued successfully
91+
3. Logging attempts to persist a raw user-controlled field
92+
4. The logging write fails because of length or schema assumptions
93+
5. The user obtains a valid token with no corresponding sign-in record
94+
95+
Example of the repeated-scope pattern:
96+
97+
```bash
98+
curl -X POST "https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token" \
99+
-H "Content-Type: application/x-www-form-urlencoded" \
100+
--data-urlencode "client_id=f05ff7c9-f75a-4acd-a3b5-f4b6a870245d" \
101+
--data-urlencode "client_info=1" \
102+
--data-urlencode "grant_type=password" \
103+
--data-urlencode "username=user@corp.com" \
104+
--data-urlencode "password=Password123!" \
105+
--data-urlencode "scope=$(for num in {1..10000}; do echo -n 'openid '; done)"
106+
```
107+
108+
#### Hunting / defensive note
109+
110+
Do not assume that every valid token use will have a matching Entra sign-in event. When investigating suspicious Graph activity, correlate:
111+
112+
- **Non-interactive sign-in logs**
113+
- **Graph Activity Logs**
114+
- **IP address**, **user/object ID**, **session/correlation identifiers**, and **time windows**
115+
116+
One practical validation method is to bracket a suspected invisible success between two normal failed logons and then verify whether the expected sequence `Failed -> Successful -> Failed` is missing the middle event after ingestion delay. If downstream Graph activity exists but the sign-in log does not, treat it as a potential **sign-in logging gap** or **token replay** condition.
117+
41118
## Authentication Tokens
42119

43120
There are **three types of tokens** used in OIDC:
@@ -566,5 +643,6 @@ From an attackers perspective it's very interesting to know where is it possible
566643
- [https://github.com/Huachao/azure-content/blob/master/articles/active-directory/active-directory-token-and-claims.md](https://github.com/Huachao/azure-content/blob/master/articles/active-directory/active-directory-token-and-claims.md)
567644
- [https://specterops.io/blog/2025/10/15/naa-or-broci-let-me-explain/](https://specterops.io/blog/2025/10/15/naa-or-broci-let-me-explain/)
568645
- [https://specterops.io/blog/2025/08/13/going-for-brokering-offensive-walkthrough-for-nested-app-authentication/](https://specterops.io/blog/2025/08/13/going-for-brokering-offensive-walkthrough-for-nested-app-authentication/)
646+
- [https://trustedsec.com/blog/full-disclosure-a-third-and-fourth-azure-sign-in-log-bypass-found](https://trustedsec.com/blog/full-disclosure-a-third-and-fourth-azure-sign-in-log-bypass-found)
569647

570648
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)