【问题标题】:Spring Security SAML replay attack preventionSpring Security SAML 重放攻击防范
【发布时间】:2024-01-03 05:42:01
【问题描述】:

如 OASIS 安全断言标记语言 (SAML)V2.0 (https://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf) 的配置文件第 4.1.4.5 章中所述,服务提供者必须通过在断言执行期间为已处理断言保留缓存来防止重放攻击没有过期。

我知道 OpenSAML 通过提供安全策略和针对重放的缓存实现来支持防止重放攻击,但是我在 Spring SAML 的任何地方都找不到这些实现的用法。我希望 WebSSOProfileConsumer 能够提供这样的功能。谁能指出我在哪里(如果有的话)可以找到这种行为的正确方向吗?

【问题讨论】:

    标签: spring spring-security spring-saml spring-security-saml2


    【解决方案1】:

    我在 Spring SAML 中没有看到任何开箱即用的东西。我们需要从应用程序中做到这一点。 需要通过存储断言的 id 并检查新断言是否具有相同的 id 来防止重放攻击。 您可以使用

    获取 ID
    org.opensaml.saml2.core.Assertion.getID(); 
    

    【讨论】:

    • 感谢您的回答。我知道可以为自定义解决方案检索 I,但我希望 Spring 安全性能够提供此功能,因为它是由规范强制执行的。我必须使用 Spring 的 org.springframework.security.web.authentication.session.SessionAuthenticationStrategy 来解决它,它可以在 SAML 处理过滤器上设置。