【问题标题】:How to block El-Tags in my JAVA tomcat web application如何在我的 JAVA tomcat Web 应用程序中阻止 El-Tags
【发布时间】:2014-02-10 13:01:55
【问题描述】:

我在我的 Java Tomcat 应用程序中遇到了 EL(表达式语言)注入问题。 我试图在 web.xml 文件中解决它:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>true</el-ignored>
         <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
</jsp-config>

以及以下文章中的建议: https://www.aspectsecurity.com/uploads/downloads/2012/12/Remote-Code-with-Expression-Language-Injection.pdf

<context-param> 
 <description>Spring Expression Language Support</description> 
 <param-name>springJspExpressionSupport</param-name> 
 <param-value>false</param-value> 
</context-param>

但是它们似乎都不起作用。 我已经使用以下 .jsp 文件对其进行了测试:

request param is: ${param.name} 

并输入网址:

http://<myURL>/<myPath>/test.jsp?name=blablabla

屏幕的输出是

request param is: blablabla

虽然我期待它是:

request param is: ${param.name}

在我改变之后。 有什么建议吗?

【问题讨论】:

  • 根据文档,问题是当您的参数中有 el 时会被评估。你展示的情况是完全正常的。而且,imo,完全禁用 el 只是错过了很多有用的功能

标签: java jsp tomcat el jsp-tags


【解决方案1】:

问题解决了。万一将来有人遇到它: 解决方法是在web.xml中添加:

<jsp-config>
    <!-- Set to true to disable JSP scripting syntax -->
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
    <!-- Set to true to disable Expression Language (EL) syntax -->
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <el-ignored>true</el-ignored>
    </jsp-property-group>
</jsp-config>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 2013-12-03
    • 2016-04-11
    • 2011-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多