{"id":1264,"date":"2023-02-19T19:44:00","date_gmt":"2023-02-19T11:44:00","guid":{"rendered":"https:\/\/systw.net\/note\/?p=1264"},"modified":"2024-03-16T00:38:58","modified_gmt":"2024-03-15T16:38:58","slug":"dom-xss-open-redirection","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/1264","title":{"rendered":"DOM XSS to open redirection"},"content":{"rendered":"\n<p>\u653b\u64ca\u8005\u5982\u679c\u53ef\u4ee5\u5f71\u97ff\u8de8\u57df\u7528\u7684sink\u6642\uff0c\u5c31\u6703\u51fa\u73fe\u57fa\u65bc DOM \u7684\u958b\u653e\u91cd\u5b9a\u5411\u6f0f\u6d1e\u3002\u5982\u679c\u6709\u6b64\u6f0f\u6d1e\uff0c\u53ef\u4ee5\u5229\u7528\u6b64\u884c\u70ba\u4f86\u5c0d\u4f7f\u7528\u8005\u9032\u884c\u7db2\u8def\u91e3\u9b5a\u653b\u64ca\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u53ef\u80fd\u5c0e\u81f4\u57fa\u65bc DOM \u7684\u958b\u653e\u91cd\u5b9a\u5411\u6f0f\u6d1e\u7684\u4e3b\u8981sinks<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location\nlocation.host\nlocation.hostname\nlocation.href\nlocation.hash\nlocation.pathname\nlocation.search\nlocation.protocol\nlocation.assign()\nlocation.replace()\nopen()\nelement.srcdoc\nXMLHttpRequest.open()\nXMLHttpRequest.send()\njQuery.ajax()\n$.ajax()<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>\u4f8b\u5982\uff0c\u4ee5\u4e0b<code>location.hash<\/code>\u53ef\u88ab\u7528\u4f86\u767c\u52d5\u653b\u64ca<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let url = \/https?:\\\/\\\/.+\/.exec(location.hash);\nif (url) {\n  location = url&#91;0];\n}<\/code><\/pre>\n\n\n\n<p>\u653b\u64ca\u8005\u80fd\u5920\u5229\u7528\u6b64\u6f0f\u6d1e\u5efa\u69cb\u4e00\u500b URL\uff0c\u5982\u679c\u5176\u4ed6\u4f7f\u7528\u8005\u5b58\u53d6\u8a72\u653b\u64caURL\uff0c\u5c07\u5c0e\u81f4\u91cd\u5b9a\u5411\u5230\u4efb\u610f\u5916\u90e8\u7db2\u57df\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p>\u53e6\u4e00\u500b\u4f8b\u5b50\u5982\u4e0b\uff0c\u5047\u5982\u76ee\u6a19\u7db2\u7ad9\u6709\u6b64\u6f0f\u6d1e\uff0c\u53ef\u767c\u52d5\u653b\u64ca\u3002\u5f9e\u8fd4\u56de\u5167\u5bb9\u53ef\u4ee5\u770b\u5230\u6709\u4f7f\u7528open-redirection\u7684\u5f31\u9ede<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>######### request ############\nGET \/post?postId=2 HTTP\/2\n...omit...\n\n######### response ############\n...omit...\n&lt;a href='#' onclick='returnURL' = \/url=https?:\\\/\\\/.+)\/.exec(location); if(returnUrl)location.href = returnUrl&#91;1];else location.href = \"\/\"'&gt;Back to Blog&lt;\/a&gt;\n...omit...<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528chrome inspect\u770b\u767c\u73fe\u5167\u5bb9\u5dee\u4e0d\u591a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"is-linkback\"&gt;\n   &lt;a href=\"#\" onclick=\"returnUrl = \/url=(https?:\\\/\\\/.+)\/.exec(location); location.href = returnUrl ? returnUrl&#91;1] : \"\/\"\"&gt;Back to Blog&lt;\/a&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p>\u7531\u65bcscript\u5167\u7684url\u53c3\u6578\u6709\u91cd\u5c0e\u5411\u5f31\u9ede\uff0c\u56e0\u6b64\u53ef\u4ee5\u69cb\u5efa\u4ee5\u4e0b\u60e1\u610f\u93c8\u7d50<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;your-lab-id.web-security-academy.net\/post?postId=2&amp;url=https:\/\/attack.com\/<\/code><\/pre>\n\n\n\n<p>\u4e00\u65e6\u8a2a\u554f\u8a72\u9023\u7d50\uff0c<code>back to blog<\/code>\u7684\u6309\u9215\u6703\u88ab\u8a2d\u5b9a\u524d\u5f80\u4ee5\u4e0b\u7db2\u5740<\/p>\n\n\n\n<p><code>https:\/\/your-lab-id.web-security-academy.net\/post?postId=2&amp;url=https:\/\/attack.com\/#<\/code><\/p>\n\n\n\n<p>\u4e00\u65e6\u9ede\u64ca<code>back to blog<\/code>\uff0c\u5c31\u6703\u88ab\u91cd\u5c0e\u5411\u5230<code>https:\/\/attack.com\/<\/code><\/p>\n\n\n\n<p>Lab: DOM-based open redirection<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u653b\u64ca\u8005\u5982\u679c\u53ef\u4ee5\u5f71\u97ff\u8de8\u57df\u7528\u7684sink\u6642\uff0c\u5c31\u6703\u51fa\u73fe\u57fa\u65bc DOM  &#8230;<\/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":[40],"tags":[41],"class_list":["post-1264","post","type-post","status-publish","format-standard","hentry","category-clientside","tag-xss"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1264","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=1264"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1264\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=1264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=1264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=1264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}