【问题标题】:Determine ESAPI Configuration Properties without Access to Deployment Environment?在不访问部署环境的情况下确定 ESAPI 配置属性?
【发布时间】:2017-11-04 10:52:32
【问题描述】:

我们最近首次对我们的 Java Spring 应用程序运行 Veracode 扫描,发现了许多安全漏洞,我们可以确定的最佳解决方案是通过 ESAPI 对用户输入进行编码。

在这种情况下,因为已被询问,“用户输入”意味着,例如,来自 cookie 的 GUID,但 Veracode 认识到 cookie 可以被伪造,因此需要对 cookie 内容进行清理......即,使用 ESAPI 编码功能如下:

logger.debug("Attempting to broadcast message to all connections with GUID " + ESAPI.encoder().encodeForHTML(guid));

我们使用的是 Maven,所以为了在我们的项目中包含 ESAPI,我们所做的只是在我们的 POM 文件中:

<dependency>
  <groupId>org.owasp.esapi</groupId>
  <artifactId>esapi</artifactId>
  <version>2.0.1</version>
</dependency>

而且它“刚刚奏效”。除了开始使用 import org.owasp.esapi.ESAPI; 之外,我们实际上什么也没做,然后我们去了城里,在本地测试中表现出色。

但是,一旦我们开始部署,它就失败了:

org.owasp.esapi.errors.ConfigurationException: java.lang.reflect.InvocationTargetException SecurityConfiguration class (org.owasp.esapi.reference.DefaultSecurityConfiguration) CTOR threw exception.
    at org.owasp.esapi.util.ObjFactory.make(ObjFactory.java:129) ~[esapi-2.0.1.jar:2.0.1]
    at org.owasp.esapi.ESAPI.securityConfiguration(ESAPI.java:184) ~[esapi-2.0.1.jar:2.0.1]
    at org.owasp.esapi.ESAPI.encoder(ESAPI.java:99) ~[esapi-2.0.1.jar:2.0.1]

我们无权访问部署环境,因为第三方对其进行管理。报告类似问题的其他 StackOverflow 问题报告说,他们的问题的答案涉及缺少 ESAPI.properties 文件。在我们的本地开发和测试中,我们不需要担心类似的事情,但我担心其他人报告需要设置一个/设置一个路径。

在我们的代码中(这是我们真正提供给部署团队的全部)有什么方法可以确保 ESAPI 将在部署环境中运行?

【问题讨论】:

  • 为您的问题增加了清晰度和答案。
  • 首先,2.0.1 存在与加密相关的安全漏洞。您应该使用 2.1.0.1

标签: java spring maven configuration esapi


【解决方案1】:

实际上,SO 的大多数其他问题都可以为您提供答案。这是代码中的注释:

/**
 * The reference {@code SecurityConfiguration} manages all the settings used by the ESAPI in a single place. In this reference
 * implementation, resources can be put in several locations, which are searched in the following order:
 * <p>
 * 1) Inside a directory set with a call to SecurityConfiguration.setResourceDirectory( "C:\temp\resources" ).
 * <p>
 * 2) Inside the System.getProperty( "org.owasp.esapi.resources" ) directory.
 * You can set this on the java command line as follows (for example):
 * <pre>
 *      java -Dorg.owasp.esapi.resources="C:\temp\resources"
 * </pre>
 * You may have to add this to the start-up script that starts your web server. For example, for Tomcat,
 * in the "catalina" script that starts Tomcat, you can set the JAVA_OPTS variable to the {@code -D} string above.
 * <p>
 * 3) Inside the {@code System.getProperty( "user.home" ) + "/.esapi"} directory (supported for backward compatibility) or
 * inside the {@code System.getProperty( "user.home" ) + "/esapi"} directory.
 * <p>
 * 4) The first ".esapi" or "esapi" directory on the classpath. (The former for backward compatibility.)
 * <p>
 * Once the Configuration is initialized with a resource directory, you can edit it to set things like master
 * keys and passwords, logging locations, error thresholds, and allowed file extensions.
 * <p>
 * WARNING: Do not forget to update ESAPI.properties to change the master key and other security critical settings.
 *
 * @author Jeff Williams (jeff.williams .at. aspectsecurity.com) <a href="http://www.aspectsecurity.com">Aspect Security</a>
 * @author Jim Manico (jim .at. manico.net) <a href="http://www.manico.net">Manico.net</a>
 * @author Kevin Wall (kevin.w.wall .at. gmail.com)
 */

在您的情况下,对于将运行您的 Web 应用程序的部署命令,请根据此处第 2 节中列出的 java 运行时属性为部署团队提供一个目录。他们需要将其添加到任何触发了启动 Web 容器的脚本/命令中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 2020-05-26
    • 2014-12-01
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 2017-05-06
    相关资源
    最近更新 更多