freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

SilverSamlForger:一款针对Silver SAML的安全研究工具
Alpha_h4ck 2024-12-19 14:21:18 89241
所属地 广西

关于SilverSamlForger

SilverSamlForger是一款针对Silver SAML的安全研究工具,该工具可以帮助广大研究人员创建自定义 SAML 响应,并可用于研究和分析 Silver SAML 威胁。

工具要求

C#

Visual Studio

工具安装

广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

git clone https://github.com/Semperis/SilverSamlForger.git

然后打开Visual Studio,将项目导入并针对不同的操作系统平台进行代码构建即可。

工具使用

组织可以监控 Entra ID 审计日志,以了解 ApplicationManagement 下 PreferredTokenSigningKeyThumbprint 的更改。我们需要将这些事件与与服务主体相关的添加服务主体凭据事件关联起来,其中过期证书的轮换是一个常见的过程,因此我们需要确定审计事件是否合法。除此之外,还可以实施变更控制流程来记录轮换有助于最大限度地减少轮换事件期间的混乱。

该工具需要一组参数才能生成 SAML 响应。有两个选项可用:

1、手动传递参数;

2、使用一个JSON文件传递参数;

支持传递的参数如下:

--pfxFile  - 指定 pfx 文件的路径。

--pfxPassword  - 指定 pfx 文件的密码。

--idpid  - 身份提供者标识符。

--recipient  - SAML 响应中的接收者。

--subjectnameid  - SAML 响应中的 subjectNameID。

--audience - SAML 响应中的接收方。

--attributes- SAML 响应中断言内的属性/声明,采用键、值格式。

运行示例:

SilverSAMLForger.exe generate --pfxPath C:\path\to\certificate.pfx --pfxPassword mycertpassword --idpid https://myidpid.com --recipient https://thesamlrecipient.com/sso/saml2/random --subjectnameid target@target.com --audience https://someaudience.com/saml2/service-provider/example --attributes http://schemas.microsoft.com/identity/claims/tenantid=<tenantID>,http://schemas.microsoft.com/identity/claims/objectidentifier=<objectID>,http://schemas.microsoft.com/identity/claims/displayname=<displayName>,http://schemas.microsoft.com/identity/claims/identityprovider=<identityProviderID>,http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress=<targetEmail>,http://schemas.microsoft.com/claims/authnmethodsreferences=http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password,http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname=<GivenName>,http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname=<SurName>,<AnythingYouWant>=<AnyValue>

生成的JSON样例文件

{

    "pfxPath": "C:\\Path:\\To\\Certificate.pfx",

    "pfxPassword": "<Password>",

    "idpid": "<IdpId>",

    "recipient": "<Recipient>",

    "subjectnameid": "<SubjectNameID>",

    "audience": "<Audience>",

    "attributes": {

        "http://schemas.microsoft.com/identity/claims/tenantid": "<TetnantID>",

        "http://schemas.microsoft.com/identity/claims/objectidentifier": "<ObjectID>",

    "http://schemas.microsoft.com/identity/claims/displayname": "<DisplayName>",

        "http://schemas.microsoft.com/identity/claims/identityprovider": "<IdPID",

        "http://schemas.microsoft.com/claims/authnmethodsreferences": "http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/password",

        "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname": "<GivenName>",

        "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname": "<SurName>",

        "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress": "<Email>",

        "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name": "<Name>"

    "<Anything>" : "<Anything>"

    

}

使用 generateJSON 命令,我们可以生成一个 SAML 响应,该响应从 json 中加载参数。它需要按如下方式构建:

SilverSAMLForger.exe generateJSON --jsonFile path_to_json_file.json

输出是 base64 和 URL 编码的 SAML 响应。

工具输出结果

安全防御建议

为了有效防范 Entra ID 中的 Silver SAML 攻击,组织应仅将 Entra ID 签名证书用于 SAML 签名目的。其中,SAML 签名证书存储在 Entra ID 中 SAML 应用程序的服务主体中。我们可以使用 Microsoft Graph API 查看有关签名密钥公开的信息,只需向以下 URI 发出 GET 请求即可:

https: //graph.microsoft.com/beta/servicePrincipals/{serviceprincipalobjectid}

组织可以审核 SAML 配置的现有服务主体并检查 displayName。如果当前使用的证书是由 Microsoft 生成的,则该证书将包含值 CN=Microsoft Azure Federated SSO Certification。

暴露信息示例

请注意,私钥材料需要设置为不可导出,这样才可以阻止威胁行为者者收集发起 Silver SAML 攻击所需的信息。

{

            "customKeyIdentifier": "Gk//vUF/JYC58HRyyuGMM5ydmOuJVUL74R6OszKQn6w=",

            "endDateTime": "2026-08-08T14:19:35Z",

            "keyId": "66ad0fe4-111d-45da-924c-545913d77be9",

            "startDateTime": "2023-08-08T14:19:36Z",

            "type": "AsymmetricX509Cert",

            "usage": "Sign",

            "key": null,

            "displayName": "CN=Microsoft Azure Federated SSO Certificate",

            "hasExtendedValue": null

        }

许可证协议

本项目的开发与发布遵循MIT开源许可协议。

项目地址

SilverSamlForger:【GitHub传送门

参考资料

https://www.semperis.com/blog/meet-silver-saml/

https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps

# 安全研究 # 威胁检测 # SAML # 威胁分析
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 Alpha_h4ck 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
Alpha_h4ck LV.10
好好学习,天天向上
  • 2359 文章数
  • 1024 关注者
Tetragon:一款基于eBPF的运行时环境安全监控工具
2025-01-21
DroneXtract:一款针对无人机的网络安全数字取证工具
2025-01-21
CNAPPgoat:一款针对云环境的安全实践靶场
2025-01-21
文章目录