mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-26 06:30:37 +00:00
241 lines
23 KiB
Markdown
241 lines
23 KiB
Markdown
# OAuth to Account takeover
|
||
|
||
<details>
|
||
|
||
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
||
|
||
Other ways to support HackTricks:
|
||
|
||
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||
* **Join the** ð¬ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ðŠ [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
||
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||
|
||
</details>
|
||
|
||
<figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure>
|
||
|
||
{% embed url="https://websec.nl/" %}
|
||
|
||
## Basic Information <a href="#d4a8" id="d4a8"></a>
|
||
|
||
OAuthã«ã¯ããŸããŸãªããŒãžã§ã³ããããåºæ¬çãªæ
å ±ã¯[OAuth 2.0 documentation](https://oauth.net/2/)ã§ç¢ºèªã§ããŸãããã®è°è«ã¯äž»ã«åºã䜿çšãããŠãã[OAuth 2.0 authorization code grant type](https://oauth.net/2/grant-types/authorization-code/)ã«çŠç¹ãåœãŠãŠããã**ã¢ããªã±ãŒã·ã§ã³ãä»ã®ã¢ããªã±ãŒã·ã§ã³ïŒèªå¯ãµãŒããŒïŒã§ãŠãŒã¶ãŒã®ã¢ã«ãŠã³ãã«ã¢ã¯ã»ã¹ãŸãã¯æäœãè¡ãããšãå¯èœã«ããèªå¯ãã¬ãŒã ã¯ãŒã¯**ãæäŸããŸãã
|
||
|
||
ä»®æ³ã®ãŠã§ããµã€ã_**https://example.com**_ãèããŠã¿ãŸãããããã®ãµã€ãã¯**ããªãã®ãã¹ãŠã®ãœãŒã·ã£ã«ã¡ãã£ã¢æçš¿ã衚瀺ãã**ããšãç®çãšããŠããŸãïŒãã©ã€ããŒããªæçš¿ãå«ãïŒããããå®çŸããããã«ãOAuth 2.0ã䜿çšãããŸãã_https://example.com_ã¯ããªãã®**ãœãŒã·ã£ã«ã¡ãã£ã¢æçš¿ã«ã¢ã¯ã»ã¹ãã**èš±å¯ãæ±ããŸãããã®çµæã_https://socialmedia.com_ã§åæç»é¢ã衚瀺ããã**èŠæ±ãããŠããæš©éãšãªã¯ãšã¹ããè¡ã£ãŠããéçºè
**ã瀺ãããŸããããªããèªå¯ãããšã_https://example.com_ã¯**ããªãã«ä»£ãã£ãŠããªãã®æçš¿ã«ã¢ã¯ã»ã¹ãã**ããšãã§ããããã«ãªããŸãã
|
||
|
||
OAuth 2.0ãã¬ãŒã ã¯ãŒã¯å
ã®ä»¥äžã®ã³ã³ããŒãã³ããç解ããããšãéèŠã§ãïŒ
|
||
|
||
* **resource owner**: ããªããã€ãŸã**ãªãœãŒã¹ã«ã¢ã¯ã»ã¹ããããšãèªå¯ãããŠãŒã¶ãŒ/ãšã³ãã£ãã£**ãäŸãã°ãããªãã®ãœãŒã·ã£ã«ã¡ãã£ã¢ã¢ã«ãŠã³ãã®æçš¿ã
|
||
* **resource server**: ã¢ããªã±ãŒã·ã§ã³ã`access token`ãååŸããåŸã«**èªèšŒããããªã¯ãšã¹ãã管çãããµãŒããŒ**ãäŸïŒ**https://socialmedia.com**ã
|
||
* **client application**: `resource owner`ããã®èªå¯ãæ±ãã**ã¢ããªã±ãŒã·ã§ã³**ãäŸïŒ**https://example.com**ã
|
||
* **authorization server**: `resource owner`ã®èªèšŒãæåããèªå¯ãåŸãããåŸã«`client application`ã«`access tokens`ãçºè¡ãã**ãµãŒããŒ**ãäŸïŒ**https://socialmedia.com**ã
|
||
* **client\_id**: ã¢ããªã±ãŒã·ã§ã³ã®å
¬éãããŠããäžæã®èå¥åã
|
||
* **client\_secret:** ã¢ããªã±ãŒã·ã§ã³ãšèªå¯ãµãŒããŒã ããç¥ã£ãŠããç§å¯éµã§ã`access_tokens`ãçæããããã«äœ¿çšãããŸãã
|
||
* **response\_type**: **èŠæ±ãããããŒã¯ã³ã®çš®é¡**ãæå®ããå€ãäŸïŒ`code`ã
|
||
* **scope**: `client application`ã`resource owner`ããèŠæ±ãã**ã¢ã¯ã»ã¹ã¬ãã«**ã
|
||
* **redirect\_uri**: èªå¯åŸã«ãŠãŒã¶ãŒããªãã€ã¬ã¯ãããã**URL**ãéåžžãäºåã«ç»é²ããããªãã€ã¬ã¯ãURLãšäžèŽããå¿
èŠããããŸãã
|
||
* **state**: **ãŠãŒã¶ãŒã®èªå¯ãµãŒããŒãžã®ãªãã€ã¬ã¯ããšæ»ãã®éã«ããŒã¿ãä¿æããããã®ãã©ã¡ãŒã¿**ããã®äžææ§ã¯**CSRFä¿è·ã¡ã«ããºã **ãšããŠæ©èœããããã«éèŠã§ãã
|
||
* **grant\_type**: **ã°ã©ã³ãã¿ã€ããšè¿ãããããŒã¯ã³ã®çš®é¡**ã瀺ããã©ã¡ãŒã¿ã
|
||
* **code**: `authorization server`ããã®èªå¯ã³ãŒãã§ã`client_id`ããã³`client_secret`ãšå
±ã«`access_token`ãååŸããããã«`client application`ã䜿çšããŸãã
|
||
* **access\_token**: `resource owner`ã«ä»£ãã£ãŠAPIãªã¯ãšã¹ããè¡ãããã«`client application`ã䜿çšãã**ããŒã¯ã³**ã
|
||
* **refresh\_token**: ã¢ããªã±ãŒã·ã§ã³ã**ãŠãŒã¶ãŒã«å床ããã³ããã衚瀺ããã«æ°ãã`access_token`ãååŸãã**ããšãå¯èœã«ããŸãã
|
||
|
||
### Flow
|
||
|
||
**å®éã®OAuthãããŒ**ã¯æ¬¡ã®ããã«é²è¡ããŸãïŒ
|
||
|
||
1. ããªãã¯[https://example.com](https://example.com)ã«ã¢ã¯ã»ã¹ããããœãŒã·ã£ã«ã¡ãã£ã¢ãšçµ±åããã¿ã³ãéžæããŸãã
|
||
2. ãµã€ãã¯æ¬¡ã«[https://socialmedia.com](https://socialmedia.com)ã«ãªã¯ãšã¹ããéããhttps://example.comã®ã¢ããªã±ãŒã·ã§ã³ãããªãã®æçš¿ã«ã¢ã¯ã»ã¹ããèš±å¯ãæ±ããŸãããªã¯ãšã¹ãã¯æ¬¡ã®ããã«æ§æãããŸãïŒ
|
||
```
|
||
https://socialmedia.com/auth
|
||
?response_type=code
|
||
&client_id=example_clientId
|
||
&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback
|
||
&scope=readPosts
|
||
&state=randomString123
|
||
```
|
||
3. 次ã«ãåæããŒãžã衚瀺ãããŸãã
|
||
4. æ¿èªåŸãSocial Mediaã¯`code`ãš`state`ãã©ã¡ãŒã¿ãå«ãã¬ã¹ãã³ã¹ã`redirect_uri`ã«éä¿¡ããŸãã
|
||
```
|
||
https://example.com?code=uniqueCode123&state=randomString123
|
||
```
|
||
5. https://example.com ã¯ããã® `code` ã `client_id` ããã³ `client_secret` ãšå
±ã«äœ¿çšããŠããµãŒããŒãµã€ããªã¯ãšã¹ããè¡ããããªãã«ä»£ãã£ãŠ `access_token` ãååŸããããªããåæããæš©éãžã®ã¢ã¯ã»ã¹ãå¯èœã«ããŸã:
|
||
```
|
||
POST /oauth/access_token
|
||
Host: socialmedia.com
|
||
...{"client_id": "example_clientId", "client_secret": "example_clientSecret", "code": "uniqueCode123", "grant_type": "authorization_code"}
|
||
```
|
||
6. æåŸã«ãhttps://example.com 㯠`access_token` ã䜿çšã㊠Social Media ã« API ã³ãŒã«ãè¡ããããã»ã¹ãå®äºããŸãã
|
||
|
||
## èåŒ±æ§ <a href="#id-323a" id="id-323a"></a>
|
||
|
||
### Open redirect\_uri <a href="#cc36" id="cc36"></a>
|
||
|
||
`redirect_uri` 㯠OAuth ããã³ OpenID å®è£
ã«ãããŠã»ãã¥ãªãã£ã®èŠã§ãããèªå¯åŸã«èªèšŒã³ãŒããªã©ã®æ©å¯ããŒã¿ãéä¿¡ãããå Žæãæ瀺ããŸãã誀ã£ãŠèšå®ããããšãæ»æè
ããããã®ãªã¯ãšã¹ããæªæã®ãããµãŒããŒã«ãªãã€ã¬ã¯ãããã¢ã«ãŠã³ãä¹ã£åããå¯èœã«ããå¯èœæ§ããããŸãã
|
||
|
||
ãšã¯ã¹ããã€ãææ³ã¯ãèªå¯ãµãŒããŒã®æ€èšŒããžãã¯ã«åºã¥ããŠç°ãªããŸããå³å¯ãªãã¹äžèŽãããæå®ããããã¡ã€ã³ãŸãã¯ãµããã£ã¬ã¯ããªå
ã®ä»»æã®URLãåãå
¥ãããã®ãŸã§æ§ã
ã§ããäžè¬çãªãšã¯ã¹ããã€ãæ¹æ³ã«ã¯ããªãŒãã³ãªãã€ã¬ã¯ãããã¹ãã©ããŒãµã«ã匱ãæ£èŠè¡šçŸã®æªçšãããŒã¯ã³çé£ã®ããã®HTMLã€ã³ãžã§ã¯ã·ã§ã³ãå«ãŸããŸãã
|
||
|
||
`redirect_uri` 以å€ã«ãã`client_uri`ã`policy_uri`ã`tos_uri`ã`initiate_login_uri` ãªã©ã®ä»ã® OAuth ããã³ OpenID ãã©ã¡ãŒã¿ããªãã€ã¬ã¯ãæ»æã«å¯ŸããŠè匱ã§ãããããã®ãã©ã¡ãŒã¿ã¯ãªãã·ã§ã³ã§ããããµãŒããŒã«ãã£ãŠãµããŒããç°ãªããŸãã
|
||
|
||
OpenID ãµãŒããŒãã¿ãŒã²ããã«ããå Žåããã£ã¹ã«ããªãŒãšã³ããã€ã³ãïŒ`**.well-known/openid-configuration**`ïŒã«ã¯ã`registration_endpoint`ã`request_uri_parameter_supported`ã`require_request_uri_registration` ãªã©ã®è²Žéãªæ§æ詳现ããªã¹ããããŠããããšããããããŸãããããã®è©³çŽ°ã¯ãç»é²ãšã³ããã€ã³ãããµãŒããŒã®ä»ã®æ§æç¹æ§ãç¹å®ããã®ã«åœ¹ç«ã¡ãŸãã
|
||
|
||
### XSS in redirect implementation <a href="#bda5" id="bda5"></a>
|
||
|
||
ãã®ãã°ããŠã³ãã£ã¬ããŒã [https://blog.dixitaditya.com/2021/11/19/account-takeover-chain.html](https://blog.dixitaditya.com/2021/11/19/account-takeover-chain.html) ã«èšèŒãããŠããããã«ããŠãŒã¶ãŒãèªèšŒããåŸã«ãµãŒããŒã®ã¬ã¹ãã³ã¹ã«ãªãã€ã¬ã¯ã **URL ãåæ ããã** å¯èœæ§ãããã**XSS ã«å¯ŸããŠè匱** ã§ããå¯èœæ§ããããŸãããã¹ãããããã®å¯èœãªãã€ããŒã:
|
||
```
|
||
https://app.victim.com/login?redirectUrl=https://app.victim.com/dashboard</script><h1>test</h1>
|
||
```
|
||
### CSRF - Improper handling of state parameter <a href="#bda5" id="bda5"></a>
|
||
|
||
OAuthå®è£
ã«ãããŠã**`state`ãã©ã¡ãŒã¿**ã®èª€çšãçç¥ã¯ã**Cross-Site Request Forgery (CSRF)**æ»æã®ãªã¹ã¯ã倧å¹
ã«å¢å ãããå¯èœæ§ããããŸãããã®è匱æ§ã¯ã`state`ãã©ã¡ãŒã¿ã**䜿çšãããªããéçãªå€ãšããŠäœ¿çšãããããŸãã¯é©åã«æ€èšŒãããªã**å Žåã«çºçããæ»æè
ãCSRFä¿è·ãåé¿ã§ããããã«ãªããŸãã
|
||
|
||
æ»æè
ã¯ãããå©çšããŠèªèšŒããã»ã¹ãååããèªåã®ã¢ã«ãŠã³ãã被害è
ã®ã¢ã«ãŠã³ãã«ãªã³ã¯ãããããšãã§ããæœåšçãª**ã¢ã«ãŠã³ãä¹ã£åã**ã«ã€ãªãããŸããããã¯ãOAuthã**èªèšŒç®ç**ã§äœ¿çšãããã¢ããªã±ãŒã·ã§ã³ã«ãããŠç¹ã«éèŠã§ãã
|
||
|
||
ãã®è匱æ§ã®å®äŸã¯ãããŸããŸãª**CTFãã£ã¬ã³ãž**ã**ãããã³ã°ãã©ãããã©ãŒã **ã§ææžåãããŠããããã®å®éã®åœ±é¿ã匷調ãããŠããŸãããã®åé¡ã¯ã**Slack**ã**Stripe**ã**PayPal**ãªã©ã®ãµãŒãããŒãã£ãµãŒãã¹ãšã®çµ±åã«ãåã³ãæ»æè
ãéç¥ãæ¯æããèªåã®ã¢ã«ãŠã³ãã«ãªãã€ã¬ã¯ãããããšãã§ããŸãã
|
||
|
||
CSRFããä¿è·ããOAuthãããŒãå®å
šã«ããããã«ã¯ã**`state`ãã©ã¡ãŒã¿**ã®é©åãªåŠçãšæ€èšŒãäžå¯æ¬ ã§ãã
|
||
|
||
### Pre Account Takeover <a href="#ebe4" id="ebe4"></a>
|
||
|
||
1. **ã¢ã«ãŠã³ãäœææã®ã¡ãŒã«ç¢ºèªãªã**: æ»æè
ã¯è¢«å®³è
ã®ã¡ãŒã«ã䜿çšããŠäºåã«ã¢ã«ãŠã³ããäœæããããšãã§ããŸãã被害è
ãåŸã§ãµãŒãããŒãã£ãµãŒãã¹ã䜿çšããŠãã°ã€ã³ãããšãã¢ããªã±ãŒã·ã§ã³ã¯èª€ã£ãŠãã®ãµãŒãããŒãã£ã¢ã«ãŠã³ããæ»æè
ã®äºåäœæã¢ã«ãŠã³ãã«ãªã³ã¯ããå¯èœæ§ããããäžæ£ã¢ã¯ã»ã¹ã«ã€ãªãããŸãã
|
||
2. **ç·©ãOAuthã¡ãŒã«ç¢ºèªã®æªçš**: æ»æè
ã¯ãã¡ãŒã«ã確èªããªãOAuthãµãŒãã¹ãæªçšããŠãèªåã®ãµãŒãã¹ã«ç»é²ãããã®åŸã¢ã«ãŠã³ãã®ã¡ãŒã«ã被害è
ã®ãã®ã«å€æŽããããšãã§ããŸãããã®æ¹æ³ã¯ãç°ãªãæ»æãã¯ãã«ãéããŠãæåã®ã·ããªãªãšåæ§ã«äžæ£ãªã¢ã«ãŠã³ãã¢ã¯ã»ã¹ã®ãªã¹ã¯ããããããŸãã
|
||
|
||
### Disclosure of Secrets <a href="#e177" id="e177"></a>
|
||
|
||
ç§å¯ã®OAuthãã©ã¡ãŒã¿ãç¹å®ãä¿è·ããããšã¯éèŠã§ãã**`client_id`**ã¯å®å
šã«å
¬éã§ããŸããã**`client_secret`**ãå
¬éããããšã¯é倧ãªãªã¹ã¯ã䌎ããŸãã`client_secret`ãæŒæŽ©ãããšãæ»æè
ã¯ã¢ããªã±ãŒã·ã§ã³ã®ã¢ã€ãã³ãã£ãã£ãšä¿¡é ŒãæªçšããŠããŠãŒã¶ãŒã®**`access_tokens`**ããã©ã€ããŒãæ
å ±ãçãããšãã§ããŸãã
|
||
|
||
äžè¬çãªè匱æ§ã¯ãã¢ããªã±ãŒã·ã§ã³ãèªèšŒ`code`ã`access_token`ã«äº€æããåŠçãã¯ã©ã€ã¢ã³ãåŽã§è¡ã誀ãããçããŸãããã®èª€ãã«ããã`client_secret`ãé²åºããæ»æè
ãã¢ããªã±ãŒã·ã§ã³ã®ãµããããŠ`access_tokens`ãçæã§ããããã«ãªããŸããããã«ããœãŒã·ã£ã«ãšã³ãžãã¢ãªã³ã°ãéããŠãæ»æè
ã¯OAuthèªèšŒã«è¿œå ã®ã¹ã³ãŒããè¿œå ããããšã§ç¹æš©ããšã¹ã«ã¬ãŒãããã¢ããªã±ãŒã·ã§ã³ã®ä¿¡é Œãããã¹ããŒã¿ã¹ãããã«æªçšããå¯èœæ§ããããŸãã
|
||
|
||
### Client Secret Bruteforce
|
||
|
||
ãµãŒãã¹ãããã€ããŒã®client\_secretãã¢ã€ãã³ãã£ãã£ãããã€ããŒãšå
±ã«**ãã«ãŒããã©ãŒã¹**ããããšãã§ããŸãã\
|
||
BFãªã¯ãšã¹ãã¯æ¬¡ã®ããã«èŠãããããããŸãã:
|
||
```
|
||
POST /token HTTP/1.1
|
||
content-type: application/x-www-form-urlencoded
|
||
host: 10.10.10.10:3000
|
||
content-length: 135
|
||
Connection: close
|
||
|
||
code=77515&redirect_uri=http%3A%2F%2F10.10.10.10%3A3000%2Fcallback&grant_type=authorization_code&client_id=public_client_id&client_secret=[bruteforce]
|
||
```
|
||
### Referer Header leaking Code + State
|
||
|
||
ã¯ã©ã€ã¢ã³ãã**codeãšstateãæã£ãŠããå Žå**ãããã**RefererããããŒå
ã«åæ ãããŠãããšãã«å¥ã®ããŒãžã«ç§»åãããšè匱**ã§ãã
|
||
|
||
### Access Token Stored in Browser History
|
||
|
||
**ãã©ãŠã¶å±¥æŽã«ã¢ã¯ã»ã¹ããŠãã¢ã¯ã»ã¹ããŒã¯ã³ãä¿åãããŠãããã©ããã確èª**ããŸãã
|
||
|
||
### Everlasting Authorization Code
|
||
|
||
**èªå¯ã³ãŒãã¯ãæ»æè
ããããçãã§äœ¿çšã§ããæéæ ãå¶éããããã«ãäžå®æéã ãæå¹ã§ããã¹ãã§ã**ã
|
||
|
||
### Authorization/Refresh Token not bound to client
|
||
|
||
**èªå¯ã³ãŒããååŸããŠå¥ã®ã¯ã©ã€ã¢ã³ãã§äœ¿çšã§ããå Žåãä»ã®ã¢ã«ãŠã³ããä¹ã£åãããšãã§ããŸã**ã
|
||
|
||
### Happy Paths, XSS, Iframes & Post Messages to leak code & state values
|
||
|
||
[**ãã®æçš¿ããã§ãã¯**](https://labs.detectify.com/writeups/account-hijacking-using-dirty-dancing-in-sign-in-oauth-flows/#gadget-2-xss-on-sandbox-third-party-domain-that-gets-the-url)
|
||
|
||
### AWS Cognito <a href="#bda5" id="bda5"></a>
|
||
|
||
ãã®ãã°ããŠã³ãã£ã¬ããŒãã§ã¯: [**https://security.lauritz-holtmann.de/advisories/flickr-account-takeover/**](https://security.lauritz-holtmann.de/advisories/flickr-account-takeover/) **AWS Cognito**ããŠãŒã¶ãŒã«è¿ã**ããŒã¯ã³**ã**ãŠãŒã¶ãŒããŒã¿ãäžæžãããã®ã«ååãªæš©éãæã£ãŠããå¯èœæ§ããã**ããšãããããŸãããããã£ãŠã**ãŠãŒã¶ãŒã®ã¡ãŒã«ã¢ãã¬ã¹ãå¥ã®ã¡ãŒã«ã¢ãã¬ã¹ã«å€æŽã§ããå Žå**ãä»ã®ã¢ã«ãŠã³ãã**ä¹ã£åã**ããšãã§ãããããããŸããã
|
||
```bash
|
||
# Read info of the user
|
||
aws cognito-idp get-user --region us-east-1 --access-token eyJraWQiOiJPVj[...]
|
||
|
||
# Change email address
|
||
aws cognito-idp update-user-attributes --region us-east-1 --access-token eyJraWQ[...] --user-attributes Name=email,Value=imaginary@flickr.com
|
||
{
|
||
"CodeDeliveryDetailsList": [
|
||
{
|
||
"Destination": "i***@f***.com",
|
||
"DeliveryMedium": "EMAIL",
|
||
"AttributeName": "email"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
詳现ãªAWS Cognitoã®æªçšæ¹æ³ã«ã€ããŠã¯ã以äžãåç
§ããŠãã ããïŒ
|
||
|
||
{% embed url="https://cloud.hacktricks.xyz/pentesting-cloud/aws-pentesting/aws-unauthenticated-enum-access/aws-cognito-unauthenticated-enum" %}
|
||
|
||
### ä»ã®ã¢ããªã®ããŒã¯ã³ã®æªçš <a href="#bda5" id="bda5"></a>
|
||
|
||
[**ãã®æžã蟌ã¿**](https://salt.security/blog/oh-auth-abusing-oauth-to-take-over-millions-of-accounts)ã§è¿°ã¹ãããŠããããã«ã**ããŒã¯ã³**ïŒã³ãŒãã§ã¯ãªãïŒãåãåãããšãæåŸ
ããOAuthãããŒã¯ãããŒã¯ã³ãã¢ããªã«å±ããŠãããã©ããã確èªããªãå Žåãè匱ã§ããå¯èœæ§ããããŸãã
|
||
|
||
ããã¯ã**æ»æè
**ã**OAuthããµããŒãããã¢ããªã±ãŒã·ã§ã³ãäœæããFacebookã§ãã°ã€ã³**ïŒäŸãã°ïŒããããšãã§ããããã§ãããã®åŸã被害è
ã**æ»æè
ã®ã¢ããªã±ãŒã·ã§ã³**ã§Facebookã«ãã°ã€ã³ãããšãæ»æè
ã¯**被害è
ã®ãŠãŒã¶ãŒã«äžããããOAuthããŒã¯ã³ãååŸãããã®ããŒã¯ã³ã䜿çšããŠè¢«å®³è
ã®OAuthã¢ããªã±ãŒã·ã§ã³ã«ãã°ã€ã³**ããããšãã§ããŸãã
|
||
|
||
{% hint style="danger" %}
|
||
ãããã£ãŠãæ»æè
ããŠãŒã¶ãŒã«èªåã®OAuthã¢ããªã±ãŒã·ã§ã³ã«ã¢ã¯ã»ã¹ãããããšãã§ããã°ãããŒã¯ã³ãæåŸ
ãããã®ããŒã¯ã³ãèªåã®ã¢ããªIDã«ä»äžããããã©ããã確èªããªãã¢ããªã±ãŒã·ã§ã³ã§è¢«å®³è
ã®ã¢ã«ãŠã³ããä¹ã£åãããšãã§ããŸãã
|
||
{% endhint %}
|
||
|
||
### äºã€ã®ãªã³ã¯ãšã¯ãã㌠<a href="#bda5" id="bda5"></a>
|
||
|
||
[**ãã®æžã蟌ã¿**](https://medium.com/@metnew/why-electron-apps-cant-store-your-secrets-confidentially-inspect-option-a49950d6d51f)ã«ãããšã被害è
ã«**returnUrl**ãæ»æè
ã®ãã¹ããæãããŒãžãéãããããšãå¯èœã§ããããã®æ
å ±ã¯**ã¯ãããŒïŒRUïŒã«ä¿å**ããã**åŸã®ã¹ããã**ã§**ããã³ãã**ã**ãŠãŒã¶ãŒ**ã«ãã®æ»æè
ã®ãã¹ãã«ã¢ã¯ã»ã¹ãèš±å¯ãããã©ãããå°ããŸãã
|
||
|
||
ãã®ããã³ãããåé¿ããããã«ã**OauthãããŒ**ãéå§ããã¿ããéãããã®RUã¯ãããŒã**returnUrl**ã䜿çšããŠèšå®ããããã³ããã衚瀺ãããåã«ã¿ããéãããã®å€ãªãã§æ°ããã¿ããéãããšãå¯èœã§ããããããšã**ããã³ããã¯æ»æè
ã®ãã¹ãã«ã€ããŠéç¥ããŸãã**ããã¯ãããŒã¯ããã«èšå®ãããããã**ããŒã¯ã³ã¯ãªãã€ã¬ã¯ã·ã§ã³ã§æ»æè
ã®ãã¹ãã«éä¿¡ãããŸã**ã
|
||
|
||
### ããã³ããã€ã³ã¿ã©ã¯ã·ã§ã³ã®åé¿ <a href="#bda5" id="bda5"></a>
|
||
|
||
[**ãã®ãããª**](https://www.youtube.com/watch?v=n9x7\_J\_a\_7Q)ã§èª¬æãããŠããããã«ãäžéšã®OAuthå®è£
ã§ã¯ã**`prompt`** GETãã©ã¡ãŒã¿ãNoneïŒ**`&prompt=none`**ïŒãšããŠæå®ããããšã§ã**ãŠãŒã¶ãŒããã©ãããã©ãŒã ã«æ¢ã«ãã°ã€ã³ããŠããå Žåã«ããã³ããã§ã¢ã¯ã»ã¹ã®ç¢ºèªãæ±ããããªãããã«ãã**ããšãã§ããŸãã
|
||
|
||
### response\_mode
|
||
|
||
[**ãã®ãããª**](https://www.youtube.com/watch?v=n9x7\_J\_a\_7Q)ã§èª¬æãããŠããããã«ãæçµURLã§ã³ãŒããæäŸããå Žæã瀺ãããã«**`response_mode`**ãã©ã¡ãŒã¿ãæå®ããããšãå¯èœã§ãïŒ
|
||
|
||
* `response_mode=query` -> ã³ãŒãã¯GETãã©ã¡ãŒã¿å
ã«æäŸãããŸãïŒ`?code=2397rf3gu93f`
|
||
* `response_mode=fragment` -> ã³ãŒãã¯URLãã©ã°ã¡ã³ããã©ã¡ãŒã¿å
ã«æäŸãããŸãïŒ`#code=2397rf3gu93f`
|
||
* `response_mode=form_post` -> ã³ãŒãã¯`code`ãšããååã®å
¥åãšå€ãæã€POSTãã©ãŒã å
ã«æäŸãããŸã
|
||
* `response_mode=web_message` -> ã³ãŒãã¯ãã¹ãã¡ãã»ãŒãžã§éä¿¡ãããŸãïŒ`window.opener.postMessage({"code": "asdasdasd...`
|
||
|
||
### SSRFsãã©ã¡ãŒã¿ <a href="#bda5" id="bda5"></a>
|
||
|
||
[**ãã®ç 究ããã§ãã¯**](https://portswigger.net/research/hidden-oauth-attack-vectors) **ãã®æè¡ã®è©³çŽ°ã«ã€ããŠã**
|
||
|
||
OAuthã®åçã¯ã©ã€ã¢ã³ãç»é²ã¯ã**Server-Side Request Forgery (SSRF)**æ»æã®ããã®éèŠãªãã¯ã¿ãŒãšããŠæ©èœããŸãããã®ãšã³ããã€ã³ãã¯ãã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã«é¢ãã詳现ãåãåããããæªçšãããå¯èœæ§ã®ããæ©å¯URLãå«ãããšããããŸãã
|
||
|
||
**éèŠãªãã€ã³ãïŒ**
|
||
|
||
* **åçã¯ã©ã€ã¢ã³ãç»é²**ã¯éåžž`/register`ã«ãããã³ã°ããã`client_name`ã`client_secret`ã`redirect_uris`ãããã³ããŽãJSON Web Key Sets (JWKs)ã®URLãªã©ã®è©³çŽ°ãPOSTãªã¯ãšã¹ãã§åãå
¥ããŸãã
|
||
* ãã®æ©èœã¯**RFC7591**ããã³**OpenID Connect Registration 1.0**ã®ä»æ§ã«åŸã£ãŠãããSSRFã«å¯ŸããŠæœåšçã«è匱ãªãã©ã¡ãŒã¿ãå«ã¿ãŸãã
|
||
* ç»é²ããã»ã¹ã¯ã以äžã®æ¹æ³ã§ãµãŒããŒãSSRFã«ãããå¯èœæ§ããããŸãïŒ
|
||
* **`logo_uri`**ïŒã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã®ããŽã®URLã§ããµãŒããŒããã§ããããå¯èœæ§ããããSSRFãåŒãèµ·ããããURLã誀ã£ãŠåŠçããããšXSSãåŒãèµ·ããå¯èœæ§ããããŸãã
|
||
* **`jwks_uri`**ïŒã¯ã©ã€ã¢ã³ãã®JWKããã¥ã¡ã³ããžã®URLã§ãæªæã®ãã圢ã§äœæãããå ŽåããµãŒããŒãæ»æè
ãå¶åŸ¡ãããµãŒããŒã«ã¢ãŠãããŠã³ããªã¯ãšã¹ããè¡ãåå ãšãªããŸãã
|
||
* **`sector_identifier_uri`**ïŒ`redirect_uris`ã®JSONé
åãåç
§ãããµãŒããŒããã§ããããå¯èœæ§ããããSSRFã®æ©äŒãäœãåºããŸãã
|
||
* **`request_uris`**ïŒã¯ã©ã€ã¢ã³ãã®èš±å¯ããããªã¯ãšã¹ãURIããªã¹ããããµãŒããŒãèªèšŒããã»ã¹ã®éå§æã«ãããã®URIããã§ããããå Žåãæªçšãããå¯èœæ§ããããŸãã
|
||
|
||
**æªçšæŠç¥ïŒ**
|
||
|
||
* `logo_uri`ã`jwks_uri`ããŸãã¯`sector_identifier_uri`ã®ãããªãã©ã¡ãŒã¿ã«æªæã®ããURLãå«ãæ°ããã¯ã©ã€ã¢ã³ããç»é²ããããšã§ãSSRFãåŒãèµ·ããããšãã§ããŸãã
|
||
* `request_uris`ãä»ããçŽæ¥ã®æªçšã¯ãã¯ã€ããªã¹ãå¶åŸ¡ã«ãã£ãŠè»œæžãããå¯èœæ§ããããŸãããäºåã«ç»é²ãããæ»æè
ãå¶åŸ¡ãã`request_uri`ãæäŸããããšã§ãèªèšŒãã§ãŒãºäžã«SSRFãä¿é²ããããšãã§ããŸãã
|
||
|
||
## OAuthãããã€ããŒã®ã¬ãŒã¹ã³ã³ãã£ã·ã§ã³
|
||
|
||
ãã¹ãããŠãããã©ãããã©ãŒã ãOAuthãããã€ããŒã§ããå Žåã[**ãããèªãã§ã¬ãŒã¹ã³ã³ãã£ã·ã§ã³ã®ãã¹ããè¡ã£ãŠãã ãã**](race-condition.md)ã
|
||
|
||
## åèæç®
|
||
|
||
* [**https://medium.com/a-bugz-life/the-wondeful-world-of-oauth-bug-bounty-edition-af3073b354c1**](https://medium.com/a-bugz-life/the-wondeful-world-of-oauth-bug-bounty-edition-af3073b354c1)
|
||
* [**https://portswigger.net/research/hidden-oauth-attack-vectors**](https://portswigger.net/research/hidden-oauth-attack-vectors)
|
||
|
||
<figure><img src="https://pentest.eu/RENDER_WebSec_10fps_21sec_9MB_29042024.gif" alt=""><figcaption></figcaption></figure>
|
||
|
||
{% embed url="https://websec.nl/" %}
|
||
|
||
<details>
|
||
|
||
<summary><strong>ãŒãããããŒããŒãŸã§ã®AWSãããã³ã°ãåŠã¶</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
||
|
||
HackTricksããµããŒãããä»ã®æ¹æ³ïŒ
|
||
|
||
* **HackTricksã§äŒç€Ÿã®åºåã衚瀺**ãããã**HackTricksãPDFã§ããŠã³ããŒã**ãããå Žåã¯ã[**ãµãã¹ã¯ãªãã·ã§ã³ãã©ã³**](https://github.com/sponsors/carlospolop)ããã§ãã¯ããŠãã ããïŒ
|
||
* [**å
¬åŒPEASS & HackTricksã°ããº**](https://peass.creator-spring.com)ãæã«å
¥ããŸããã
|
||
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family)ãçºèŠããç§ãã¡ã®ç¬å çãª[**NFTs**](https://opensea.io/collection/the-peass-family)ã³ã¬ã¯ã·ã§ã³ããã§ãã¯ããŠãã ãã
|
||
* ð¬ [**Discordã°ã«ãŒã**](https://discord.gg/hRep4RUj7f)ãŸãã¯[**Telegramã°ã«ãŒã**](https://t.me/peass)ã«åå ãããã**Twitter** ðŠ [**@carlospolopm**](https://twitter.com/hacktricks\_live)ããã©ããŒããŠãã ããã
|
||
* **ãããã³ã°ã®ããªãã¯ãå
±æããã«ã¯ã** [**HackTricks**](https://github.com/carlospolop/hacktricks)ããã³[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud)ã®GitHubãªããžããªã«PRãæåºããŠãã ããã
|
||
|
||
</details>
|