{"id":460763,"date":"2025-05-23T15:00:09","date_gmt":"2025-05-23T15:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=460763"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=460763","title":{"rendered":"<span>DASTing SAML: Breaking Trust, One Assertion at a Time<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>My name is Ilya and I\u2019m a Core Developer at Bright Security. In Bright we work on a DAST (Dynamic Application Security Testing) solution that helps development teams find and fix vulnerabilities early, straight from CI\/CD. My own path began in full-stack engineering, but almost a decade of shipping production code drew me ever deeper into application security. In this article I\u2019m explaining key approaches on what SAML actually is and how we detect it in Bright using DAST.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/795\/554\/a0d\/795554a0d0c51217539227819b4f6d70.png\" width=\"780\" height=\"440\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/795\/554\/a0d\/795554a0d0c51217539227819b4f6d70.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/795\/554\/a0d\/795554a0d0c51217539227819b4f6d70.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>What is SAML (Security Assertion Markup Language)?<\/h2>\n<p>Let\u2019s start with the definition even though I\u2019m quite certain you know it if you\u2019re reading this article. SAML (Security Assertion Markup Language) is an XML-based standard for exchanging authentication and authorization data between different security domains, typically an Identity Provider (IdP) and a Service Provider (SP).<\/p>\n<h4>Where You&#8217;ll See SAML in Action<\/h4>\n<ol>\n<li>\n<p><strong>Enterprise Single Sign-On (SSO):<\/strong> inside companies, employees often log in once and then can access email, CRM, cloud tools, etc., without having to authenticate again. That\u2019s SAML making life easier behind the scenes.<\/p>\n<\/li>\n<li>\n<p><strong>Federated Identity: <\/strong>sometimes two different companies (or two different departments) agree to trust each other&#8217;s users. SAML is often the protocol that makes this &#171;you can use your ID from Company A to access Company B&#187; setup work.<\/p>\n<\/li>\n<\/ol>\n<h4>Why Developers (and Companies) Care About SAML<\/h4>\n<ol>\n<li>\n<p><strong>One Login to Rule Them All:<\/strong> SAML centralized authentication. No more users creating 10 different passwords for 10 different services (and using &#171;Password123&#187; for all of them).<\/p>\n<\/li>\n<li>\n<p><strong>It\u2019s a Standard: <\/strong>because SAML is standardized, your app can work with any identity provider that implements SAML \u2014 Microsoft, Okta, Google Workspace, you name it.<\/p>\n<\/li>\n<li>\n<p><strong>Security Boost: <\/strong>\u0441redentials stay with the IdP. The service provider just gets a signed assertion saying, \u201cYes, this user is legit.\u201d The SP doesn\u2019t know any credentials.<\/p>\n<\/li>\n<\/ol>\n<h2>Why SAML Refuses to Die (and Probably Won&#8217;t Anytime Soon)<\/h2>\n<ol>\n<li>\n<p><strong>Legacy Systems:<\/strong> big companies started using SAML over a decade ago. Moving away from it would mean rewriting tons of systems, testing for months, and basically begging for budget approval.<\/p>\n<\/li>\n<li>\n<p><strong>Compliance Rules:<\/strong> for some industries, SAML-based SSO isn&#8217;t just \u201cnice to have\u201d \u2014 it\u2019s baked into regulations and audit checklists.<\/p>\n<\/li>\n<li>\n<p><strong>Existing Trust Networks:<\/strong> partnerships between businesses often rely on long-standing SAML agreements. Switching protocols means legal headaches and new contracts.<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>In short: <strong>it\u2019s stable, it works, and ripping it out would hurt.<\/strong>  <\/p>\n<\/blockquote>\n<h2>Under the Hood: How SAML Actually Works<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c87\/6b8\/3b7\/c876b83b7f95a49095a5347f9e696899.jpeg\" width=\"1600\" height=\"861\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c87\/6b8\/3b7\/c876b83b7f95a49095a5347f9e696899.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c87\/6b8\/3b7\/c876b83b7f95a49095a5347f9e696899.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>Here&#8217;s a straightforward breakdown of the SAML authentication workflow:<\/p>\n<ol>\n<li>\n<p><strong>User<\/strong> tries to access some protected resource.<\/p>\n<\/li>\n<li>\n<p><strong>Service Provider (SP)<\/strong> notices this unauthenticated user.<\/p>\n<\/li>\n<li>\n<p><strong>SP<\/strong> redirects the user to the <strong>Identity Provider (IdP)<\/strong>, asking for authentication.<\/p>\n<\/li>\n<li>\n<p>The user&#8217;s <strong>browser<\/strong> gets sent over (via HTTP Redirect or POST) to the IdP.<\/p>\n<\/li>\n<li>\n<p><strong>User logs in<\/strong> (or maybe they already have a session at the IdP).<\/p>\n<\/li>\n<li>\n<p>The <strong>IdP builds a SAML Assertion<\/strong> and <strong>signs it<\/strong>.<\/p>\n<\/li>\n<li>\n<p>The <strong>IdP sends<\/strong> the signed SAML Response back to the browser.<\/p>\n<\/li>\n<li>\n<p>The <strong>browser posts<\/strong> that response back to the SP.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP validates<\/strong> the response and signature.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP reads<\/strong> the assertion and verifies the user&#8217;s identity.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP creates a session<\/strong> for the user.<\/p>\n<\/li>\n<li>\n<p><strong>The user is in!<\/strong> They get access to the resource they asked for.<\/p>\n<\/li>\n<\/ol>\n<p><strong>!<\/strong> <strong>Important to remember:<\/strong> the SP and IdP <strong>never<\/strong> communicate to each other directly. It&#8217;s all through the user&#8217;s browser.<\/p>\n<h2>Breaking Down a SAML Assertion<\/h2>\n<p>Once the IdP authenticates a user it sends a SAML Assertion inside the SAML Response which represents an XML-document. A typical SAML Response looks like this:<\/p>\n<ul>\n<li>\n<p><strong>&lt;samlp:Response&gt;<\/strong> (Root Element): metadata about the response \u2014 like who sent it, when, and where it should go.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;ds:Signature&gt;<\/strong> (Optional at Response Level): a digital signature that proves the whole response wasn\u2019t tampered with.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Assertion&gt; <\/strong>(The Important Part): here\u2019s where the juicy details live:<\/p>\n<ul>\n<li>\n<p><strong>&lt;Issuer&gt;<\/strong>: who issued the assertion (usually your IdP).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;ds:Signature&gt; <\/strong>(Optional at Assertion Level): some IdPs sign just the assertion, others sign both the response and the assertion.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Subject&gt;<\/strong>: the actual user \u2014 includes a &lt;NameID&gt; (like an email or username).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Conditions&gt;<\/strong>: rules like when the assertion is valid and who can use it (audience restrictions).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;AuthnStatement&gt;<\/strong>: proof of how the user authenticated (password, MFA, etc.).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;AttributeStatement&gt;<\/strong>: information about the current user:\u00a0 email, groups, job title, etc.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>SAML misconfiguration<\/h2>\n<p>Even though SAML is designed to be secure, small misconfigurations can blow massive holes in your app\u2019s defenses. Here\u2019s the common ways you can exploit Broken SAML. Different kinds of misconfiguration can be the first sign that this implementation is vulnerable.<\/p>\n<h3>Missing Message Signature<\/h3>\n<h4>What it is<\/h4>\n<p>The SAML Response is completely missing its XML signature.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If an SP only checks that the assertion is signed (but not the entire SAML response) or fails to check signatures at all, an attacker can tamper with the SAML response or inject malicious content.<\/p>\n<h4>Impact<\/h4>\n<p>The SP might trust an unsigned or altered response, enabling unauthorized access or session hijacking.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Simply try to remove the response signature and see if the SP accepts the assertion. <\/p>\n<h3>Missing Assertion Signature<\/h3>\n<h4>What it is<\/h4>\n<p>The SAML Assertion (the part that actually asserts user identity and claims) isn\u2019t signed, even though the outer message might be signed.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>The heart of SAML security is the assertion. If that\u2019s unsigned, an attacker can modify user attributes, roles, or identity claims inside the assertion.<\/p>\n<h4>Impact<\/h4>\n<p>Forged or modified user data, including identity or roles, leading to impersonation or privilege escalation.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>This time try to remove the assertion signature and see if the SP accepts the assertion. <\/p>\n<h3>Missing Both Signatures<\/h3>\n<h4>What it is<\/h4>\n<p><strong>Neither<\/strong> the overall SAML response nor the assertion is signed.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>This is the worst-case scenario for signature-based integrity. If both signatures are missing and the SP does not enforce signature validation, the entire message can be altered at will by an attacker.<\/p>\n<h4>Impact<\/h4>\n<p>Total compromise of trust \u2014 an attacker can fully forge the response, granting arbitrary permissions or user identities.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Try to remove both signatures and see if the SP accepts the assertion. <\/p>\n<h2>SAML vulnerabilities<\/h2>\n<h3>Invalid Signature Handling<\/h3>\n<h4>What it is<\/h4>\n<p>This technique tests whether a Service Provider (SP) correctly validates digital signatures in the SAML response. It includes three vectors:<\/p>\n<ul>\n<li>\n<p><strong>Invalid Message Signature<\/strong>: The outer message is signed, but the signature is tampered with or replaced.<\/p>\n<\/li>\n<li>\n<p><strong>Invalid Assertion Signature<\/strong>: The assertion element is signed, but with an invalid or fake signature.<\/p>\n<\/li>\n<li>\n<p><strong>Invalid Both Signatures<\/strong>: Both the message and assertion signatures are present, but both are invalid or replaced with garbage values.<\/p>\n<\/li>\n<\/ul>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If the SP fails to validate the integrity and authenticity of signatures correctly\u2014whether in the message, the assertion, or both\u2014it may process malicious or forged content. This opens the door to impersonation, privilege escalation, or unauthorized access.<\/p>\n<h4>Impact<\/h4>\n<p>Improper signature validation can lead to:<\/p>\n<ul>\n<li>\n<p>Acceptance of tampered SAML messages or assertions<\/p>\n<\/li>\n<li>\n<p>Forging of user identities or attributes<\/p>\n<\/li>\n<li>\n<p>Bypassing authentication mechanisms<\/p>\n<\/li>\n<\/ul>\n<h4>Detection mechanism<\/h4>\n<p>Systematically replace the message and\/or assertion signatures with invalid data:<\/p>\n<ul>\n<li>\n<p>Modify only the message signature<\/p>\n<\/li>\n<li>\n<p>Modify only the assertion signature<\/p>\n<\/li>\n<li>\n<p>Modify both signatures simultaneously<\/p>\n<\/li>\n<\/ul>\n<p>If any of these variations are accepted by the SP, it&#8217;s a strong indicator of broken or insufficient signature validation logic.<\/p>\n<pre><code class=\"xml\">&lt;samlp:Response     ID=\"_someID\"     Version=\"2.0\"     IssueInstant=\"2025-03-21T12:34:56Z\"     Destination=\"https:\/\/serviceprovider.com\/sso\/consume\"&gt;      &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;      &lt;ds:Signature&gt;         !!!Tampered XML signature replaces the original one!!!     &lt;\/ds:Signature&gt;      &lt;Assertion         ID=\"_assertionID\"         IssueInstant=\"2025-03-21T12:34:56Z\"         Version=\"2.0\"&gt;          &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;          &lt;ds:Signature&gt;             !!!Tampered XML signature replaces the original one!!!         &lt;\/ds:Signature&gt;          &lt;Subject&gt;             &lt;NameID&gt;john.doe@example.com&lt;\/NameID&gt;             &lt;SubjectConfirmation                 Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"&gt;                 &lt;SubjectConfirmationData                     InResponseTo=\"_someID\"                     NotOnOrAfter=\"2025-03-21T12:39:56Z\"                     Recipient=\"https:\/\/serviceprovider.com\/sso\/consume\"\/&gt;             &lt;\/SubjectConfirmation&gt;         &lt;\/Subject&gt;          &lt;Conditions             NotBefore=\"2025-03-21T12:34:56Z\"             NotOnOrAfter=\"2025-03-21T12:39:56Z\"&gt;             &lt;AudienceRestriction&gt;                 &lt;Audience&gt;https:\/\/serviceprovider.com&lt;\/Audience&gt;             &lt;\/AudienceRestriction&gt;         &lt;\/Conditions&gt;          &lt;AttributeStatement&gt;             &lt;Attribute Name=\"email\"&gt;                 &lt;AttributeValue&gt;john.doe@example.com&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;             &lt;Attribute Name=\"role\"&gt;                 &lt;AttributeValue&gt;user&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;         &lt;\/AttributeStatement&gt;     &lt;\/Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>Unsigned or Partially Signed SAML<\/h3>\n<h4>What it is<\/h4>\n<p>\u00a0An attacker manipulates the SAML response by removing or emptying the <strong>&lt;Signature&gt;<\/strong> element either on the entire message, the <strong>&lt;Assertion&gt;<\/strong>, or both. The result is a message with no cryptographic integrity \u2014 fully or partially unsigned.<\/p>\n<ul>\n<li>\n<p><strong>Unsigned Message:<\/strong> the outer response carries a <strong>&lt;Signature&gt;<\/strong> tag with an empty or missing value.<\/p>\n<\/li>\n<li>\n<p><strong>Unsigned Assertion:<\/strong> only the <strong>&lt;Assertion&gt;<\/strong> section is missing a valid signature, while the message may still appear signed.<\/p>\n<\/li>\n<li>\n<p><strong>Unsigned Both:<\/strong> neither the message nor the assertion is signed \u2014 the entire structure is left unsigned.<\/p>\n<\/li>\n<\/ul>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>Some Service Providers (SPs) only check for the <em>presence<\/em> of a signature tag rather than verifying its <em>validity<\/em> or scope. If signature enforcement is misconfigured, attackers can inject or modify assertions, impersonate users, or escalate privileges without detection.<\/p>\n<h4>Impact<\/h4>\n<p>From unauthorized access (e.g., logging in as another user) to full account takeover \u2014 depending on how lenient the SP&#8217;s validation is.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Test with:<\/p>\n<ul>\n<li>\n<p>An empty <strong>&lt;ds:SignatureValue&gt;<\/strong> inside the Response <strong>&lt;Signature&gt;<\/strong>.<\/p>\n<\/li>\n<li>\n<p>An empty <strong>&lt;ds:SignatureValue&gt;<\/strong> inside on the Assertion <strong>&lt;Signature&gt;<\/strong>.<\/p>\n<\/li>\n<li>\n<p>Both <strong>&lt;ds:SignatureValue&gt;<\/strong> are empty.<\/p>\n<\/li>\n<\/ul>\n<p>If any of these are accepted, the SP is vulnerable.<\/p>\n<pre><code class=\"xml\">&lt;samlp:Response     ID=\"_someID\"     Version=\"2.0\"     IssueInstant=\"2025-03-21T12:34:56Z\"     Destination=\"https:\/\/serviceprovider.com\/sso\/consume\"&gt;      &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;      &lt;ds:Signature&gt;         &lt;ds:SignedInfo&gt;...&lt;\/ds:SignedInfo&gt;         &lt;ds:SignatureValue&gt;&lt;\/ds:SignatureValue&gt; &lt;!-- empty --&gt;     &lt;\/ds:Signature&gt;      &lt;Assertion         ID=\"_assertionID\"         IssueInstant=\"2025-03-21T12:34:56Z\"         Version=\"2.0\"&gt;          &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;          &lt;ds:Signature&gt;             &lt;ds:SignedInfo&gt;...&lt;\/ds:SignedInfo&gt;             &lt;ds:SignatureValue&gt;&lt;\/ds:SignatureValue&gt; &lt;!-- empty --&gt;         &lt;\/ds:Signature&gt;          &lt;Subject&gt;             &lt;NameID&gt;john.doe@example.com&lt;\/NameID&gt;             &lt;SubjectConfirmation                 Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"&gt;                 &lt;SubjectConfirmationData                     InResponseTo=\"_someID\"                     NotOnOrAfter=\"2025-03-21T12:39:56Z\"                     Recipient=\"https:\/\/serviceprovider.com\/sso\/consume\"\/&gt;             &lt;\/SubjectConfirmation&gt;         &lt;\/Subject&gt;          &lt;Conditions             NotBefore=\"2025-03-21T12:34:56Z\"             NotOnOrAfter=\"2025-03-21T12:39:56Z\"&gt;             &lt;AudienceRestriction&gt;                 &lt;Audience&gt;https:\/\/serviceprovider.com&lt;\/Audience&gt;             &lt;\/AudienceRestriction&gt;         &lt;\/Conditions&gt;          &lt;AttributeStatement&gt;             &lt;Attribute Name=\"email\"&gt;                 &lt;AttributeValue&gt;john.doe@example.com&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;             &lt;Attribute Name=\"role\"&gt;                 &lt;AttributeValue&gt;user&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;         &lt;\/AttributeStatement&gt;     &lt;\/Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>Privilege Escalation<\/h3>\n<h4>What it is<\/h4>\n<p>The attacker modifies user roles or privileges inside the SAML assertion. For example, changing <strong>role=&#187;user&#187;<\/strong> to <strong>role=&#187;admin&#187;<\/strong>.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If the signature or claims aren\u2019t strictly validated, or if the SP only checks partial fields, the attacker can escalate from basic user to superuser or admin.<\/p>\n<h4>Impact<\/h4>\n<p>Full administrative access, unauthorized data access, or total system compromise if the SP honors the forged roles.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>If you do a black-box pentesting, try to change the\u00a0 role attribute to a different value: <strong>admin, administrator, moderator<\/strong>, etc. But if you know what roles exist in the app you can intentionally target them.<\/p>\n<pre><code class=\"xml\">&lt;samlp:Response     ID=\"_someID\"     Version=\"2.0\"     IssueInstant=\"2025-03-21T12:34:56Z\"     Destination=\"https:\/\/serviceprovider.com\/sso\/consume\"&gt;      &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;      &lt;ds:Signature&gt;         &lt;!-- XML Signature data signing the Response --&gt;     &lt;\/ds:Signature&gt;      &lt;Assertion         ID=\"_assertionID\"         IssueInstant=\"2025-03-21T12:34:56Z\"         Version=\"2.0\"&gt;          &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;          &lt;ds:Signature&gt;             &lt;!-- XML Signature data signing the Assertion --&gt;         &lt;\/ds:Signature&gt;          &lt;Subject&gt;             &lt;NameID&gt;john.doe@example.com&lt;\/NameID&gt;             &lt;SubjectConfirmation                 Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"&gt;                 &lt;SubjectConfirmationData                     InResponseTo=\"_someID\"                     NotOnOrAfter=\"2025-03-21T12:39:56Z\"                     Recipient=\"https:\/\/serviceprovider.com\/sso\/consume\"\/&gt;             &lt;\/SubjectConfirmation&gt;         &lt;\/Subject&gt;          &lt;Conditions             NotBefore=\"2025-03-21T12:34:56Z\"             NotOnOrAfter=\"2025-03-21T12:39:56Z\"&gt;             &lt;AudienceRestriction&gt;                 &lt;Audience&gt;https:\/\/serviceprovider.com&lt;\/Audience&gt;             &lt;\/AudienceRestriction&gt;         &lt;\/Conditions&gt;          &lt;AttributeStatement&gt;             &lt;Attribute Name=\"email\"&gt;                 &lt;AttributeValue&gt;john.doe@example.com&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;             &lt;Attribute Name=\"role\"&gt;                 &lt;AttributeValue&gt;admin&lt;\/AttributeValue&gt; &lt;!-- Replaced the role user \u2192 admin --&gt;             &lt;\/Attribute&gt;         &lt;\/AttributeStatement&gt;     &lt;\/Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>XML Signature Wrapping Attacks<\/h3>\n<h4>What it is<\/h4>\n<p>The attacker injects an <strong>unsigned<\/strong>, malicious <strong>&lt;Assertion&gt;<\/strong> or <strong>&lt;Response&gt;<\/strong> element into a SAML message <strong>before<\/strong> the legitimate, signed one. The Service Provider (SP) validates the signature on the legitimate part \u2014 but incorrectly processes <strong>attributes or authentication data<\/strong> from the attacker-controlled element.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If the SP doesn\u2019t strictly validate the XML structure or enforce that the signed element is the one actually used, it may trust and act on <strong>malicious data<\/strong>. This opens the door to unauthorized access, privilege escalation, or impersonation.<\/p>\n<h4>Impact<\/h4>\n<p>Admin access, identity spoofing, or arbitrary claims injection \u2014 even though the attacker does not control the signed content. A full compromise is possible if the SP uses attributes from the forged assertion.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Inject an additional <strong>&lt;Assertion&gt;<\/strong> or <strong>&lt;Response&gt;<\/strong> before the valid signed one. Modify key attributes in the malicious assertion (e.g., set <strong>Role=admin<\/strong> or <strong>Email=admin@example.com<\/strong>). If the SP logs you in as another user or with elevated privileges, it is vulnerable.<\/p>\n<pre><code class=\"xml\">&lt;!-- Variant 1: two separate SAML responses, malicious one comes first --&gt;  &lt;Response ID=\"_evilresp\"&gt;           &lt;!-- Unsigned, malicious response first --&gt;   &lt;Assertion ID=\"_evilassertion\"&gt;     &lt;AttributeStatement&gt;       &lt;Attribute Name=\"Role\"&gt;admin&lt;\/Attribute&gt;     &lt;\/AttributeStatement&gt;   &lt;\/Assertion&gt; &lt;\/Response&gt;  &lt;Response ID=\"_goodresponse\"&gt;       &lt;!-- Legitimate, signed response second --&gt;   &lt;Assertion ID=\"_goodassertion\"&gt;     &lt;Signature&gt;...valid signature...&lt;\/Signature&gt;     &lt;AttributeStatement&gt;       &lt;Attribute Name=\"Role\"&gt;user&lt;\/Attribute&gt;     &lt;\/AttributeStatement&gt;   &lt;\/Assertion&gt; &lt;\/Response&gt;   &lt;!-- Variant 2: one SAML Response containing two Assertions,                 the forged one is placed before the legitimate signed one --&gt;  &lt;samlp:Response ...&gt;    &lt;!-- Forged Assertion placed first --&gt;   &lt;saml:Assertion ID=\"_forged-assertion\"&gt;     &lt;Subject&gt;admin@example.com&lt;\/Subject&gt;   &lt;\/saml:Assertion&gt;   &lt;!-- Legitimate Assertion with valid signature --&gt;   &lt;saml:Assertion ID=\"_legitimate-assertion\"&gt;     &lt;ds:Signature&gt;LAS&lt;\/ds:Signature&gt;     &lt;Subject&gt;user@example.com&lt;\/Subject&gt;   &lt;\/saml:Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>XML Comment Handling<\/h3>\n<h4>What it is<\/h4>\n<p>An attacker who already has authenticated access to the SSO system can impersonate another user by injecting an <strong>XML comment (&lt;!&#8212; &#8212;&gt;)<\/strong> into the username (e.g., <strong>&lt;NameID&gt;<\/strong>) field of a SAML assertion. For example:<\/p>\n<pre><code>&lt;NameID&gt;admin&lt;!--ignore--&gt;@example.com&lt;\/NameID&gt;<\/code><\/pre>\n<p>Some SAML libraries incorrectly parse or reconstruct this field, leading to identity confusion.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If the Service Provider (SP) does not correctly canonicalize and validate the value, it may resolve <strong>admin&lt;!&#8212;ignore&#8212;&gt;@example.com<\/strong> as <strong>admin@example.com<\/strong> and <strong>grant access to another user&#8217;s account<\/strong> \u2014 without needing their credentials. This makes impersonation trivial for an already logged-in attacker.<\/p>\n<h4>Impact<\/h4>\n<p>Account takeover of any user the attacker targets \u2014 including administrators \u2014 simply by manipulating the <strong>&lt;NameID&gt;<\/strong> or other identifier fields with comment injection. <\/p>\n<h4>Detection mechanism<\/h4>\n<p>During testing, modify the SAML assertion to include an XML comment in the username or identifier fields. For example, split the value like <strong>john&lt;!&#8212;test&#8212;&gt;@example.com<\/strong>. If the SP authenticates the attacker as <strong>john@example.com<\/strong>, it&#8217;s vulnerable.<\/p>\n<h4>Known vulnerable libraries\/products (patched)<\/h4>\n<ul>\n<li>\n<p>OneLogin <strong>python-saml <\/strong>\u2013 CVE-2017-11427<\/p>\n<\/li>\n<li>\n<p>OneLogin <strong>ruby-saml<\/strong> \u2013 CVE-2017-11428<\/p>\n<\/li>\n<li>\n<p>Clever <strong>saml2-js<\/strong> \u2013 CVE-2017-11429<\/p>\n<\/li>\n<li>\n<p>OmniAuth-SAML \u2013 CVE-2017-11430<\/p>\n<\/li>\n<li>\n<p>Shibboleth \u2013 CVE-2018-0489<\/p>\n<\/li>\n<li>\n<p>Duo Network Gateway \u2013 CVE-2018-7340<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"xml\">&lt;samlp:Response     ID=\"_someID\"     Version=\"2.0\"     IssueInstant=\"2025-03-21T12:34:56Z\"     Destination=\"https:\/\/serviceprovider.com\/sso\/consume\"&gt;      &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;      &lt;ds:Signature&gt;         &lt;!-- XML Signature data signing the Response --&gt;     &lt;\/ds:Signature&gt;      &lt;Assertion         ID=\"_assertionID\"         IssueInstant=\"2025-03-21T12:34:56Z\"         Version=\"2.0\"&gt;          &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;          &lt;ds:Signature&gt;             &lt;!-- XML Signature data signing the Assertion --&gt;         &lt;\/ds:Signature&gt;          &lt;Subject&gt;             &lt;NameID&gt;john.doe@example.com&lt;\/NameID&gt;             &lt;SubjectConfirmation                 Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"&gt;                 &lt;SubjectConfirmationData                     InResponseTo=\"_someID\"                     NotOnOrAfter=\"2025-03-21T12:39:56Z\"                     Recipient=\"https:\/\/serviceprovider.com\/sso\/consume\"\/&gt;             &lt;\/SubjectConfirmation&gt;         &lt;\/Subject&gt;          &lt;Conditions             NotBefore=\"2025-03-21T12:34:56Z\"             NotOnOrAfter=\"2025-03-21T12:39:56Z\"&gt;             &lt;AudienceRestriction&gt;                 &lt;Audience&gt;https:\/\/serviceprovider.com&lt;\/Audience&gt;             &lt;\/AudienceRestriction&gt;         &lt;\/Conditions&gt;          &lt;AttributeStatement&gt;             &lt;Attribute Name=\"email\"&gt;                 &lt;AttributeValue&gt;                     john.doe@example.com&lt;!--XMLCOMMENT--&gt;..evil.com                 &lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;             &lt;Attribute Name=\"role\"&gt;                 &lt;AttributeValue&gt;user&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;         &lt;\/AttributeStatement&gt;     &lt;\/Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>XXE (XML External Entity) in Broken SAML<\/h3>\n<h4>What it is<\/h4>\n<p>Some XML parsers support <strong>external entity declarations<\/strong>, which act like macros or shortcuts in the document. For example:<\/p>\n<pre><code class=\"xml\">&lt;!ENTITY s \"s\"&gt; &lt;!ENTITY f1 \"f1\"&gt;<\/code><\/pre>\n<p>When a SAML Response includes values like <strong>&amp;s;&amp;f1;taff1<\/strong>, the parser expands them into staff1 <strong>after signature verification<\/strong>. This leads to a mismatch between what was signed by the Identity Provider (IdP) and what the Service Provider (SP) actually processes.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<ul>\n<li>\n<p>\u00a0<strong>Signature Bypass<\/strong>: The IdP signs one version of the XML, but entity expansion causes the SP to validate a structurally different document, allowing <strong>subtle data tampering<\/strong> while the signature still appears valid.<\/p>\n<\/li>\n<li>\n<p><strong>Attribute Forgery<\/strong>: Attackers can inject or alter sensitive fields such as <strong>uid<\/strong>, <strong>email<\/strong>, or <strong>role <\/strong>using crafted entities \u2014 bypassing normal integrity checks.<\/p>\n<\/li>\n<li>\n<p><strong>Full XXE Exploitation<\/strong>: If the SP\u2019s XML parser allows external entity resolution, this can escalate into a classic <strong>XXE attack<\/strong> \u2014 enabling attackers to read server files (e.g., <strong>\/etc\/passwd<\/strong>) or perform <strong>SSRF<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h4>Impact<\/h4>\n<ul>\n<li>\n<p>Unauthorized access or privilege escalation by tampering with signed data.<\/p>\n<\/li>\n<li>\n<p>Potential server-side data leakage or internal network access if XXE is triggered.<\/p>\n<\/li>\n<\/ul>\n<h4>Detection mechanism<\/h4>\n<p>Craft a SAML response where attribute values use custom entities (e.g., &amp;uid1;). If the SP resolves these post-signature and grants access based on the expanded value, it\u2019s vulnerable. Also test for classic XXE payloads to detect file read or SSRF behavior.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt; &lt;!DOCTYPE Response [   &lt;!ENTITY s  \"s\"&gt;   &lt;!ENTITY f1 \"f1\"&gt; ]&gt; &lt;saml2p:Response     xmlns:saml2p=\"urn:oasis:names:tc:SAML:2.0:protocol\"     Destination=\"https:\/\/idptestbed\/Shibboleth.sso\/SAML2\/POST\"     ID=\"_04cfe67e596b7449d05755049ba9ec28\"     InResponseTo=\"_dbb85ce7ff81905a3a7b448afb3a4b\"     IssueInstant=\"2017-12-08T15:15:56.062Z\"     Version=\"2.0\"&gt;      [...]      &lt;saml2:Attribute FriendlyName=\"uid\"                      Name=\"urn:oid:0.9.2342.19200300.100.1.1\"                      NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:uri\"&gt;         &lt;saml2:AttributeValue&gt;             &amp;s;taf&amp;f1;         &lt;\/saml2:AttributeValue&gt;     &lt;\/saml2:Attribute&gt;      [...] &lt;\/saml2p:Response&gt;<\/code><\/pre>\n<h2>Securing SAML: Don&#8217;t Trust, Verify<\/h2>\n<p>SAML is battle-tested, widely adopted, and deeply embedded in enterprise environments \u2014 and that&#8217;s exactly why it&#8217;s such a high-value target. When properly configured, SAML provides a secure and efficient way to manage identity across systems. But the moment signature enforcement, entity resolution, or assertion validation is even slightly misconfigured, attackers can turn that same convenience into a foothold for privilege escalation, impersonation, and full account takeovers.<\/p>\n<p>What makes Broken SAML particularly dangerous is how <em>invisible<\/em> these issues can be in production. The application appears to work. Users authenticate. Sessions are created. But under the hood, trust boundaries may already be breached. Many of the vulnerabilities discussed \u2014 such as unsigned assertions, signature wrapping, or XML entity misuse \u2014 don\u2019t crash your app or throw errors. They silently let attackers through the door.<\/p>\n<p>This is where <strong>Dynamic Application Security Testing (DAST)<\/strong> becomes essential. DAST doesn\u2019t just lint your SAML configs or scan your source code \u2014 it behaves like an attacker. It manipulates live SAML flows, injects malformed assertions, and tests your app&#8217;s real-world reaction. When applied correctly, it can reveal misconfigurations that static tools or manual reviews often miss.<\/p>\n<p>At Bright Security, we believe modern DAST should go beyond scanning pages and input fields. It should understand protocols like SAML, test for these high-impact edge cases, and provide actionable insights to developers \u2014 before attackers get the chance.<\/p>\n<p><strong>Bottom line:<br \/><\/strong>If your app supports SAML, make signature validation strict, enforce proper structure, and never assume a signature means security. Test it. Validate it. Break it \u2014 before someone else does.\u00a0<\/p>\n<p>Thanks for sticking with me through this deep dive \u2014 I appreciate you taking the time to explore these often-overlooked corners of SAML security.<\/p>\n<p>If you have questions, spot something interesting in your own app, or just want to share feedback, feel free to reach out to me:<\/p>\n<p>LinkedIn:<a href=\"https:\/\/www.linkedin.com\/in\/ilya-olchikov\/\" rel=\"noopener noreferrer nofollow\"> https:\/\/www.linkedin.com\/in\/ilya-olchikov\/<\/a><\/p>\n<p>Telegram: @ScriptedEcho<strong><br \/><\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/912156\/\"> https:\/\/habr.com\/ru\/articles\/912156\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>My name is Ilya and I\u2019m a Core Developer at Bright Security. In Bright we work on a DAST (Dynamic Application Security Testing) solution that helps development teams find and fix vulnerabilities early, straight from CI\/CD. My own path began in full-stack engineering, but almost a decade of shipping production code drew me ever deeper into application security. In this article I\u2019m explaining key approaches on what SAML actually is and how we detect it in Bright using DAST.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>What is SAML (Security Assertion Markup Language)?<\/h2>\n<p>Let\u2019s start with the definition even though I\u2019m quite certain you know it if you\u2019re reading this article. SAML (Security Assertion Markup Language) is an XML-based standard for exchanging authentication and authorization data between different security domains, typically an Identity Provider (IdP) and a Service Provider (SP).<\/p>\n<h4>Where You&#8217;ll See SAML in Action<\/h4>\n<ol>\n<li>\n<p><strong>Enterprise Single Sign-On (SSO):<\/strong> inside companies, employees often log in once and then can access email, CRM, cloud tools, etc., without having to authenticate again. That\u2019s SAML making life easier behind the scenes.<\/p>\n<\/li>\n<li>\n<p><strong>Federated Identity: <\/strong>sometimes two different companies (or two different departments) agree to trust each other&#8217;s users. SAML is often the protocol that makes this &#171;you can use your ID from Company A to access Company B&#187; setup work.<\/p>\n<\/li>\n<\/ol>\n<h4>Why Developers (and Companies) Care About SAML<\/h4>\n<ol>\n<li>\n<p><strong>One Login to Rule Them All:<\/strong> SAML centralized authentication. No more users creating 10 different passwords for 10 different services (and using &#171;Password123&#187; for all of them).<\/p>\n<\/li>\n<li>\n<p><strong>It\u2019s a Standard: <\/strong>because SAML is standardized, your app can work with any identity provider that implements SAML \u2014 Microsoft, Okta, Google Workspace, you name it.<\/p>\n<\/li>\n<li>\n<p><strong>Security Boost: <\/strong>\u0441redentials stay with the IdP. The service provider just gets a signed assertion saying, \u201cYes, this user is legit.\u201d The SP doesn\u2019t know any credentials.<\/p>\n<\/li>\n<\/ol>\n<h2>Why SAML Refuses to Die (and Probably Won&#8217;t Anytime Soon)<\/h2>\n<ol>\n<li>\n<p><strong>Legacy Systems:<\/strong> big companies started using SAML over a decade ago. Moving away from it would mean rewriting tons of systems, testing for months, and basically begging for budget approval.<\/p>\n<\/li>\n<li>\n<p><strong>Compliance Rules:<\/strong> for some industries, SAML-based SSO isn&#8217;t just \u201cnice to have\u201d \u2014 it\u2019s baked into regulations and audit checklists.<\/p>\n<\/li>\n<li>\n<p><strong>Existing Trust Networks:<\/strong> partnerships between businesses often rely on long-standing SAML agreements. Switching protocols means legal headaches and new contracts.<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>In short: <strong>it\u2019s stable, it works, and ripping it out would hurt.<\/strong>  <\/p>\n<\/blockquote>\n<h2>Under the Hood: How SAML Actually Works<\/h2>\n<figure class=\"full-width\"><\/figure>\n<p>Here&#8217;s a straightforward breakdown of the SAML authentication workflow:<\/p>\n<ol>\n<li>\n<p><strong>User<\/strong> tries to access some protected resource.<\/p>\n<\/li>\n<li>\n<p><strong>Service Provider (SP)<\/strong> notices this unauthenticated user.<\/p>\n<\/li>\n<li>\n<p><strong>SP<\/strong> redirects the user to the <strong>Identity Provider (IdP)<\/strong>, asking for authentication.<\/p>\n<\/li>\n<li>\n<p>The user&#8217;s <strong>browser<\/strong> gets sent over (via HTTP Redirect or POST) to the IdP.<\/p>\n<\/li>\n<li>\n<p><strong>User logs in<\/strong> (or maybe they already have a session at the IdP).<\/p>\n<\/li>\n<li>\n<p>The <strong>IdP builds a SAML Assertion<\/strong> and <strong>signs it<\/strong>.<\/p>\n<\/li>\n<li>\n<p>The <strong>IdP sends<\/strong> the signed SAML Response back to the browser.<\/p>\n<\/li>\n<li>\n<p>The <strong>browser posts<\/strong> that response back to the SP.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP validates<\/strong> the response and signature.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP reads<\/strong> the assertion and verifies the user&#8217;s identity.<\/p>\n<\/li>\n<li>\n<p>The <strong>SP creates a session<\/strong> for the user.<\/p>\n<\/li>\n<li>\n<p><strong>The user is in!<\/strong> They get access to the resource they asked for.<\/p>\n<\/li>\n<\/ol>\n<p><strong>!<\/strong> <strong>Important to remember:<\/strong> the SP and IdP <strong>never<\/strong> communicate to each other directly. It&#8217;s all through the user&#8217;s browser.<\/p>\n<h2>Breaking Down a SAML Assertion<\/h2>\n<p>Once the IdP authenticates a user it sends a SAML Assertion inside the SAML Response which represents an XML-document. A typical SAML Response looks like this:<\/p>\n<ul>\n<li>\n<p><strong>&lt;samlp:Response&gt;<\/strong> (Root Element): metadata about the response \u2014 like who sent it, when, and where it should go.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;ds:Signature&gt;<\/strong> (Optional at Response Level): a digital signature that proves the whole response wasn\u2019t tampered with.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Assertion&gt; <\/strong>(The Important Part): here\u2019s where the juicy details live:<\/p>\n<ul>\n<li>\n<p><strong>&lt;Issuer&gt;<\/strong>: who issued the assertion (usually your IdP).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;ds:Signature&gt; <\/strong>(Optional at Assertion Level): some IdPs sign just the assertion, others sign both the response and the assertion.<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Subject&gt;<\/strong>: the actual user \u2014 includes a &lt;NameID&gt; (like an email or username).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;Conditions&gt;<\/strong>: rules like when the assertion is valid and who can use it (audience restrictions).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;AuthnStatement&gt;<\/strong>: proof of how the user authenticated (password, MFA, etc.).<\/p>\n<\/li>\n<li>\n<p><strong>&lt;AttributeStatement&gt;<\/strong>: information about the current user:\u00a0 email, groups, job title, etc.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>SAML misconfiguration<\/h2>\n<p>Even though SAML is designed to be secure, small misconfigurations can blow massive holes in your app\u2019s defenses. Here\u2019s the common ways you can exploit Broken SAML. Different kinds of misconfiguration can be the first sign that this implementation is vulnerable.<\/p>\n<h3>Missing Message Signature<\/h3>\n<h4>What it is<\/h4>\n<p>The SAML Response is completely missing its XML signature.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If an SP only checks that the assertion is signed (but not the entire SAML response) or fails to check signatures at all, an attacker can tamper with the SAML response or inject malicious content.<\/p>\n<h4>Impact<\/h4>\n<p>The SP might trust an unsigned or altered response, enabling unauthorized access or session hijacking.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Simply try to remove the response signature and see if the SP accepts the assertion. <\/p>\n<h3>Missing Assertion Signature<\/h3>\n<h4>What it is<\/h4>\n<p>The SAML Assertion (the part that actually asserts user identity and claims) isn\u2019t signed, even though the outer message might be signed.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>The heart of SAML security is the assertion. If that\u2019s unsigned, an attacker can modify user attributes, roles, or identity claims inside the assertion.<\/p>\n<h4>Impact<\/h4>\n<p>Forged or modified user data, including identity or roles, leading to impersonation or privilege escalation.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>This time try to remove the assertion signature and see if the SP accepts the assertion. <\/p>\n<h3>Missing Both Signatures<\/h3>\n<h4>What it is<\/h4>\n<p><strong>Neither<\/strong> the overall SAML response nor the assertion is signed.<\/p>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>This is the worst-case scenario for signature-based integrity. If both signatures are missing and the SP does not enforce signature validation, the entire message can be altered at will by an attacker.<\/p>\n<h4>Impact<\/h4>\n<p>Total compromise of trust \u2014 an attacker can fully forge the response, granting arbitrary permissions or user identities.<\/p>\n<h4>Detection mechanism<\/h4>\n<p>Try to remove both signatures and see if the SP accepts the assertion. <\/p>\n<h2>SAML vulnerabilities<\/h2>\n<h3>Invalid Signature Handling<\/h3>\n<h4>What it is<\/h4>\n<p>This technique tests whether a Service Provider (SP) correctly validates digital signatures in the SAML response. It includes three vectors:<\/p>\n<ul>\n<li>\n<p><strong>Invalid Message Signature<\/strong>: The outer message is signed, but the signature is tampered with or replaced.<\/p>\n<\/li>\n<li>\n<p><strong>Invalid Assertion Signature<\/strong>: The assertion element is signed, but with an invalid or fake signature.<\/p>\n<\/li>\n<li>\n<p><strong>Invalid Both Signatures<\/strong>: Both the message and assertion signatures are present, but both are invalid or replaced with garbage values.<\/p>\n<\/li>\n<\/ul>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>If the SP fails to validate the integrity and authenticity of signatures correctly\u2014whether in the message, the assertion, or both\u2014it may process malicious or forged content. This opens the door to impersonation, privilege escalation, or unauthorized access.<\/p>\n<h4>Impact<\/h4>\n<p>Improper signature validation can lead to:<\/p>\n<ul>\n<li>\n<p>Acceptance of tampered SAML messages or assertions<\/p>\n<\/li>\n<li>\n<p>Forging of user identities or attributes<\/p>\n<\/li>\n<li>\n<p>Bypassing authentication mechanisms<\/p>\n<\/li>\n<\/ul>\n<h4>Detection mechanism<\/h4>\n<p>Systematically replace the message and\/or assertion signatures with invalid data:<\/p>\n<ul>\n<li>\n<p>Modify only the message signature<\/p>\n<\/li>\n<li>\n<p>Modify only the assertion signature<\/p>\n<\/li>\n<li>\n<p>Modify both signatures simultaneously<\/p>\n<\/li>\n<\/ul>\n<p>If any of these variations are accepted by the SP, it&#8217;s a strong indicator of broken or insufficient signature validation logic.<\/p>\n<pre><code class=\"xml\">&lt;samlp:Response     ID=\"_someID\"     Version=\"2.0\"     IssueInstant=\"2025-03-21T12:34:56Z\"     Destination=\"https:\/\/serviceprovider.com\/sso\/consume\"&gt;      &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;      &lt;ds:Signature&gt;         !!!Tampered XML signature replaces the original one!!!     &lt;\/ds:Signature&gt;      &lt;Assertion         ID=\"_assertionID\"         IssueInstant=\"2025-03-21T12:34:56Z\"         Version=\"2.0\"&gt;          &lt;Issuer&gt;https:\/\/idp.example.com&lt;\/Issuer&gt;          &lt;ds:Signature&gt;             !!!Tampered XML signature replaces the original one!!!         &lt;\/ds:Signature&gt;          &lt;Subject&gt;             &lt;NameID&gt;john.doe@example.com&lt;\/NameID&gt;             &lt;SubjectConfirmation                 Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"&gt;                 &lt;SubjectConfirmationData                     InResponseTo=\"_someID\"                     NotOnOrAfter=\"2025-03-21T12:39:56Z\"                     Recipient=\"https:\/\/serviceprovider.com\/sso\/consume\"\/&gt;             &lt;\/SubjectConfirmation&gt;         &lt;\/Subject&gt;          &lt;Conditions             NotBefore=\"2025-03-21T12:34:56Z\"             NotOnOrAfter=\"2025-03-21T12:39:56Z\"&gt;             &lt;AudienceRestriction&gt;                 &lt;Audience&gt;https:\/\/serviceprovider.com&lt;\/Audience&gt;             &lt;\/AudienceRestriction&gt;         &lt;\/Conditions&gt;          &lt;AttributeStatement&gt;             &lt;Attribute Name=\"email\"&gt;                 &lt;AttributeValue&gt;john.doe@example.com&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;             &lt;Attribute Name=\"role\"&gt;                 &lt;AttributeValue&gt;user&lt;\/AttributeValue&gt;             &lt;\/Attribute&gt;         &lt;\/AttributeStatement&gt;     &lt;\/Assertion&gt; &lt;\/samlp:Response&gt;<\/code><\/pre>\n<h3>Unsigned or Partially Signed SAML<\/h3>\n<h4>What it is<\/h4>\n<p>\u00a0An attacker manipulates the SAML response by removing or emptying the <strong>&lt;Signature&gt;<\/strong> element either on the entire message, the <strong>&lt;Assertion&gt;<\/strong>, or both. The result is a message with no cryptographic integrity \u2014 fully or partially unsigned.<\/p>\n<ul>\n<li>\n<p><strong>Unsigned Message:<\/strong> the outer response carries a <strong>&lt;Signature&gt;<\/strong> tag with an empty or missing value.<\/p>\n<\/li>\n<li>\n<p><strong>Unsigned Assertion:<\/strong> only the <strong>&lt;Assertion&gt;<\/strong> section is missing a valid signature, while the message may still appear signed.<\/p>\n<\/li>\n<li>\n<p><strong>Unsigned Both:<\/strong> neither the message nor the assertion is signed \u2014 the entire structure is left unsigned.<\/p>\n<\/li>\n<\/ul>\n<h4>Why it\u2019s dangerous<\/h4>\n<p>Some Service Providers (SPs) only check for the <em>presence<\/em> of a signature tag rather than verifying its <em>validity<\/em> or scope. If signature enforcement<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-460763","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=460763"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/460763\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}