{"id":5261,"date":"2021-08-15T08:56:12","date_gmt":"2021-08-15T00:56:12","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=5261"},"modified":"2021-08-15T08:56:12","modified_gmt":"2021-08-15T00:56:12","slug":"spring%e8%bf%9e%e7%8e%af%e6%bc%8f%e6%b4%9ecve-2015-5211%e5%92%8ccve-2020-5421%e4%bf%ae%e5%a4%8d%e5%8d%87%e7%ba%a7%e6%95%99%e7%a8%8b%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=5261","title":{"rendered":"Spring\u8fde\u73af\u6f0f\u6d1eCVE-2015-5211\u548cCVE-2020-5421\u4fee\u590d\u5347\u7ea7\u6559\u7a0b\uff01"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u4e0d\u9020\u8f6e\u5b50\uff0c\u4f46\u9700\u8981\u5b66\u4f1a\u4fee\u590d\u8f6e\u5b50\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u591a\u6570\u7a0b\u5e8f\u5458\u4f1a\u70b9 Star\uff0c\u5c11\u6570\u7a0b\u5e8f\u5458\u4f1a Fork\uff0c\u53ea\u6709\u6781\u5c11\u6570\u7684\u7a0b\u5e8f\u5458\u4f1a\u70b9 Watch\u3002\u800c\u6211\u4e00\u822c\u4f1a\u70b9 Star \u548c Watch\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xmt1139057136\/xttblog\/2021\/08\/cve0.png\" alt=\"Spring\u5f00\u6e90\u4ee3\u7801\" \/><figcaption>Spring\u5f00\u6e90\u4ee3\u7801<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u70b9 Watch \u7684\u539f\u56e0\u662f\uff0c\u89c2\u5bdf\u8fd9\u4e2a\u6846\u67b6\u6700\u65b0\u7684\u6539\u52a8\uff0c\u63d0\u4ea4\u4e86\u54ea\u4e9b\u65b0\u4ee3\u7801\uff0c\u4e3a\u4ec0\u4e48\u63d0\u4ea4\u8fd9\u4e9b\u4ee3\u7801\u7b49\u7b49\u3002\u5173\u6ce8\u8fd9\u4e9b\u5185\u5bb9\uff0c\u5f80\u5f80\u5bf9\u6211\u6709\u975e\u5e38\u5927\u7684\u60ca\u559c\uff0c\u6211\u4ece\u4e2d\u5b66\u5230\u4e0d\u5c11\u77e5\u8bc6\uff0c\u540c\u65f6\u4e5f\u4f1a\u7b2c\u4e00\u65f6\u95f4\u83b7\u5f97\u5f00\u6e90\u6846\u67b6\u7684\u6f0f\u6d1e\u4fee\u590d\u60c5\u51b5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6628\u5929\u5468\u4e94\u4e0b\u73ed\u65f6\u95f4\uff0c\u5ba2\u6237\u8f6c\u53d1\u4e86\u4e00\u5c01\u90ae\u4ef6\u7ed9\u6211\u3002\u90ae\u4ef6\u663e\u793a Spring \u6709\u4e00\u4e2a\u6f0f\u6d1e\u9700\u8981\u4fee\u590d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xmt1139057136\/xttblog\/2021\/08\/cve1.png\" alt=\"CVE-2015-5211\" \/><figcaption>CVE-2015-5211<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u770b\u8fd9\u4e2a\u6f0f\u6d1e\u7f16\u53f7\u5c31\u77e5\u9053\uff0c\u5b83\u662f\u4e00\u4e2a 2015 \u5e74\u5c31\u62a5\u544a\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xmt1139057136\/xttblog\/2021\/08\/cve2.png\" alt=\"CVE-2015-5211\" \/><figcaption>CVE-2015-5211<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5173\u4e8e\u8fd9\u4e2a\u6f0f\u6d1e\u7684\u8bf4\u660e\u548c\u4fee\u590d\uff0c\u7f51\u4e0a\u7684\u8d44\u6599\u90fd\u5f88\u5c11\uff0c\u5c31\u50cf\u662f\u521a\u88ab\u53d1\u73b0\u7684\u4e00\u6837\u3002\u901a\u8fc7\u641c\u7d22\u67e5\u627e\u5f97\u77e5\uff0c\u8fd9\u4e2a\u6f0f\u6d1e\u7684\u53d1\u73b0\u4e0e\u590d\u73b0\u6765\u81ea\u4e8e\u4e00\u7bc7\u8bba\u6587(<code><a href=\"https:\/\/www.trustwave.com\/en-us\/resources\/blogs\/spiderlabs-blog\/reflected-file-download-a-new-web-attack-vector\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/www.trustwave.com\/en-us\/resources\/blogs\/spiderlabs-blog\/reflected-file-download-a-new-web-attack-vector\/\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">https:\/\/www.trustwave.com\/en-us\/resources\/blogs\/spiderlabs-blog\/reflected-file-download-a-new-web-attack-vector\/<\/a><\/code>)\uff0c\u800c\u4e4b\u6240\u4ee5\u4e0d\u53d7\u91cd\u89c6\u662f\u56e0\u4e3a\u8c37\u6b4c\u548c Spring \u56e2\u961f\u8ba4\u4e3a\u8fd9\u4e2a\u6f0f\u6d1e\u5f71\u54cd\u5e76\u4e0d\u5927\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CVE-2015-5211 \u5c31\u662f\u4e00\u4e2a\u6211\u4eec\u5e38\u89c1\u7684 RFD \u6f0f\u6d1e\u3002RFD\uff0c\u5373<code>Reflected File Download<\/code>\u53cd\u5c04\u578b\u6587\u4ef6\u4e0b\u8f7d\u6f0f\u6d1e\uff0c\u662f\u4e00\u4e2a 2014 \u5e74\u6765\u81ea BlackHat \u7684\u6f0f\u6d1e\u3002\u8fd9\u4e2a\u6f0f\u6d1e\u5728\u539f\u7406\u4e0a\u7c7b\u4f3c XSS\uff0c\u5728\u5371\u5bb3\u4e0a\u7c7b\u4f3c DDE\uff1a\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a URL \u5730\u5740\u4f7f\u7528\u6237\u4e0b\u8f7d\u4e00\u4e2a\u6076\u610f\u6587\u4ef6\uff0c\u4ece\u800c\u5371\u5bb3\u7528\u6237\u7684\u7ec8\u7aef PC\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u6f0f\u6d1e\u5f88\u7f55\u89c1\uff0c\u5927\u591a\u6570\u516c\u53f8\u4f1a\u8ba4\u4e3a\u5b83\u662f\u4e00\u4e2a\u9700\u8981\u7ed3\u5408\u793e\u5de5\u7684\u4f4e\u5371\u6f0f\u6d1e\uff0c\u4f46\u8c37\u6b4c\uff0c\u5fae\u8f6f\uff0c\u96c5\u864e\uff0ceBay\uff0cPayPal \u548c\u5176\u4ed6\u8bb8\u591a\u516c\u53f8\u8ba4\u4e3a\u8fd9\u662f\u4e00\u4e2a\u4e2d\u5371\u6f0f\u6d1e\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xmt1139057136\/xttblog\/2021\/08\/cve3.png\" alt=\"RFD \u6f0f\u6d1e\" \/><figcaption>RFD \u6f0f\u6d1e<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u5c31\u662f\u8bf4\u8fd9\u4e2a\u6f0f\u6d1e\u4f24\u5bb3\u6027\u4e0d\u5927\uff0c\u5c48\u8fb1\u6027\u4e5f\u4e0d\u5f3a\u3002\u901a\u8fc7\u8fd9\u4e2a\u6f0f\u6d1e\u80fd\u591f\u6253\u5f00\u6211\u4eec\u7684\u8ba1\u7b97\u5668\uff0c\u5173\u95ed\u7535\u8111\u7b49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>## \u6279\u5904\u7406\u6267\u884c\u65f6\u4f1a\u6253\u5f00\u8ba1\u7b97\u5668\nhttp:\/\/www.google.com\/finance\/info;setup.bat?q=ELI:ALTR&callback=calc\n## \u6279\u5904\u7406\u6267\u884c\u65f6windows\u4f1a\u6ce8\u9500\nhttp:\/\/www.google.com\/finance\/info;setup.bat?q=ELI:ALTR&amp;callback=logoff<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\uff0c\u5bf9\u8be5\u95ee\u9898\u53ea\u662f\u7b80\u5355\u901a\u62a5\uff0c\u5bf9\u518d\u73b0\u548c\u9a8c\u8bc1\u4e5f\u4e0d\u591f\u91cd\u89c6\uff0c\u5bf9\u53ef\u89c1\u7684\u4fee\u6539\u65b9\u6848\u5c31\u66f4\u4e0d\u8981\u5962\u671b\u4e86\u3002\u540e\u6765\uff0c\u5b98\u65b9\u5728\u5347\u7ea7\u5176\u4ed6\u6f0f\u6d1e\u548c\u529f\u80fd\u65f6\uff0c\u4e5f\u5bf9\u8fd9\u4e2a\u6f0f\u6d1e\u8fdb\u884c\u4e86\u4e00\u5e76\u4fee\u590d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4fee\u6539 CVE-2015-5211 \u8865\u4e01\u63d0\u4ea4\u8bb0\u5f55 Protect against RFD exploits(<code><a rel=\"noreferrer noopener\" aria-label=\"https:\/\/github.com\/spring-projects\/spring-framework\/commit\/2bd1da\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"https:\/\/github.com\/spring-projects\/spring-framework\/commit\/2bd1da\" target=\"_blank\">https:\/\/github.com\/spring-projects\/spring-framework\/commit\/2bd1da<\/a><\/code>)<\/li><li>\u4fee\u6539 CVE-2015-5211 \u53c2\u8003\u8865\u4e01\u63d0\u4ea4\u8bb0\u5f55Avoid unnecessary parsing of path params(<code><a href=\"https:\/\/github.com\/spring-projects\/spring-framework\/commit\/899761f0a8890353dc01f10d2af96ae192f3e655\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/github.com\/spring-projects\/spring-framework\/commit\/899761f0a8890353dc01f10d2af96ae192f3e655\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">https:\/\/github.com\/spring-projects\/spring-framework\/commit\/899761f0a8890353dc01f10d2af96ae192f3e655<\/a><\/code>)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c31\u662f\u56e0\u4e3a\u4e0d\u591f\u91cd\u89c6\uff0c\u5b98\u65b9\u5728\u4fee\u590d <code>CVE-2015-5211<\/code> \u5b8c\u6210\u540e\u3002\u5728 2020 \u5e74\uff0c\u53c8\u88ab\u53d1\u73b0\uff0c\u5f53\u5e74\u4fee\u590d\u7684 CVE-2015-5211 \u6f0f\u6d1e\uff0c\u5f15\u51fa\u4e86\u65b0\u7684\u6f0f\u6d1e\uff1a<code>CVE-2020-5421<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u62d4\u8d77\u841d\u535c\u5e26\u8d77\u6ce5\u3002<code>CVE-2020-5421<\/code>\u7684\u6f0f\u6d1e\u662f\u5728\u4fee\u590d<code>CVE-2015-5211<\/code>\u65f6\uff0c\u7559\u4e0b\u7684\u4e00\u4e2a\u6f0f\u6d1e\u3002\u5728\u5bf9 url \u505a\u8fc7\u6ee4\u67e5\u627e\u6587\u4ef6\u540d\u79f0\u524d\uff0c\u5148\u9488\u5bf9\u6027\u7684\u5904\u7406\u4e86<code>;jsessionid=xxxx;<\/code>\u3002\u5728\u53d1\u73b0<code>;jsessionId=<\/code>\u5f00\u59cb\u5230\u4e0b\u4e00\u4e2a\u5206\u53f7\u7ed3\u675f\u7684\u90e8\u5206\u5185\u4e0d\u68c0\u67e5\u662f\u5426\u5b58\u5728\u6587\u4ef6\u540d\u79f0\uff0c\u800c\u6f0f\u6d1e\u5c31\u53ef\u4ee5\u901a\u8fc7<code>;jsessionid=ssddfeff&amp;setup.bat<\/code>\u8fd9\u6837\u7684\u65b9\u5f0f\u5b58\u5728\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u597d\u7406\u89e3\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u6267\u884c\uff1a<code>http:\/\/localhost:8080\/spring\/;jsessionid=\/input.bat?input=calc<\/code>\u3002\u539f\u672c\u7684\u6253\u5f00\u8ba1\u7b97\u5668\u88ab\u4fee\u590d\u4e86\uff0c\u73b0\u5728\u53d8\u6210\u4e86\u4e0b\u8f7d\u540d\u4e3a<code>input.bat<\/code>\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u590d\u73b0\u8fc7\u7a0b\u8d85\u7ea7\u7b80\u5355\uff0c\u4e3b\u8981\u4ee3\u7801\u6211\u6574\u7406\u6210\u4e86\u4e00\u4e2a demo\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u4f7f\u7528\u5305\u542b\u6f0f\u6d1e\u7684\u7248\u672c\uff0c\u57fa\u4e8e SpringBoot-2.1.7.RELEASE\u3001Spring-xxx-5.1.9.RELEASE \u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;parent&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n    &lt;version&gt;2.1.7.RELEASE&lt;\/version&gt;\n    &lt;relativePath\/&gt;\n&lt;\/parent&gt;\n&lt;dependencies&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n&lt;\/dependencies&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u590d\u73b0\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>spring.mvc.pathmatch.use-suffix-pattern=true\nspring.mvc.contentnegotiation.favor-path-extension=true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u590d\u73b0\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Controller\n@RequestMapping(value = \"spring\")\npublic class cve20205421 {\n\n    \/\/ localhost:8080\/spring\/input?input=hello\n    @RequestMapping(\"input\")\n    @ResponseBody\n    public String input(String input){\n        return input;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u4ee5\u4e0a\u4ee3\u7801\uff0c\u5728 url \u4e2d\u6dfb\u52a0<code>;jsessionid=<\/code>\u3002\u5982<code>http:\/\/localhost:8080\/spring\/;jsessionid=\/\u4e1a\u4f59\u8349.bat?input=calc<\/code>\uff0c\u5c31\u4f1a\u4e0b\u8f7d\u540d\u4e3a<code>\u4e1a\u4f59\u8349.bat<\/code>\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">OK\uff0c\u524d\u9762\u626f\u4e86\u90a3\u4e48\u591a\uff0c\u90fd\u662f\u6ca1\u7528\u4e86\u3002\u6700\u4e3b\u8981\u7684\u8fd8\u662f\u4fee\u590d\u65b9\u6848\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u590d\u65b9\u6848\u4e00\u5171\u6709 3 \u79cd\u3002\u65b9\u6848\u4e00\uff1a\u628a\u4e0a\u9762\u7684\u590d\u73b0\u914d\u7f6e\u5168\u90e8\u6539\u4e3a false\u3002\u5982\u679c\u8fd9\u4e00\u6b65\u4f60\u505a\u4e0d\u5230\uff0c\u90a3\u5c31\u91c7\u7528\u65b9\u6848\u4e8c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65b9\u6848\u4e8c\uff1a\u5347\u7ea7 jar \u5305\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/xmt1139057136\/xttblog\/2021\/08\/cve4.png\" alt=\"Spring\u5347\u7ea7jar\u5305\" \/><figcaption>Spring\u5347\u7ea7jar\u5305<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728 Spring \u7684\u7248\u672c\u57fa\u672c\u4e0a\u90fd\u88ab\u5176\u4ed6\u7b2c\u4e09\u65b9\u7684 jar \u5f3a\u4f9d\u8d56\u3002\u4e0d\u5efa\u8bae\u8fdb\u884c\u5927\u7248\u672c\u7684\u5347\u7ea7\uff0c\u6240\u4ee5\uff0c\u5efa\u8bae\u8fd8\u662f\uff0c5.x \u7684\u5347\u7ea7 5.x \u7684\u6700\u65b0\u7248\uff1b4.x \u5347\u7ea7\u5230 4.x \u7684\u6700\u65b0\u7248\uff1b3.x \u4e5f\u5347\u7ea7\u5230 3.x \u7684\u6700\u65b0\u7248\u3002\u4f4e\u4e8e 3.x \u7248\u672c\u7684\uff0c\u90a3\u53ea\u80fd\u6539\u4ee3\u7801\u91cd\u65b0\u7f16\u8bd1\u4e86\uff0c\u56e0\u4e3a 3.x \u4ee5\u4e0b\u7684\u7248\u672c\uff0c\u5b98\u65b9\u90fd\u4e0d\u5728\u7ef4\u62a4\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Spring \u7248\u672c\u5347\u7ea7\uff0c\u6839\u636e Maven \u7684\u4f9d\u8d56\u6700\u77ed\u8def\u5f84\u4f18\u5148\u539f\u5219\uff0c\u5206\u5206\u949f\u641e\u5b9a\u3002\u5982\u6709\u4e0d\u4f1a\u7684\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1\uff1acodedq\uff0c\u514d\u8d39\u6559\u5b66\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u590d\u65b9\u6848\u4e09\uff1a\u6dfb\u52a0\u5b89\u5168\u8fc7\u6ee4\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class SpringJsessionidRdfFilter implements Filter {\n\n    private final Set&lt;String&gt; safeExtensions = new HashSet&lt;&gt;();\n    \/* Extensions associated with the built-in message converters *\/\n    private static final Set&lt;String&gt; WHITELISTED_EXTENSIONS = new HashSet&lt;&gt;(Arrays.asList(\n            \"txt\", \"text\", \"yml\", \"properties\", \"csv\",\n            \"json\", \"xml\", \"atom\", \"rss\",\n            \"png\", \"jpe\", \"jpeg\", \"jpg\", \"gif\", \"wbmp\", \"bmp\"));\n\n    @Override\n    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {\n        HttpServletRequest request = (HttpServletRequest)servletRequest;\n        HttpServletResponse response = (HttpServletResponse)servletResponse;\n\n        String contentDisposition = response.getHeader(HttpHeaders.CONTENT_DISPOSITION);\n        if (!\"\".equals(contentDisposition)&amp;&amp;null != contentDisposition) {\n            return;\n        }\n\n        try {\n            int status = response.getStatus();\n            if (status &lt; 200 || status &gt; 299) {\n                return;\n            }\n        }\n        catch (Throwable ex) {\n            \/\/ ignore\n        }\n\n        String requestUri = request.getRequestURI();\n\n        System.out.println(requestUri);\n\n        if(requestUri.contains(\";jsessionid=\")){\n            int index = requestUri.lastIndexOf('\/') + 1;\n            String filename = requestUri.substring(index);\n            String pathParams = \"\";\n\n            index = filename.indexOf(';');\n            if (index != -1) {\n                pathParams = filename.substring(index);\n                filename = filename.substring(0, index);\n            }\n\n            UrlPathHelper decodingUrlPathHelper = new UrlPathHelper();\n            filename = decodingUrlPathHelper.decodeRequestString(request, filename);\n            String ext = StringUtils.getFilenameExtension(filename);\n\n            pathParams = decodingUrlPathHelper.decodeRequestString(request, pathParams);\n            String extInPathParams = StringUtils.getFilenameExtension(pathParams);\n\n            if (!safeExtension(request, ext) || !safeExtension(request, extInPathParams)) {\n                response.addHeader(HttpHeaders.CONTENT_DISPOSITION, \"inline;filename=f.txt\");\n            }\n        }\n        filterChain.doFilter(servletRequest,servletResponse);\n    }\n\n    private boolean safeExtension(HttpServletRequest request, @Nullable String extension) {\n        if (!StringUtils.hasText(extension)) {\n            return true;\n        }\n        extension = extension.toLowerCase(Locale.ENGLISH);\n        this.safeExtensions.addAll(WHITELISTED_EXTENSIONS);\n        if (this.safeExtensions.contains(extension)) {\n            return true;\n        }\n        String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);\n        if (pattern != null &amp;&amp; pattern.endsWith(\".\" + extension)) {\n            return true;\n        }\n        if (extension.equals(\"html\")) {\n            String name = HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE;\n            Set&lt;MediaType&gt; mediaTypes = (Set&lt;MediaType&gt;) request.getAttribute(name);\n            if (!CollectionUtils.isEmpty(mediaTypes) &amp;&amp; mediaTypes.contains(MediaType.TEXT_HTML)) {\n                return true;\n            }\n        }\n        return false;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5fc3\u539f\u7406\u5c31\u662f\uff1a<code>\u89e3\u6790 url\u4e2d\u7684\u6700\u540e\u4e00\u8282(\u6700\u540e\u4e00\u4e2a'\/'\u4e4b\u540e\u7684\u5185\u5bb9')\uff0c\u5982\u679c\u5b58\u5728\u6587\u4ef6\u540d\u79f0\uff0c\u53d6\u5f97\u5176\u6269\u5c55\u540d\u3002\u5982\u679c\u4e0d\u662f\u5982\u4e0b\u7684\u767d\u540d\u5355\u4e2d\u7684\u7c7b\u578b\uff0c\u5c31\u5728\u5934\u4fe1\u606f\u4e2d\u8bbe\u7f6e<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"Content-Disposition:\u00a0inline;filename=f.txt\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ba9\u5176\u4ee5\u56fa\u5b9a\u7684\u6587\u4ef6\u540d\u79f0 f.txt \u4e0b\u8f7d\uff0c\u4ee5\u907f\u514d\u51fa\u73b0\u4e0d\u53d7\u63a7\u5236\u7684\u6587\u4ef6\u7c7b\u578b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9650\u5236\u6587\u4ef6\u7c7b\u578b\u767d\u540d\u5355\u4e3a\uff1a&#8221;txt&#8221;, &#8220;text&#8221;, &#8220;json&#8221;, &#8220;xml&#8221;, &#8220;atom&#8221;, &#8220;rss&#8221;, &#8220;png&#8221;, &#8220;jpe&#8221;, &#8220;jpeg&#8221;, &#8220;jpg&#8221;, &#8220;gif&#8221;, &#8220;wbmp&#8221;, &#8220;bmp&#8221;\uff0c\u4e0d\u5728\u767d\u540d\u5355\u5185\u7684\u5c31\u88ab\u62e6\u622a\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=5261\">Spring\u8fde\u73af\u6f0f\u6d1eCVE-2015-5211\u548cCVE-2020-5421\u4fee\u590d\u5347\u7ea7\u6559\u7a0b\uff01<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u4e0d\u9020\u8f6e\u5b50\uff0c\u4f46\u9700\u8981\u5b66\u4f1a\u4fee\u590d\u8f6e\u5b50\uff01 \u5bf9\u4e8e\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u591a\u6570\u7a0b\u5e8f\u5458\u4f1a\u70b9 Star\uff0c\u5c11\u6570\u7a0b\u5e8f\u5458\u4f1a Fork\uff0c\u53ea\u6709\u6781 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[551,1522,354,210,803],"class_list":["post-5261","post","type-post","status-publish","format-standard","hentry","category-java","tag-spring","tag-springboot","tag-sql","tag-struts2","tag-803"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5261"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5261\/revisions"}],"predecessor-version":[{"id":5262,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5261\/revisions\/5262"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}