{"id":10939,"date":"2023-08-10T23:24:42","date_gmt":"2023-08-10T15:24:42","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10939"},"modified":"2023-08-14T11:26:12","modified_gmt":"2023-08-14T03:26:12","slug":"html-attribute-nonce-translate","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/08\/html-attribute-nonce-translate\/","title":{"rendered":"\u67e5\u6f0f\u8865\u7f3a\uff0c\u6211\u4ecd\u672a\u77e5\u9053\u7684HTML nonce\u548cpopover\u5c5e\u6027"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10939\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10939<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202308-nonce-popover.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/nonce-popover-cover.png\" width=\"421\" height=\"272\" alt=\"\u5c01\u9762\u56fe\uff0c\u5c0f\u9e7f\u770b\u9e1f\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h4>\u524d\u8a00<\/h4>\n<p>\u6570\u5e74\u524d\u6709\u6574\u7406\u8fc7\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2020\/01\/html-global-attributes\/\">HTML\u5168\u5c40\u5c5e\u6027\u5217\u8868\u5927\u5168<\/a>\u201d\uff0c\u4eca\u5929\u518d\u6b21\u6e29\u4e60\u4e86\u4e0b\uff0c\u53d1\u73b0\u5c1a\u6709\u7f3a\u6f0f\uff0c\u6240\u4ee5\u8fd9\u91cc\u518d\u6b21\u8bb0\u5f55\u4e0b\u3002<\/p>\n<p>\u7f3a\u4e86\u8fd9\u4e24\u4e2aHTML\u5c5e\u6027\uff0c\u4e00\u4e2a\u662f nonce\uff0c\u53e6\u4e00\u4e2a\u662f popover\u3002<\/p>\n<h3>\u4e00\u3001\u5b89\u5168\u4e0enonce<\/h3>\n<p>nonce\u7684\u4e2d\u6587\u610f\u601d\u662f\u201c\u4e34\u65f6\u9020\u7684\uff0c\u5076\u9020\u7684\uff0c\u53ea\u4f7f\u7528\u4e00\u6b21\u7684\u201d\uff0c\u914d\u5408\u201c\u5185\u5bb9\u5b89\u5168\u7b56\u7565\uff08Content Security Policy\uff0c\u7b80\u79f0CSP\uff09\u201d\uff0c\u53ef\u4ee5\u51b3\u5b9a\u7ed9\u5b9a\u5143\u7d20\u7684\u8bf7\u6c42\u662f\u5426\u6267\u884c\u3002<\/p>\n<p>\u5e94\u7528\u5e38\u7528\u662f\u8fd9\u6837\u7684\u3002<\/p>\n<p>\u524d\u7aef\u662f\u53ef\u4ee5\u901a\u8fc7 <code>&lt;meta&gt;<\/code> \u5143\u7d20\u6307\u5b9a\u9875\u9762\u7684\u5185\u5bb9\u5b89\u5168\u7b56\u7565\u7684\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'\" \/&gt;<\/pre>\n<p>\u53ef\u4ee5\u8ba9\u53ea\u6709\u548c\u9875\u9762\u540c\u57df\u540d\u7684\u9759\u6001\u8d44\u6e90\u624d\u52a0\u8f7d\uff0c\u540c\u65f6\uff0c\u4f1a\u963b\u6b62\u9875\u9762\u4e0a\u6240\u6709\u5185\u8054JavaScript\u7684\u6267\u884c\uff0c\u8fd9\u6837\uff0c\u53ef\u4ee5\u6709\u6548\u907f\u514dXSS\u653b\u51fb\u3002<\/p>\n<p>\u4f8b\u5982\u6709\u9875\u9762\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'\"&gt;\r\n    &lt;title&gt;CSP unsafe-inline\u4e0e\u5185\u8054JS\u548cCSS\u7684\u6267\u884c&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;p&gt;\u6ca1\u6709alert\u63d0\u793a\u51fa\u73b0\u3002&lt;\/p&gt;\r\n    &lt;script&gt;\r\n        alert('hello world');\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><code>&lt;header&gt;<\/code> \u5143\u7d20\u5185\u6307\u5b9a\u4e86\u67d0\u4e2a CSP \u7b56\u7565\uff0c\u6b64\u65f6\uff0c\u5185\u8054\u7684 <code>&lt;script&gt;<\/code> \u5143\u7d20\u5185\u7684JS\u4ee3\u7801\u662f\u4e0d\u6267\u884c\u7684\uff0c\u4e5f\u5c31\u662f\u9875\u9762\u4e0d\u4f1a\u51fa\u73b0 alert \u63d0\u793a\u3002<\/p>\n<p>\u4e0d\u4ec5\u5982\u6b64\uff0c\u9875\u9762\u8fd8\u4f1a\u62a5\u4e00\u4e9b\u9519\u8bef\uff1a<\/p>\n<blockquote><p>Refused to execute inline script because it violates the following Content Security Policy directive: &#8220;default-src &#8216;self'&#8221;. Either the &#8216;unsafe-inline&#8217; keyword, a hash (&#8216;sha256-Ucj61+zsMpSab6QdWBaKF0dD7g1XPR4K+DJ4ZkaowqY=&#8217;), or a nonce (&#8216;nonce-&#8230;&#8217;) is required to enable inline execution. Note also that &#8216;script-src&#8217; was not explicitly set, so &#8216;default-src&#8217; is used as a fallback.<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_171545.png\" width=\"581\" height=\"255\" alt=\"\u62a5\u9519\u63d0\u793a\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4f46\u8fd9\u79cd\u9650\u5236\u592a\u4e25\u683c\u4e86\uff0c\u5f00\u53d1\u8005\u672c\u610f\u662f\u9650\u5236\u5916\u94fe\u8d44\u6e90\u7684\u52a0\u8f7d\u548c\u6267\u884c\uff0c\u7ed3\u679c\u8fde\u5185\u8054JS\u90fd\u4e0d\u6267\u884c\u4e86\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u662f\u6709\u5904\u7406\u65b9\u6cd5\u7684\uff0c\u4f7f\u7528 unsafe-inline \u7b56\u7565\u5373\u53ef\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self' 'unsafe-inline'\" \/&gt;<\/pre>\n<p>\u6b64\u65f6\uff0c\u5c31\u53ef\u4ee5\u6b63\u5e38\u89e6\u53d1alert\u63d0\u793a\u4ee3\u7801\u7684\u6267\u884c\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_171911.png\" width=\"696\" height=\"189\" alt=\"alert\u63d0\u793a\u6b63\u5e38\u6267\u884c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4f46\uff0c\u5982\u679c\u5927\u5bb6\u53bb\u67e5\u627e\u5173\u4e8e CSP \u7684\u8d44\u6599\uff0c\u65e0\u4e00\u4f8b\u5916\u90fd\u662f\u4e0d\u63a8\u8350\u4f7f\u7528 &#8216;unsafe-inline&#8217;\uff0c\u56e0\u4e3a\u5176\u4f1a\u8ba9\u5927\u591a\u6570\u7684\u5b89\u5168\u9650\u5236\u5931\u6548\uff0c\u4f8b\u5982\uff0c\u5047\u8bbe\u4ee3\u7801\u5b9e\u73b0\u4e0d\u5230\u4f4d\uff0c\u5c31\u4f1a\u9047\u5230\u4e0b\u56fe\u6240\u793a\u7684XSS\u653b\u51fb\u3002<\/p>\n<pre>\/app?name=&lt;script&gt;alert('xss');&lt;script&gt;<\/pre>\n<p>\u8fd9\u5c31\u51fa\u73b0\u4e86\u77db\u76fe\uff0c\u6709\u4e9b\u5185\u8054\u4ee3\u7801\u660e\u660e\u662f\u81ea\u5df1\u4eba\u5199\u7684\uff0c\u5374\u4e0d\u8ba9\u6267\u884c\uff0c\u5c82\u80fd\u56e0\u564e\u5e9f\u98df\uff1f<\/p>\n<p>\u6b64\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 nonce \u7b56\u7565\uff0c\u5141\u8bb8\u67d0\u90e8\u5206\u5185\u8054JS\u6267\u884c\uff0c\u8fd9\u6837\u5c31\u907f\u514d\u4e86unsafe-inline\u8fd9\u79cd\u5168\u5c40\u7b56\u7565\u5bf9\u6574\u4e2a\u9875\u9762\u7684\u5f71\u54cd\u3002<\/p>\n<h4>\u5982\u4f55\u5b9e\u73b0\uff1f<\/h4>\n<p>\u901a\u5e38\u5206\u4e3a\u4e0b\u9762\u51e0\u6b65\u3002<\/p>\n<ol>\n<li>\u751f\u6210\u4e00\u6bb5\u968f\u673a\u7684Base64\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5bc6\u94a5\uff0c\u81f3\u5c11\u5305\u542b128\u4f4d\u6570\u636e\uff0c\u6bcf\u6b21\u9875\u9762\u8f7d\u5165\u8fd9\u4e2a\u503c\u90fd\u5fc5\u987b\u662f\u65b0\u7684\u4e14\u552f\u4e00\u7684\u3002\u4e0b\u9762\u4ee3\u7801\u793a\u610f\u7684\u662fnode.js\u73af\u5883\u4e2d\u7684\u751f\u6210\uff1a\n<pre>\r\nconst crypto = require(\"crypto\");\r\ncrypto.randomBytes(16).toString(\"base64\");\r\n\/\/ '8IBTHwOdqNKAWeKl7plt8g=='<\/pre>\n<p>Web\u4fa7\u53ef\u4ee5\u8bd5\u8bd5\u4e0b\u9762\u7684\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre>btoa(crypto.randomUUID())\r\n\/\/ NDhkODkxMzYtNGUxZS00N2NjLTk1YTItNWMyOTM4YzdhZGJj<\/pre>\n<\/li>\n<li>\u5c06\u6b64\u968f\u673a\u5b57\u7b26\u4e32\u4f5c\u4e3anonce\u7684\u5c5e\u6027\u503c\uff0c\u4f8b\u5982\uff1a\n<pre>&lt;script nonce=\"NDhkODkxMzYtNGUxZS00N2NjLTk1YTItNWMyOTM4YzdhZGJj\"&gt;\r\n  \/\/ \u2026\r\n&lt;\/script&gt;<\/pre>\n<\/li>\n<li>\u5728Content-Security-Policy\u7b56\u7565\u4e2d\u6307\u5b9a\u6b64nonce\u503c\uff0c\u4ee5<code>nonce-<\/code>\u5f00\u5934\u3002\n<pre>&lt;meta http-equiv=\"Content-Security-Policy\" content=\"script-src 'nonce-NDhkODkxMzYtNGUxZS00N2NjLTk1YTItNWMyOTM4YzdhZGJj'\"&gt;<\/pre>\n<p>\u6b64\u65f6\uff0c\u4ec5\u4ec5nonce\u503c\u6709\u8bbe\u7f6e\uff0c\u4e14\u503c\u5339\u914d\u7684 <code>&lt;script&gt;<\/code> \u4ee3\u7801\u624d\u4f1a\u6267\u884c\u3002<\/li>\n<\/ol>\n<h4>\u5176\u4ed6\u7279\u6027<\/h4>\n<p>MDN\u6587\u6863\u4e0a\u6709\u8bf4\uff0c\u51fa\u4e8e\u5b89\u5168\u8003\u8651\uff0cnonce\u5c5e\u6027\u503c\u65e0\u6cd5\u83b7\u53d6\uff0c\u53ea\u80fd\u8bfb\u53d6\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u4e0b\u9762\u7684\u4ee3\u7801(getAttribute\u65b9\u6cd5)\u662f\u65e0\u6cd5\u83b7\u5f97nonce\u5c5e\u6027\u503c\u7684\uff1a<\/p>\n<pre>\/\/ \u8fd4\u56de\u7a7a\u5b57\u7b26\u4e32\r\nscript.getAttribute(\"nonce\");<\/pre>\n<p>\u7136\u800c\uff0c\u6839\u636e\u6211\u7684\u6d4b\u8bd5\uff0c\u662f\u53ef\u4ee5\u83b7\u53d6\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_180054.png\" width=\"403\" height=\"349\" alt=\"\u53ef\u4ee5\u83b7\u53d6nonce\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e0d\u4ec5\u662f\u63a7\u5236\u53f0\uff0c\u5c31\u662f\u5728\u9875\u9762JS\u4ee3\u7801\u4e2d\u4e5f\u662f\u53ef\u4ee5\u8fd4\u56de\u7684\u3002<\/p>\n<p>\u6211\u4e0d\u6e05\u695a\u662f\u4e0d\u662f\u6211\u6253\u5f00\u7684\u65b9\u5f0f\u4e0d\u5bf9\uff0c\u8fd8\u662f\u89c4\u8303\u662f\u8fd9\u4e48\u5b9a\u4e49\u7684\uff0c\u4f46\u662f\u6d4f\u89c8\u5668\u5e76\u672a\u4e25\u683c\u6267\u884c\u8fd9\u4e2a\u7b56\u7565\u3002<\/p>\n<h3>\u4e8c\u3001\u539f\u751f\u5f39\u5c42\u4e0epopover<\/h3>\n<p><code>popover<\/code> \u5c5e\u6027\u662f\u4e2a\u6bd4\u8f83\u65b0\u7684\u5c5e\u6027\u3002<\/p>\n<p>\u53ef\u4ee5\u8ba9\u4efb\u610f\u7684\u5143\u7d20\u70b9\u51fb\u540e\u76f4\u63a5\u51fa\u73b0\u6d4f\u89c8\u5668\u5c42\u9762\u7684popover\u5f39\u51fa\u5c42\u6548\u679c\u3002<\/p>\n<p>\u5176\u5b9e\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u901a\u8fc7\u4e00\u4e9bHTML\u5c5e\u6027\u6307\u5b9a\u5373\u53ef\u5b9e\u73b0\u5bf9\u5e94\u7684\u529f\u80fd\uff0c\u770b\u4ee3\u7801\u5c31\u4e00\u76ee\u4e86\u7136\uff1a<\/p>\n<p>\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;button popovertarget=\"imgPopover\"&gt;\u70b9\u51fb\u6211&lt;\/button&gt;  \r\n&lt;div popover id=\"imgPopover\"&gt;\r\n    &lt;img src=\"1.jpg\" \/&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\u6b64\u65f6\uff0c\u70b9\u51fb\u6309\u94ae\uff0c\u5c31\u4f1a\u51fa\u73b0\u56fe\u7247\u663e\u793a\u6d6e\u5c42\u3002<\/p>\n<p>\u6548\u679c\u793a\u610f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_223232.png\" width=\"509\" height=\"444\" alt=\"\u70b9\u51fb\u6309\u94ae\u51fa\u73b0\u6d6e\u5c42\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202308\/html-popover-show-image-demo.php\" rel=\"noopener\" target=\"_blank\">\u539f\u751fpopover\u5f39\u51fa\u5c42\u67e5\u770b\u56fe\u7247demo<\/a><\/p>\n<p>\u5176\u4e2d\uff0c<code>popovertarget<\/code>\u5c5e\u6027\u8bbe\u7f6e\u5728\u6309\u94ae\u4e0a\uff0c\u70b9\u51fb\u540e\uff0c\u81ea\u52a8\u5bfb\u627e\u8bbe\u7f6e\u4e86popover\u5c5e\u6027\uff0c\u540c\u65f6 id \u503c\u5339\u914d\u7684\u5143\u7d20\u3002<\/p>\n<p>\u800c\u8bbe\u7f6e\u4e86<code>popover<\/code>\u5c5e\u6027\u7684\u5143\u7d20\u9ed8\u8ba4\u9690\u85cf\uff0c\u81ea\u5e26\u8fb9\u6846\uff0c\u906e\u7f69\u80cc\u666f\u900f\u660e\uff0c\u540c\u65f6\u5c42\u7ea7\u9876\u7ea7\uff08top layer\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_223535.png\" width=\"459\" height=\"130\" alt=\"\u9876\u7ea7\u5c42\u7ea7\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u652f\u6301ESC\u7b49\u5feb\u6377\u952e\uff0c\u4f7f\u7528\u975e\u5e38\u65b9\u4fbf\uff0c\u53ef\u8c13\u662f\u5b9e\u73b0\u6d6e\u5c42\u5f39\u51fa\u5c42\u7684\u4e0a\u4e0a\u4e4b\u9009\u3002<\/p>\n<h4>\u517c\u5bb9\u6027<\/h4>\n<p>\u517c\u5bb9\u6027\u8fd9\u5757\uff0c\u5df2\u7ecf\u53ef\u4ee5\u660e\u786e\u5404\u5927\u73b0\u4ee3\u6d4f\u89c8\u5668\u90fd\u4f1a\u652f\u6301\uff0c\u76ee\u524d\u73b0\u72b6\u662fChrome\u548cSafari\u5df2\u7ecf\u652f\u6301\uff0cFirefox\u5f00\u542f\u5b9e\u9a8c\u652f\u6301\uff0c\u4e0d\u51fa\u4e00\u4e24\u5e74\uff0c\u5c31\u53ef\u4ee5\u5728\u6b63\u5f0f\u73af\u5883\u4f7f\u7528\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/2023-08-10_223951.png\" width=\"651\" height=\"263\" alt=\"popover\u5b9e\u73b0\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e09\u3001\u7ed3\u8bed\u5ff5\u5ff5\u53e8\u53e8<\/h3>\n<p>1. \u6234\u4e86\u5feb3\u5e74\u7684\u7259\u7b8d\u62c6\u4e86\uff0c\u82b1\u8d39\u63a5\u8fd13\u4e07\uff0c\u63a5\u4e0b\u6765\u8fd8\u9700\u8981\u5e26\u4fdd\u6301\u5668\uff0c\u7136\u540e\u7a33\u5b9a\u540e\u518d\u53bb\u8865\u7259\uff0c\u65b9\u6848\u5b9a\u597d\u4e86\uff0c\u9a6c\u91cc\u5170\u6865\uff0c\u8d39\u75285000~6000\uff0c\u5c31\u4e00\u4e2a\u7259\u9f7f\u54e6\u3002<\/p>\n<p>\u4fdd\u6301\u5668\u5c31\u662f\u4e2a\u6709\u7259\u9f7f\u51f9\u578b\u7684\u5851\u6599\u7247\uff0c\u5176\u8c8c\u4e0d\u626c\uff0c800\u5143\uff0c\u5403\u996d\u8981\u6458\u6389\uff0c\u5403\u5b8c\u8fd8\u8981\u6234\u4e0a\uff0c\u7b2c\u4e00\u5e7424\u5c0f\u65f6\uff0c\u53ef\u80fd\u662f\u65b0\u505a\u7684\uff0c\u88c5\u548c\u62ff\u90fd\u4e00\u8a00\u96be\u5c3d\uff0c\u4e0a\u6392\u7684\u62ff\u4e0b\u6765\u50cf\u62d4\u7259\uff0c\u8981\u7528\u5f88\u5927\u7684\u529b\uff0c\u4e0b\u6392\u8fb9\u7f18\u788d\u7740\u4e00\u4e2a\u7a81\u51fa\u7684\u7259\u9f88\u6839\uff0c\u90fd\u7ea2\u4e86\u3002<\/p>\n<p>\u5509\uff0c\u9ebb\u70e6\u53c8\u75db\u82e6\uff0c\u5e0c\u671b\u7a33\u5b9a\u4e00\u6bb5\u65f6\u5019\u540e\u4f1a\u597d\u4e00\u4e9b\u3002<\/p>\n<p>2. \u4e0a\u5468\u516d\u53bb\u90ca\u5916\uff0c\u60f3\u987a\u4fbf\u4e70\u4e9b\u5357\u6c47\u6c34\u871c\u6843\uff0c\u88ab\u544a\u77e5\u4e0b\u5e02\u4e86\uff0c\u6211\u6574\u4e2a\u4eba\u90fd\u4e0d\u597d\u4e86\uff0c\u8fd8\u6ca1\u5f00\u59cb\u8fd9\u5c31\u7ed3\u675f\u4e86\u3002<\/p>\n<p>3. \u4e0a\u5468\u672b\u53bb\u770b\u4e86\u8f66\uff0c\u621111\u5e74\u7684\u7b2c\u4e00\u8f86\u8001\u8f66\u6253\u7b97\u8d70\u62a5\u9500\uff0c\u7ed9\u5bb6\u91cc\u9886\u5bfc\u6362\u4e2a\u65b0\u7684\u4ee3\u6b65\u8f66\uff0c2023\u5e74\u6709\u65b0\u653f\u7b56\uff0c\u62a5\u9500\u6709\u8865\u8d34\uff0c\u6bd4\u5356\u4e8c\u624b\u8f66\u5212\u7b97\uff0c\u53ef\u95ee\u4e0b\u6765\uff0c\u6709\u8bf4\u6ca1\u6709\uff0c\u53c8\u8bf4\u62a5\u9500\u5c312000\u5757\u94b1\uff0c\u8fd8\u4e0d\u6b62\u5565\u60c5\u51b5\uff0c\u8fd9\u5468\u672b\u518d\u53bb\u95ee\u95ee\u3002<\/p>\n<p>4. \u53d1\u73b0Web\u8fd9\u5757\uff0c\u5173\u4e8e\u5b89\u5168\u7684\u77e5\u8bc6\u975e\u5e38\u591a\uff0c\u4e5f\u6bd4\u8f83\u6742\uff0c\u5173\u952e\u2026\u2026\u600e\u4e48\u8bf4\u5462\uff0c\u6ca1\u6709\u60f3\u8c61\u7684\u90a3\u4e48\u6709\u5fc5\u8981\uff0c\u611f\u89c9\u5b66\u8fd8\u662f\u4e0d\u5b66\uff0c\u6536\u76ca\u4e5f\u5c31\u90a3\u6837\uff0c\u6bd4\u65b9\u8bf4XSS\u653b\u51fb\uff0c\u5e73\u65f6\u5f00\u53d1\u591a\u6ce8\u610f\uff0c\u80af\u5b9a\u6bd4\u4f7f\u7528CSP\u9650\u5236\u66f4\u7701\u5fc3\uff0c\u540e\u8005\u8fd8\u8981\u5b66\u4e60\uff0c\u8fd8\u6709\u4e00\u5806\u9ebb\u70e6\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u6211\u89c9\u5f97\u4e86\u89e3\u8fd8\u662f\u6709\u5fc5\u8981\u7684\uff0c\u6bd4\u65b9\u8bf4XSS\u653b\u51fb\u5982\u4f55\u53d1\u751f\uff0c\u5e73\u65f6\u8be5\u6ce8\u610f\u4ec0\u4e48\uff0c\u6709\u54ea\u4e9b\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u57fa\u672c\u7684\u77e5\u8bc6\u8fd8\u8981\u77e5\u9053\u7684\uff0c\u81f3\u4e8e\u66f4\u6df1\u5165\u7684\u89e3\u51b3\u65b9\u6cd5\uff0c\u4ee5\u53ca\u8bed\u6cd5\u7ec6\u8282\uff0c\u54b1\u4eec\u6bd5\u7adf\u4e0d\u662f\u4e13\u95e8\u505a\u5b89\u5168\u51fa\u8eab\u7684\uff0c\u8003\u8651\u5230\u8fd8\u6709\u66f4\u91cd\u8981\u7684\u77e5\u8bc6\u8981\u5b66\u4e60\uff0c\u6240\u4ee5\u6ca1\u6709\u5fc5\u8981\u82b1\u592a\u591a\u65f6\u95f4\u5728\u4e0a\u9762\u3002<\/p>\n<p>\u597d\u5427\uff0c\u5c31\u8bf4\u8fd9\u4e48\u591a\u5427\uff0c\u4e00\u4e9b\u77e5\u8bc6\uff0c\u4e00\u4e9b\u788e\u788e\u5ff5\uff0c\u6b22\u8fce<button onclick=\"shareWeixin.click()\" class=\"entry-share-btn\">\u5206\u4eab<\/button>\uff0c\u611f\u8c22\u9605\u8bfb\uff01<\/p>\n<p>???<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10939\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10939<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202308\/nonce-popover-cover.png\" width=\"160\" height=\"103\" alt=\"\u5c01\u9762\u56fe\uff0c\u5c0f\u9e7f\u770b\u9e1f\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>nonce\u53ef\u4ee5\u7528\u6765\u51b3\u5b9a\u54ea\u4e9b\u5185\u8054JS\u6267\u884c\uff0cpopover\u53ef\u4ee5\u65e0JS\u5b9e\u73b0\u6d6e\u5c42\u5f39\u51fa\u5c42\u4ea4\u4e92\u6548\u679c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1097],"tags":[1938,1808,1394,9,982,1936,1935,1937,1939],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10939"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10939"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10939\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}