防止使用 url 重定向

编程入门 行业动态 更新时间:2024-10-07 20:34:45
本文介绍了防止使用 url 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用 Java Struts 2 编写的应用程序.我们检测到一个开放重定向漏洞.

I have an application written in Java Struts 2. We detected an open redirect vulnerability.

当网页通过用户控制的输入被重定向到另一个域中的另一个 URL 时,就会发生开放重定向.

Open redirect occurs when a web page is being redirected to another URL in another domain via a user-controlled input.

例如:当我们尝试像 myapp.abc/test.action?redirect:google/? 这样的 URL 时,它会重定向到 google.

For example: when we try URL like myapp.abc/test.action?redirect:google/?, it redirects to google.

出于安全考虑,我需要阻止这种情况.它不应重定向到除我们的域之外的任何其他域.如何防止此类攻击?

I need to prevent this for security concerns. It should not redirect to any other domain except our domain. How do I prevent this type of attack?

推荐答案

重定向参数被 S2-016.

如果你仍然使用它,那么你应该通过请求手动解析参数.

If you still use it then you should parse parameters manually via the request.

可能您需要了解Struts2 如何处理来自 URL 的请求参数.

由于特殊参数由 ActionMapper 处理.并且默认实现用于删除易受攻击的参数,然后您需要编写自定义操作映射器.

Since the special parameters are handled by the ActionMapper. And default implementation is used to remove vulnerable parameters then you need to write a custom action mapper.

要使用带有 struts 的自定义动作映射器,您需要通过配置它

To use custom action mapper with struts you need to configure it via

constant name="struts.mapper.class" value="restaurants" />

更多推荐

防止使用 url 重定向

本文发布于:2023-10-10 18:25:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479372.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!