File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
src/main/java/org/joychou/controller Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 3131- [ XXE] ( https://github.com/JoyChou93/java-sec-code/wiki/XXE )
3232- [ SQLI] ( https://github.com/JoyChou93/java-sec-code/wiki/SQL-Inject )
3333- [ Fastjson] ( https://github.com/JoyChou93/java-sec-code/wiki/Fastjson )
34+ - [ CORS] ( https://github.com/JoyChou93/java-sec-code/wiki/CORS )
3435- [ Others] ( https://github.com/JoyChou93/java-sec-code/wiki/others )
3536
3637
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public class CORS {
2626 *
2727 * @param request
2828 * @param response
29- * @desc: 当origin为空,即直接访问的情况下,response的header中不会出现Access-Control-Allow-Origin
29+ * @desc https://github.com/JoyChou93/java-sec-code/wiki/CORS
3030 */
3131 @ RequestMapping ("/vuls1" )
3232 @ ResponseBody
@@ -61,7 +61,16 @@ private static String vuls3(HttpServletResponse response) {
6161 private static String seccode (HttpServletRequest request , HttpServletResponse response ) {
6262 String origin = request .getHeader ("Origin" );
6363 Security sec = new Security ();
64- if (!sec .checkSafeUrl (origin , urlwhitelist )) {
64+ Boolean origin_safe = false ;
65+
66+ // 如果origin为空,表示是同域过来的请求或者浏览器直接发起的请求,这种直接放过,没有安全问题。
67+ if (origin == null ) {
68+ origin_safe = true ;
69+ }else if (sec .checkSafeUrl (origin , urlwhitelist )) {
70+ origin_safe = true ;
71+ }
72+
73+ if (!origin_safe ) {
6574 return "Origin is not safe." ;
6675 }
6776 response .setHeader ("Access-Control-Allow-Origin" , "*" );
You can’t perform that action at this time.
0 commit comments