trufflesecurity / trufflehog

Find, verify, and analyze leaked credentials
https://trufflesecurity.com
GNU Affero General Public License v3.0
15.83k stars 1.65k forks source link

Create detector for Azure refresh tokens #2978

Open rgmz opened 3 months ago

rgmz commented 3 months ago

Description:

Azure refresh tokens are long-lived opaque tokens returned alongside access tokens^1. They can remain valid for an indefinite period, and can be used to generate a new valid access token on behalf of the subject.

This detector can be tested by obtaining a live refresh token. I like using ROADtools:

# Obtain a token for Microsoft Office
# https://learn.microsoft.com/en-us/troubleshoot/azure/entra/entra-id/governance/verify-first-party-apps-sign-in
$ roadrecon auth --device-code -c d3590ed6-52b3-4102-aeff-aad2292ab01c -r msgraph
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ABCDEFG123 to authenticate. 
Tokens were written to .roadtools_auth

This detector only works with refresh tokens created for public clients. If a client is confidential, the required tenant, id, and secret should trigger the service principal detector.

Checklist: