问题的复盘

首先这个问题出现的时机是,当用户访问特定的连接(如http://localhost/index)时没有权限,被重定向到登录页面http://localhost/login。为了登录成功后再跳转到目标访问的页面http://localhost/index,Spring Security会在Cookie中存一个信息,标记一为一个jsessionid。重定向时Servlet容器,也就是tomcat之类的会把jsessionid编码到重定向url,也就是http://localhost/login;jsessionid=xxxxxxxxxx。这种请求会被Spring Security的StrictHttpFirewall拦截,引发进而The request was rejected because the URL contained a potentially malicious String ";"错误。

安全策略

OWASP指出在URL中暴露jsessionid是非常危险的举动,可能导致会话固定攻击,因此不建议上述的行为。

解决方案

目前有两种解决方案。

允许url携带jsessionid

这种在网上很多,如果浏览器的cookie被禁用或者你的应用可以容忍上述安全漏洞你可以在Spring Security中采取这种方式:

httpSecurity.sessionManagement().enableSessionUrlRewriting(true);

这种不建议使用。

修改servlet容器的会话机制

在 Spring Boot 中配置 Tomcat 的跟踪模式:

server.servlet.session.tracking-modes=cookie

先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦

The request was rejected because the URL contained a potentially malicious String “;“问题的正确解决姿势相关推荐

  1. The request was rejected because the URL contained a potentially malicious String “//“

    报错详情 org.springframework.security.web.firewall.RequestRejectedException: The request was rejected be ...

  2. The request was rejected because the URL contained a potentially malicious String “%2e“

    日志出现: [http-nio-80-exec-3] ERROR o.a.c.c.C.[.[localhost].[/].[dispatcherServlet] - Servlet.service() ...

  3. The request was rejected because the URL contained a potentially malicious String “//“ 报错

    控制台报错 请求将被拒绝,因为URL字符串包含一个潜在的恶意"/ /" The request was rejected because the URL contained a p ...

  4. SpringSecurity:request was rejected because the URL contained a potentially malicious String “//“

    问题描述 项目发布时候,权限校验发生了问题,登录接口报错'用户未授权',其实就是登录接口也被拦截器拦掉了,本地是没有问题的,估计是代理的问题,查看服务器日志如下: org.springframewor ...

  5. The request was rejected because the URL contained a potentially malicious String ;报错解决

    报错信息 浏览器中看到的报错 错误摘要: The request was rejected because the URL contained a potentially malicious Stri ...

  6. springboot学习(七十一)解决问题:the URL contained a potentially malicious String “;“

    访问某个请求报错: org.springframework.security.web.firewall.RequestRejectedException: The request was reject ...

  7. the URL contained a potentially malicious String “//“

    这个问题是因为前端的请求url后面多加了一个斜杠,把后面的斜杠删了就行, 正确的: 错误的:

  8. web.firewall.RequestRejectedException: The request was rejected because the URL contained a potentia

    spring security 自带url 校验失败 因为请求的url不合法,但是对接方又不能修改,只能平台适配 org.springframework.security.web.firewall.R ...

  9. SpringBoot整合升级Spring Security 报错 【The request was rejected because the URL was not normalized】...

    前言 最近LZ给项目框架升级, 从Spring1.x升级到Spring2.x, 在这里就不多赘述两个版本之间的区别以及升级的原因. 关于升级过程中踩的坑,在其他博文中会做比较详细的记录,以便给读者参考 ...

最新文章

  1. 程序中下载采购申请的附件
  2. PyInstaller库函数
  3. 从搜索引擎到核心交易数据库,详解阿里云神龙如何支撑双11
  4. 通过jQuery源码学习javascript(三)
  5. 剑指offer-面试题13.在O(1)时间删除链表节点
  6. 1.Python基础----认识环境
  7. 今天,我需要你的支持!
  8. 基于GAN的手写数字生成实践
  9. [Vmware卸载] Vmware12卸载
  10. oracle导出导入同义词,oracle同义词语句备份
  11. html 阴历阳历转换,本人花了一个星期的时间,使用ASP代码获得公历并转换成农历时间(2021年至2100年)...
  12. oracle北京时区,Oracle 时区 - Amazon Relational Database Service
  13. DES的s盒输出CPA和DPA攻击
  14. oracle中删除级联方法,Oracle 外键级联删除
  15. int... num什么意思?
  16. 【练习/Python】监测汇率脚本
  17. MySql只能用localhsot或者127.0.0.1连接
  18. 威霆商务车改装独特的爱马仕橙+磨砂黑的搭配
  19. stm8L051低功耗采集电池电量ADC例程
  20. vggNet网络学习(网络架构及代码搭建)

热门文章

  1. 从G1到冻酸奶Froyo
  2. Failed to connect to github-production-release-asset-2e65be.s3.amazonaws.com port 443: Timed out
  3. RabbitMQ安装流程
  4. drozer安装之夜深模拟器
  5. Python基础2——open函数
  6. C++设计模式——装饰着模式(高屋建瓴)
  7. Android支付接入(七):Googlenbsp;In-app-Billing
  8. 向国外发送邮件用什么邮箱?
  9. 基于CommonsCollections4的Gadget分析
  10. 计算机主机里四大件,电脑的四大件是什么