【问题标题】:How to prevent the wildcard namespace in struts?如何防止struts中的通配符命名空间?
【发布时间】:2013-07-17 04:08:57
【问题描述】:

我遇到了一个问题,我在以下情况下无法找到关键字:

<package name="Main" namespace="/" extends="struts-default">
    <action name="administrator" class="com.xyz.AdminAction">
        <result name="success">/WEB-INF/jsp/admin.jsp</result>
    </action>
</package>

上面的 url 应该是 http://xyz.com/administrator 并且可以正常工作。但是,如果我将 url 更改为 http://xyz.com/asdasd/asdasdasd/administrator 并且它仍然有效,但我不能接受这个!那么任何只告诉struts http://xyz.com/administrator 的设置都被接受了吗?谢谢!

【问题讨论】:

  • 当心。如果您以这种特殊方式配置了 Struts 应用程序(将“alwaysSelectFullNamespace”设置为“true”),您的应用程序很可能容易受到 CVE-2018-11776 的攻击:semmle.com/news/apache-struts-CVE-2018-11776

标签: struts2 struts2-namespace


【解决方案1】:

alwaysSelectFullNamespace 属性设置为true

来自struts-default.properties

### Whether to always select the namespace to be everything before the last slash or not
struts.mapper.alwaysSelectFullNamespace=true

XML 配置是首选,所以在你的struts.xml:

<struts>
  <constant name="struts.mapper.alwaysSelectFullNamespace" value="true" />
  ...

【讨论】:

    猜你喜欢
    • 2018-03-09
    • 2018-07-31
    • 2014-03-31
    • 1970-01-01
    • 1970-01-01
    • 2021-03-28
    • 1970-01-01
    • 2021-10-16
    • 2021-09-28
    相关资源
    最近更新 更多