防止使用 url 重定向 [英] Prevent redirection using url

查看:64
本文介绍了防止使用 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.com/test.action?redirect:google.com/? 这样的 URL 时,它会重定向到 google.com.

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

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

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 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆