Spring Security SAML 和本周的 SAML 漏洞

工程 | Rob Winch | 2018 年 3 月 1 日 | ...

本周,软件世界发现 SAML 漏洞影响多个实现。如果您使用 Spring Security SAML 的默认设置,您不会受到此漏洞的影响。

Spring Security SAML 使用的底层实现是 Shibboleth 的 OpenSAML Java 库。 OpenSAML Java 实现未在包含漏洞的库中列出(Shibboleth openSAML C ++容易受到攻击)。但是,如果 ParserPool 已被自定义,您可能会受到影响。

不安全配置

具体来说,如果应用程序显式设置 BasicParserPoolStaticBasicParserPool 以使 ignoreComments = false,则它容易受到攻击。例如,以下配置容易受到攻击

使用 StaticBasicParserPool 的不安全 Java 配置

// NOT secure!!!
@Bean(initMethod = "initialize")
ParserPool parserPool() {
    StaticBasicParserPool pool = new StaticBasicParserPool();
    // DO NOT set ignoreComments = false opens up exploit
    pool.setIgnoreComments(false);
    return pool;
}

使用 BasicParserPool 的不安全 Java 配置

// NOT secure!!!
@Bean
ParserPool parserPool() {
    BasicParserPool pool = new BasicParserPool();
    // DO NOT set ignoreComments = false opens up exploit
    pool.setIgnoreComments(false);
    return pool;
}

使用 StaticBasicParserPool 的不安全 XML 配置

<!-- NOT secure!!! -->
<bean id="parserPool" init-method="initialize"
           class="org.opensaml.xml.parse.StaticBasicParserPool">
    <!-- DO NOT set ignoreComments = false opens up exploit -->
    <property name="ignoreComments" value="false"/>
</bean>

使用 BasicParserPool 的不安全 XML 配置

<!-- NOT secure!!! -->
<bean id="parserPool" class="org.opensaml.xml.parse.BasicParserPool">
    <!-- DO NOT set ignoreComments = false opens up exploit -->
    <property name="ignoreComments" value="false"/>
</bean>

安全配置

以下配置是安全的

使用 StaticBasicParserPool 的安全 Java 配置

@Bean(initMethod = "initialize")
ParserPool parserPool() {
    StaticBasicParserPool pool = new StaticBasicParserPool();
    // ignoreComments default is true (safe)
    return pool;
}

使用 BasicParserPool 的安全 Java 配置

@Bean(initMethod = "initialize")
ParserPool parserPool() {
    BasicParserPool pool = new BasicParserPool();
    // ignoreComments default is true (safe)
    return pool;
}

使用 StaticBasicParserPool 的安全 XML 配置

<bean id="parserPool" class="org.opensaml.xml.parse.StaticBasicParserPool">
    <!-- ignoreComments default is true (safe) -->
</bean>

使用 BasicParserPool 的安全 XML 配置

<bean id="parserPool" init-method="initialize"
           class="org.opensaml.xml.parse.BasicParserPool">
    <!-- ignoreComments default is true (safe) -->
</bean>

不安全的 PaserPool 配置

现在可能是查看其他 不安全配置的好时机。具体来说,以下 ParserPool 属性是不安全的

  • expandEntityReferences 设置为 true 是不安全的。

  • javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING 设置为 false 是不安全的。

  • [https://apache.ac.cn/xml/features/disallow-doctype-dec](https://apache.ac.cn/xml/features/disallow-doctype-dec) 设置为 false 是不安全的。 这是一个 Xerces 特定的功能,包括诸如 Oracle 和 OpenJDK JRE 提供的内部 JAXP 实现之类的衍生物。 对于其他 JAXP 实现,请阅读特定实现的文档,以了解如何实现类似的配置。

  • ignoreComments 设置为 false 是不安全的(如本文中所述)

获取 Spring 新闻简报

通过 Spring 新闻简报保持联系

订阅

领先一步

VMware 提供培训和认证,以加速您的进步。

了解更多

获取支持

Tanzu Spring 在一个简单的订阅中提供对 OpenJDK™,Spring 和 Apache Tomcat® 的支持和二进制文件。

了解更多

即将到来的活动

查看 Spring 社区中所有即将到来的活动。

查看所有