23 KiB
OAuth to Account takeover
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the ð¬ Discord group or the telegram group or follow us on Twitter ðŠ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
{% embed url="https://websec.nl/" %}
Basic Information
OAuthã¯ããŸããŸãªããŒãžã§ã³ãæäŸããŠãããåºæ¬çãªæ å ±ã¯OAuth 2.0 documentationã§å ¥æã§ããŸãããã®è°è«ã¯äž»ã«åºã䜿çšãããŠããOAuth 2.0 authorization code grant typeã«çŠç¹ãåœãŠãŠãããã¢ããªã±ãŒã·ã§ã³ãä»ã®ã¢ããªã±ãŒã·ã§ã³ã®ãŠãŒã¶ãŒã¢ã«ãŠã³ãã«ã¢ã¯ã»ã¹ãŸãã¯æäœãè¡ãããšãå¯èœã«ããèªå¯ãã¬ãŒã ã¯ãŒã¯ãæäŸããŸãïŒèªå¯ãµãŒããŒïŒã
ä»®æ³ã®ãŠã§ããµã€ã_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: ãªãœãŒã¹ãªãŒããŒããã®èªå¯ãæ±ããã¢ããªã±ãŒã·ã§ã³ãäŸïŒhttps://example.comã
- authorization server: ãªãœãŒã¹ãªãŒããŒã®èªèšŒãæåããèªå¯ãååŸãããåŸã«
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 application
ãaccess_token
ãååŸããããã«client_id
ãšclient_secret
ãšå ±ã«äœ¿çšããŸãã - access_token: ãªãœãŒã¹ãªãŒããŒã®ä»£ããã«APIãªã¯ãšã¹ãã«äœ¿çšãããããŒã¯ã³ã
- refresh_token: ã¢ããªã±ãŒã·ã§ã³ããŠãŒã¶ãŒã«å床ããã³ããã衚瀺ããããšãªãæ°ãã
access_token
ãååŸããããšãå¯èœã«ããŸãã
Flow
å®éã®OAuthãããŒã¯æ¬¡ã®ããã«é²è¡ããŸãïŒ
- ããªãã¯https://example.comã«ç§»åããããœãŒã·ã£ã«ã¡ãã£ã¢ãšçµ±åããã¿ã³ãéžæããŸãã
- ãµã€ãã¯æ¬¡ã«ãããªãã®æçš¿ã«ã¢ã¯ã»ã¹ããããã«https://example.comã®ã¢ããªã±ãŒã·ã§ã³ã«èš±å¯ãæ±ãããªã¯ãšã¹ããhttps://socialmedia.comã«éä¿¡ããŸãããªã¯ãšã¹ãã¯æ¬¡ã®ããã«æ§æãããŸãïŒ
https://socialmedia.com/auth
?response_type=code
&client_id=example_clientId
&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback
&scope=readPosts
&state=randomString123
- 次ã«ãåæããŒãžã衚瀺ãããŸãã
- ããªãã®æ¿èªã«ç¶ããŠããœãŒã·ã£ã«ã¡ãã£ã¢ã¯
redirect_uri
ã«code
ãšstate
ãã©ã¡ãŒã¿ãå«ãã¬ã¹ãã³ã¹ãéä¿¡ããŸãïŒ
https://example.com?code=uniqueCode123&state=randomString123
- 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"}
- æåŸã«ãããã»ã¹ã¯ https://example.com ãããªãã®
access_token
ã䜿çšããŠãœãŒã·ã£ã«ã¡ãã£ã¢ã«APIã³ãŒã«ãè¡ããã¢ã¯ã»ã¹ããããšã§çµäºããŸãã
è匱æ§
ãªãŒãã³ãªãã€ã¬ã¯ã_uri
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
ãã®ãã°ããŠã³ãã£ã¬ããŒã 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 - äžé©åãªç¶æ ãã©ã¡ãŒã¿ã®åãæ±ã
OAuthã®å®è£
ã«ãããŠãstate
ãã©ã¡ãŒã¿ã®èª€çšãŸãã¯çç¥ã¯ãã¯ãã¹ãµã€ããªã¯ãšã¹ããã©ãŒãžã§ãªïŒCSRFïŒæ»æã®ãªã¹ã¯ã倧å¹
ã«é«ããå¯èœæ§ããããŸãããã®è匱æ§ã¯ãstate
ãã©ã¡ãŒã¿ã䜿çšãããŠããªããéçãªå€ãšããŠäœ¿çšãããŠããããŸãã¯é©åã«æ€èšŒãããŠããªãå Žåã«çºçããæ»æè
ãCSRFä¿è·ãåé¿ã§ããããã«ãªããŸãã
æ»æè ã¯ãèªèšŒããã»ã¹ãååããŠèªåã®ã¢ã«ãŠã³ãã被害è ã®ã¢ã«ãŠã³ãã«ãªã³ã¯ãããããšã§ããã®è匱æ§ãæªçšããæœåšçãªã¢ã«ãŠã³ãä¹ã£åããåŒãèµ·ããããšãã§ããŸããããã¯ãOAuthãèªèšŒç®çã§äœ¿çšãããã¢ããªã±ãŒã·ã§ã³ã«ãããŠç¹ã«éèŠã§ãã
ãã®è匱æ§ã®å®äŸã¯ãããŸããŸãªCTFãã£ã¬ã³ãžããããã³ã°ãã©ãããã©ãŒã ã§ææžåãããŠããããã®å®éã®åœ±é¿ã匷調ããŠããŸãããã®åé¡ã¯ãSlackãStripeãPayPalãªã©ã®ãµãŒãããŒãã£ãµãŒãã¹ãšã®çµ±åã«ãåã³ãæ»æè ãéç¥ãæ¯æããèªåã®ã¢ã«ãŠã³ãã«ãªãã€ã¬ã¯ãã§ããå¯èœæ§ããããŸãã
state
ãã©ã¡ãŒã¿ã®é©åãªåãæ±ããšæ€èšŒã¯ãCSRFããã®ä¿è·ãšOAuthãããŒã®ã»ãã¥ãªãã£ã確ä¿ããããã«éèŠã§ãã
ã¢ã«ãŠã³ãä¹ã£åãå
- ã¢ã«ãŠã³ãäœææã®ã¡ãŒã«ç¢ºèªãªã: æ»æè ã¯è¢«å®³è ã®ã¡ãŒã«ã䜿çšããŠäºåã«ã¢ã«ãŠã³ããäœæã§ããŸãã被害è ãåŸã«ãµãŒãããŒãã£ãµãŒãã¹ã䜿çšããŠãã°ã€ã³ãããšãã¢ããªã±ãŒã·ã§ã³ããã®ãµãŒãããŒãã£ã¢ã«ãŠã³ããæ»æè ã®äºåäœæã¢ã«ãŠã³ãã«èª€ã£ãŠãªã³ã¯ãããç¡èš±å¯ã®ã¢ã¯ã»ã¹ãåŒãèµ·ããå¯èœæ§ããããŸãã
- ç·©ãOAuthã¡ãŒã«ç¢ºèªã®æªçš: æ»æè ã¯ãã¡ãŒã«ã確èªããªãOAuthãµãŒãã¹ãæªçšããèªåã®ãµãŒãã¹ã«ç»é²ããåŸãã¢ã«ãŠã³ãã®ã¡ãŒã«ã被害è ã®ãã®ã«å€æŽããããšãã§ããŸãããã®æ¹æ³ããæåã®ã·ããªãªãšåæ§ã«ç¡èš±å¯ã®ã¢ã«ãŠã³ãã¢ã¯ã»ã¹ã®ãªã¹ã¯ã䌎ããŸãããç°ãªãæ»æãã¯ã¿ãŒãéããŠè¡ãããŸãã
ç§å¯ã®é瀺
ç§å¯ã®OAuthãã©ã¡ãŒã¿ãç¹å®ãä¿è·ããããšã¯éèŠã§ããclient_id
ã¯å®å
šã«é瀺ã§ããŸãããclient_secret
ãæããã«ããããšã¯é倧ãªãªã¹ã¯ã䌎ããŸããclient_secret
ãæŒæŽ©ãããšãæ»æè
ã¯ã¢ããªã±ãŒã·ã§ã³ã®ã¢ã€ãã³ãã£ãã£ãšä¿¡é ŒãæªçšããŠãŠãŒã¶ãŒã®access_tokens
ããã©ã€ããŒãæ
å ±ãçãããšãã§ããŸãã
äžè¬çãªè匱æ§ã¯ãã¢ããªã±ãŒã·ã§ã³ãèªèšŒcode
ãaccess_token
ã«äº€æããéã«ãã¯ã©ã€ã¢ã³ãåŽã§ã¯ãªããµãŒããŒåŽã§èª€ã£ãŠåŠçããå Žåã«çºçããŸãããã®ãã¹ã¯client_secret
ã®é²åºãåŒãèµ·ãããæ»æè
ãã¢ããªã±ãŒã·ã§ã³ã®å矩ã§access_tokens
ãçæã§ããããã«ããŸããããã«ããœãŒã·ã£ã«ãšã³ãžãã¢ãªã³ã°ãéããŠãæ»æè
ã¯OAuthèªèšŒã«è¿œå ã®ã¹ã³ãŒããè¿œå ããããšã§æš©éããšã¹ã«ã¬ãŒãããã¢ããªã±ãŒã·ã§ã³ã®ä¿¡é Œãããå°äœãããã«æªçšããããšãã§ããŸãã
ã¯ã©ã€ã¢ã³ãã·ãŒã¯ã¬ãããã«ãŒããã©ãŒã¹
ãµãŒãã¹ãããã€ããŒã®ã¢ã€ãã³ãã£ãã£ãããã€ããŒã«å¯ŸããŠã¯ã©ã€ã¢ã³ãã·ãŒã¯ã¬ããããã«ãŒããã©ãŒã¹ããã¢ã«ãŠã³ããçãè©Šã¿ãè¡ãããšãã§ããŸãã
ãã«ãŒããã©ãŒã¹ã®ãªã¯ãšã¹ãã¯æ¬¡ã®ããã«ãªãå¯èœæ§ããããŸã:
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
ãã®æçš¿ã確èªããŠãã ãã
AWS Cognito
ãã®ãã°ããŠã³ãã£ã¬ããŒãã§ã¯: https://security.lauritz-holtmann.de/advisories/flickr-account-takeover/ AWS CognitoããŠãŒã¶ãŒã«è¿ãããŒã¯ã³ã¯ããŠãŒã¶ãŒããŒã¿ãäžæžãããã®ã«ååãªæš©éãæã£ãŠããå¯èœæ§ããããŸãããããã£ãŠãç°ãªããŠãŒã¶ãŒã®ã¡ãŒã«ã¢ãã¬ã¹ã«ãŠãŒã¶ãŒã®ã¡ãŒã«ã¢ãã¬ã¹ãå€æŽã§ããå Žåãä»ã®ã¢ã«ãŠã³ããä¹ã£åãããšãã§ãããããããŸããã
# 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"
}
]
}
For more detailed info about how to abuse AWS cognito check:
{% embed url="https://cloud.hacktricks.xyz/pentesting-cloud/aws-pentesting/aws-unauthenticated-enum-access/aws-cognito-unauthenticated-enum" %}
Abusing other Apps tokens
ãã®æžã蟌ã¿ã§è¿°ã¹ãããŠããããã«ãããŒã¯ã³ïŒã³ãŒãã§ã¯ãªãïŒãåãåãããšãæåŸ ããOAuthãããŒã¯ãããŒã¯ã³ãã¢ããªã«å±ããŠãããã©ããã確èªããªãå Žåãè匱ã§ããå¯èœæ§ããããŸãã
ããã¯ãæ»æè ãèªåã®ã¢ããªã±ãŒã·ã§ã³ã§OAuthããµããŒãããFacebookã§ãã°ã€ã³ããã¢ããªã±ãŒã·ã§ã³ãäœæã§ããããã§ãã次ã«ã被害è ãæ»æè ã®ã¢ããªã±ãŒã·ã§ã³ã§Facebookã«ãã°ã€ã³ãããšãæ»æè ã¯ãã®ã¢ããªã±ãŒã·ã§ã³ã«äžãããããŠãŒã¶ãŒã®OAuthããŒã¯ã³ãååŸãã被害è ã®ãŠãŒã¶ãŒããŒã¯ã³ã䜿çšããŠè¢«å®³è ã®OAuthã¢ããªã±ãŒã·ã§ã³ã«ãã°ã€ã³ããããšãã§ããŸãã
{% hint style="danger" %} ãããã£ãŠãæ»æè ããŠãŒã¶ãŒã«èªåã®OAuthã¢ããªã±ãŒã·ã§ã³ã«ã¢ã¯ã»ã¹ãããããšã«æåããã°ãããŒã¯ã³ãæåŸ ããŠããã¢ããªã±ãŒã·ã§ã³ã§è¢«å®³è ã®ã¢ã«ãŠã³ããä¹ã£åãããšãã§ããŸããããã®ããŒã¯ã³ãèªåã®ã¢ããªIDã«ä»äžããããã©ããã確èªããŠããŸããã {% endhint %}
Two links & cookie
ãã®æžã蟌ã¿ã«ãããšã被害è ãæ»æè ã®ãã¹ããæãreturnUrlãæã€ããŒãžãéãããã«ããããšãå¯èœã§ããããã®æ å ±ã¯ã¯ãããŒïŒRUïŒã«ä¿åãããåŸã®ã¹ãããã§ããã³ããããŠãŒã¶ãŒã«ãã®æ»æè ã®ãã¹ããžã®ã¢ã¯ã»ã¹ãèš±å¯ãããã©ãããå°ããŸãã
ãã®ããã³ãããåé¿ããããã«ãOauthãããŒãéå§ããããã®ã¿ããéããreturnUrlã䜿çšããŠãã®RUã¯ãããŒãèšå®ããããã³ããã衚瀺ãããåã«ã¿ããéããæ°ããã¿ãããã®å€ãªãã§éãããšãå¯èœã§ããããããããšã**ããã³ããã¯æ»æè ã®ãã¹ãã«ã€ããŠéç¥ããŸããããã¯ãããŒã¯ããã«èšå®ããããããããŒã¯ã³ã¯ãªãã€ã¬ã¯ãã§æ»æè ã®ãã¹ãã«éä¿¡ãããŸãã
Prompt Interaction Bypass
ãã®ãããªã§èª¬æãããŠããããã«ãäžéšã®OAuthå®è£
ã§ã¯ãprompt
GETãã©ã¡ãŒã¿ãNoneïŒ&prompt=none
ïŒãšããŠæå®ããããšã§ããã§ã«ãã©ãããã©ãŒã ã«ãã°ã€ã³ããŠããå Žåã«ããŠã§ãäžã§äžããããã¢ã¯ã»ã¹ã確èªããããã«ãŠãŒã¶ãŒã«æ±ããããšãé²ãããšãã§ããŸãã
response_mode
ãã®ãããªã§èª¬æãããŠããããã«ã**response_mode
**ãã©ã¡ãŒã¿ãæå®ããŠãæçµURLã§ã³ãŒããã©ãã«æäŸããããã瀺ãããšãå¯èœã§ãïŒ
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 parameters
ãã®ç 究ã確èªããŠãã ãã ãã®æè¡ã®è©³çŽ°ã«ã€ããŠã
OAuthã«ãããåçã¯ã©ã€ã¢ã³ãç»é²ã¯ãã»ãã¥ãªãã£è匱æ§ã®ããã®ããŸãæçœã§ãªããéèŠãªãã¯ãã«ãšããŠæ©èœããç¹ã«**ãµãŒããŒãµã€ããªã¯ãšã¹ããã©ãŒãžã§ãªïŒSSRFïŒ**æ»æã«é¢é£ããŠããŸãããã®ãšã³ããã€ã³ãã¯ãOAuthãµãŒããŒãã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã«é¢ãã詳现ãåãåãããšãå¯èœã«ããæªçšãããå¯èœæ§ã®ããæ©å¯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ãååŸããå Žåã«æªçšãããå¯èœæ§ããããŸãã
æªçšæŠç¥ïŒ
- SSRFã¯ã
logo_uri
ãjwks_uri
ããŸãã¯sector_identifier_uri
ã®ãã©ã¡ãŒã¿ã«æªæã®ããURLãæã€æ°ããã¯ã©ã€ã¢ã³ããç»é²ããããšã§åŒãèµ·ããããå¯èœæ§ããããŸãã request_uris
ãä»ããçŽæ¥çãªæªçšã¯ãã¯ã€ããªã¹ãå¶åŸ¡ã«ãã£ãŠè»œæžãããå¯èœæ§ããããŸãããäºåã«ç»é²ãããæ»æè ãå¶åŸ¡ããrequest_uri
ãæäŸããããšã§ãèªå¯ãã§ãŒãºäžã«SSRFãä¿é²ããããšãã§ããŸãã
OAuth providers Race Conditions
ãã¹ãããŠãããã©ãããã©ãŒã ãOAuthãããã€ããŒã§ããå Žåã¯ãã¬ãŒã¹ã³ã³ãã£ã·ã§ã³ã®å¯èœæ§ããã¹ãããããã«ãããèªãã§ãã ããã
References
- https://medium.com/a-bugz-life/the-wondeful-world-of-oauth-bug-bounty-edition-af3073b354c1
- https://portswigger.net/research/hidden-oauth-attack-vectors
{% embed url="https://websec.nl/" %}
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the ð¬ Discord group or the telegram group or follow us on Twitter ðŠ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.