{
    "document": {
        "category": "csaf_base",
        "csaf_version": "2.0",
        "distribution": {
            "tlp": {
                "label": "WHITE"
            }
        },
        "lang": "en",
        "notes": [
            {
                "category": "legal_disclaimer",
                "text": "The Netherlands Cyber Security Center (henceforth: NCSC-NL) maintains this portal to enhance access to its information and vulnerabilities. The use of this information is subject to the following terms and conditions:\n\nThe vulnerabilities disclosed in this portal are gathered by NCSC-NL from a variety of open sources, which the user can retrieve from other platforms. NCSC-NL makes every reasonable effort to ensure that the content of this portal is kept up to date, and that it is accurate and complete. Nevertheless, NCSC-NL cannot entirely rule out the possibility of errors, and therefore cannot give any warranty in respect of its completeness, accuracy or real-time keeping up-to-date. NCSC-NL does not control nor guarantee the accuracy, relevance, timeliness or completeness of information obtained from these external sources. The vulnerabilities disclosed in this portal are intended solely for the convenience of professional parties to take appropriate measures to manage the risks posed to the cybersecurity. No rights can be derived from the information provided therein.\n\nNCSC-NL and the Kingdom of the Netherlands assume no legal liability or responsibility for any damage resulting from either the use or inability of use of the vulnerabilities disclosed in this portal. This includes damage resulting from the inaccuracy of incompleteness of the information contained in it.\nThe information on this page is subject to Dutch law. All disputes related to or arising from the use of this portal regarding the disclosure of vulnerabilities will be submitted to the competent court in The Hague. This choice of means also applies to the court in summary proceedings."
            }
        ],
        "publisher": {
            "category": "coordinator",
            "contact_details": "cert@ncsc.nl",
            "name": "National Cyber Security Centre",
            "namespace": "https://www.ncsc.nl/"
        },
        "title": "CVE-2026-32313",
        "tracking": {
            "current_release_date": "2026-03-23T03:33:18.023887Z",
            "generator": {
                "date": "2026-02-17T15:00:00Z",
                "engine": {
                    "name": "V.E.L.M.A",
                    "version": "1.7"
                }
            },
            "id": "CVE-2026-32313",
            "initial_release_date": "2026-03-13T20:38:49.671198Z",
            "revision_history": [
                {
                    "date": "2026-03-13T20:38:49.671198Z",
                    "number": "1",
                    "summary": "CVE created.| Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products created (1).| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-03-13T20:38:51.937635Z",
                    "number": "2",
                    "summary": "NCSC Score created."
                },
                {
                    "date": "2026-03-13T21:12:45.271976Z",
                    "number": "3",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| References created (4).| CWES updated (1)."
                },
                {
                    "date": "2026-03-13T21:12:47.182566Z",
                    "number": "4",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-14T07:35:27.659389Z",
                    "number": "5",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-14T14:51:26.367368Z",
                    "number": "6",
                    "summary": "Source created.| CVE status created. (valid)| EPSS created."
                },
                {
                    "date": "2026-03-15T00:10:41.797218Z",
                    "number": "7",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products connected (14).| References created (5).| CWES updated (1)."
                },
                {
                    "date": "2026-03-15T00:30:41.293317Z",
                    "number": "8",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| Products connected (21).| Product Identifiers created (21).| Products created (1).| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-03-16T14:33:34.279811Z",
                    "number": "9",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| References created (3).| CWES updated (1)."
                },
                {
                    "date": "2026-03-16T14:33:37.251803Z",
                    "number": "10",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-16T14:39:00.877719Z",
                    "number": "11",
                    "summary": "Unknown change."
                },
                {
                    "date": "2026-03-16T22:51:01.551097Z",
                    "number": "12",
                    "summary": "References created (1)."
                },
                {
                    "date": "2026-03-17T00:30:44.334813Z",
                    "number": "13",
                    "summary": "References created (1)."
                },
                {
                    "date": "2026-03-17T20:26:20.692987Z",
                    "number": "14",
                    "summary": "Products created (1).| Product Identifiers created (1).| Exploits created (1)."
                },
                {
                    "date": "2026-03-17T20:26:24.069681Z",
                    "number": "15",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-19T15:28:43.046499Z",
                    "number": "16",
                    "summary": "Source created.| CVE status created. (valid)| Description created for source.| CVSS created.| References created (5).| CWES updated (1)."
                },
                {
                    "date": "2026-03-19T15:28:46.200140Z",
                    "number": "17",
                    "summary": "NCSC Score updated."
                },
                {
                    "date": "2026-03-20T09:31:07.108498Z",
                    "number": "18",
                    "summary": "Source connected.| CVE status created. (valid)| EPSS created."
                },
                {
                    "date": "2026-03-20T09:31:12.904257Z",
                    "number": "19",
                    "summary": "NCSC Score updated."
                }
            ],
            "status": "interim",
            "version": "19"
        }
    },
    "product_tree": {
        "branches": [
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/<3.1.5",
                                "product": {
                                    "name": "vers:unknown/<3.1.5",
                                    "product_id": "CSAFPID-5839261",
                                    "product_identification_helper": {
                                        "cpe": "cpe:2.3:a:xmlseclibs_project:xmlseclibs:*:*:*:*:*:*:*:*"
                                    }
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "XMLSecLibs"
                    }
                ],
                "category": "vendor",
                "name": "XMLSecLibs Project"
            },
            {
                "branches": [
                    {
                        "branches": [
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.3.2",
                                "product": {
                                    "name": "vers:unknown/1.3.2",
                                    "product_id": "CSAFPID-4469520",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.3.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.3.3",
                                "product": {
                                    "name": "vers:unknown/1.3.3",
                                    "product_id": "CSAFPID-5238949",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.3.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.3.4",
                                "product": {
                                    "name": "vers:unknown/1.3.4",
                                    "product_id": "CSAFPID-5238950",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.3.4"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.4.0",
                                "product": {
                                    "name": "vers:unknown/1.4.0",
                                    "product_id": "CSAFPID-4469521",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.4.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.4.1",
                                "product": {
                                    "name": "vers:unknown/1.4.1",
                                    "product_id": "CSAFPID-5238951",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.4.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.4.2",
                                "product": {
                                    "name": "vers:unknown/1.4.2",
                                    "product_id": "CSAFPID-5238952",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.4.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/1.4.3",
                                "product": {
                                    "name": "vers:unknown/1.4.3",
                                    "product_id": "CSAFPID-5238953",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@1.4.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/2.0.0",
                                "product": {
                                    "name": "vers:unknown/2.0.0",
                                    "product_id": "CSAFPID-4469522",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@2.0.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/2.0.1",
                                "product": {
                                    "name": "vers:unknown/2.0.1",
                                    "product_id": "CSAFPID-4469523",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@2.0.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/2.1.0",
                                "product": {
                                    "name": "vers:unknown/2.1.0",
                                    "product_id": "CSAFPID-5238954",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@2.1.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/2.1.1",
                                "product": {
                                    "name": "vers:unknown/2.1.1",
                                    "product_id": "CSAFPID-5238955",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@2.1.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.0.0",
                                "product": {
                                    "name": "vers:unknown/3.0.0",
                                    "product_id": "CSAFPID-4469524",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.0.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.0.1",
                                "product": {
                                    "name": "vers:unknown/3.0.1",
                                    "product_id": "CSAFPID-4469525",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.0.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.0.2",
                                "product": {
                                    "name": "vers:unknown/3.0.2",
                                    "product_id": "CSAFPID-4469526",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.0.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.0.3",
                                "product": {
                                    "name": "vers:unknown/3.0.3",
                                    "product_id": "CSAFPID-4469527",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.0.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.0.4",
                                "product": {
                                    "name": "vers:unknown/3.0.4",
                                    "product_id": "CSAFPID-5238956",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.0.4"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.1.0",
                                "product": {
                                    "name": "vers:unknown/3.1.0",
                                    "product_id": "CSAFPID-5238957",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.1.0"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.1.1",
                                "product": {
                                    "name": "vers:unknown/3.1.1",
                                    "product_id": "CSAFPID-5238958",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.1.1"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.1.2",
                                "product": {
                                    "name": "vers:unknown/3.1.2",
                                    "product_id": "CSAFPID-5238959",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.1.2"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.1.3",
                                "product": {
                                    "name": "vers:unknown/3.1.3",
                                    "product_id": "CSAFPID-5238960",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.1.3"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/3.1.4",
                                "product": {
                                    "name": "vers:unknown/3.1.4",
                                    "product_id": "CSAFPID-5827344",
                                    "product_identification_helper": {
                                        "purl": "pkg:composer/robrichards/xmlseclibs@3.1.4"
                                    }
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/<3.1.5",
                                "product": {
                                    "name": "vers:unknown/<3.1.5",
                                    "product_id": "CSAFPID-5825959"
                                }
                            },
                            {
                                "category": "product_version_range",
                                "name": "vers:unknown/>=0|<3.1.5",
                                "product": {
                                    "name": "vers:unknown/>=0|<3.1.5",
                                    "product_id": "CSAFPID-5828138"
                                }
                            }
                        ],
                        "category": "product_name",
                        "name": "xmlseclibs"
                    }
                ],
                "category": "vendor",
                "name": "robrichards"
            }
        ]
    },
    "vulnerabilities": [
        {
            "cve": "CVE-2026-32313",
            "cwe": {
                "id": "CWE-354",
                "name": "Improper Validation of Integrity Check Value"
            },
            "notes": [
                {
                    "category": "description",
                    "text": "xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. Prior to 3.1.5, XML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length. An attacker can use this to brute-force an authentication tag, recover the GHASH key, and decrypt the encrypted nodes. It also allows to forge arbitrary ciphertexts without knowing the encryption key. This vulnerability is fixed in 3.1.5.",
                    "title": "cveprojectv5 - https://www.cve.org/CVERecord?id=CVE-2026-32313"
                },
                {
                    "category": "description",
                    "text": "### Summary\nXML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length.\nAn attacker can use this to brute-force an authentication tag, recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of), and decrypt the encrypted nodes.\nIt also allows to forge arbitrary ciphertexts without knowing the encryption key.\n\n### Details\nWhen decrypting with either aes-128-gcm, aes-192-gcm, or aes-256-gcm [here](https://github.com/robrichards/xmlseclibs/blob/2bdfd742624d739dfadbd415f00181b4a77aaf07/src/XMLSecurityKey.php#L467-L479), the `$authTag` is set from a `substr()`, but never has its length validated (it should be validated with something like `strlen($authTag) == self::AUTHTAG_LENGTH`).\nFor that reason, a shorter than expected data blob will allow for the `$authTag` to have as short a tag as only one byte (see [PHP's documentation](https://www.php.net/manual/en/function.openssl-decrypt.php#:~:text=The%20length%20of%20the%20tag%20is%20not%20checked%20by%20the%20function.%20It%20is%20the%20caller%27s%20responsibility%20to%20ensure%20that%20the%20length%20of%20the%20tag%20matches%20the%20length%20of%20the%20tag%20retrieved%20when%20openssl_encrypt()%20has%20been%20called.%20Otherwise%20the%20decryption%20may%20succeed%20if%20the%20given%20tag%20only%20matches%20the%20start%20of%20the%20proper%20tag.)).\n\nSee this example:\n```php\nfunction test($data) {\n    $ivSize = 12;\n    $tagSize = 16;\n\n    $iv = substr($data, 0, $ivSize);\n    $data = substr($data, $ivSize);\n    $offset = 0 - $tagSize;\n    $tag = substr($data, $offset);\n    $ct = substr($data, 0, $offset);\n\n    echo 'IV: \"' . $iv . '\"' . PHP_EOL;\n    echo 'Tag: \"' . $tag . '\"' . PHP_EOL;\n    echo 'CT: \"' . $ct . '\"' . PHP_EOL;\n}\n\n/* Outputs:\nphp > test('myNonceNoncet');\nIV: \"myNonceNonce\"\nTag: \"t\"\nCT: \"\"\nphp > test('myNonceNonceta');\nIV: \"myNonceNonce\"\nTag: \"ta\"\nCT: \"\"\nphp > test('myNonceNoncetag');\nIV: \"myNonceNonce\"\nTag: \"tag\"\nCT: \"\"\n*/\n```\n\nWith a legit ciphertext in hand, this is enough to recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of).\nWith that key, any authenticated tags can be computed offline which allows for decryption of the ciphertext and forgery of arbitrary ciphertexts.\n\n### PoC\n1. Setup a server expecting XML with an encrypted assertion\n    - Run this php script [poc.php](https://github.com/user-attachments/files/24426600/poc.php.txt) with `php -S 127.0.0.1:8888` (taken from [this saml test case](https://github.com/robrichards/xmlseclibs/blob/69fd63080bc47a8d51bc101c30b7cb756862d1d6/tests/saml/saml-decrypt.phpt#L62))\n    - The script expects this private key: [sp-private-key.pem.](https://github.com/user-attachments/files/24426620/sp-private-key.pem.txt)\n2. Create an XML document with an encrypted assertion (encrypted with `aes-256-gcm`)\n    - Here is the `SAMLResponse` used in the video below: [saml_response.txt](https://github.com/user-attachments/files/24426638/saml_response.txt)\n\n**Note:** The steps from 3 to 6 are implemented in this exploit script: [nonce_reuse_with_fmt_val_oracle.py](https://github.com/user-attachments/files/24426645/nonce_reuse_with_fmt_val_oracle.py).\nYou can run the script with `sage -python nonce_reuse_with_fmt_val_oracle.py -s 'url-encoded_and_base64-encoded_samlresponse'`\n\n3. Take the content of the `<xenc:CipherValue>` node and apply the following modifications\n    1. Base64-decode the content\n    2. Take the first 12 bytes and save them as the nonce\n    3. Take the last 16 bytes and save them as the tag\n    4. Now brute-force the tag of an empty ciphertext\n        1. Loop through all 256 possible byte values (let's call that `byte_tag_attempt`)\n        2. Concatenate together the nonce and the `byte_tag_attempt`\n        3. Base64-encode the result\n        4. Replace the content of the `<xenc:CipherValue>` node with this result\n        5. On http errors 500, we learn that the tag is valid\n        6. Do the same for the next byte of the tag until all 16 bytes have been brute-forced\n4. With this new tag and the empty ciphertext, compute the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) (the way to do this has been described in this [blog post](https://frereit.de/aes_gcm/))\n5. Use this [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) to compute authentication tags offline for arbitrary ciphertexts\n6. Decryption is done by observing XML parsing errors that occur after modifying the ciphertext, those can be seen as http errors 500\n\n[poc.webm](https://github.com/user-attachments/assets/2f6e4a7e-4384-4350-b423-7ddd77aa9152)\n\n\n### Impact\nThe general impact is:\n- XML nodes encrypted with AES-GCM can be decrypted by observing parsing differences\n- XML nodes encrypted with AES-GCM can be modified to decrypt to an arbitrary value\n- The GCM internal [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) can be recovered\n\nIn cases where the encryption key is embedded in the XML and is encrypted with the Service Provider's public key (like often done with SAML), the last two items don't have a big impact.\nThis is because: \n- With the Service Provider's public key, an arbitrary ciphertext can be created with a known symmetric key\n- The symmetric keys are generated on the fly every time the IdP creates a new `SAMLResponse`\n\nIn any case, secrets that are embedded in the XML, whether coming from an IdP, or from another scheme, can be decrypted.\n\n**Important:** If static symmetric keys are used, as the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) could have leaked, you must rotate those keys.\n\n### References\nFor additional information on the issue, you can refer to this [blog post](https://sideni.xyz/posts/exploiting_openssl_api/) about the OpenSSL issue and how it can be exploited.",
                    "title": "github - https://github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "description",
                    "text": "xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. Prior to 3.1.5, XML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length. An attacker can use this to brute-force an authentication tag, recover the GHASH key, and decrypt the encrypted nodes. It also allows to forge arbitrary ciphertexts without knowing the encryption key. This vulnerability is fixed in 3.1.5.",
                    "title": "osv - https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/GIT%2FCVE-2026-32313.json?alt=media"
                },
                {
                    "category": "description",
                    "text": "### Summary\nXML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length.\nAn attacker can use this to brute-force an authentication tag, recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of), and decrypt the encrypted nodes.\nIt also allows to forge arbitrary ciphertexts without knowing the encryption key.\n\n### Details\nWhen decrypting with either aes-128-gcm, aes-192-gcm, or aes-256-gcm [here](https://github.com/robrichards/xmlseclibs/blob/2bdfd742624d739dfadbd415f00181b4a77aaf07/src/XMLSecurityKey.php#L467-L479), the `$authTag` is set from a `substr()`, but never has its length validated (it should be validated with something like `strlen($authTag) == self::AUTHTAG_LENGTH`).\nFor that reason, a shorter than expected data blob will allow for the `$authTag` to have as short a tag as only one byte (see [PHP's documentation](https://www.php.net/manual/en/function.openssl-decrypt.php#:~:text=The%20length%20of%20the%20tag%20is%20not%20checked%20by%20the%20function.%20It%20is%20the%20caller%27s%20responsibility%20to%20ensure%20that%20the%20length%20of%20the%20tag%20matches%20the%20length%20of%20the%20tag%20retrieved%20when%20openssl_encrypt()%20has%20been%20called.%20Otherwise%20the%20decryption%20may%20succeed%20if%20the%20given%20tag%20only%20matches%20the%20start%20of%20the%20proper%20tag.)).\n\nSee this example:\n```php\nfunction test($data) {\n    $ivSize = 12;\n    $tagSize = 16;\n\n    $iv = substr($data, 0, $ivSize);\n    $data = substr($data, $ivSize);\n    $offset = 0 - $tagSize;\n    $tag = substr($data, $offset);\n    $ct = substr($data, 0, $offset);\n\n    echo 'IV: \"' . $iv . '\"' . PHP_EOL;\n    echo 'Tag: \"' . $tag . '\"' . PHP_EOL;\n    echo 'CT: \"' . $ct . '\"' . PHP_EOL;\n}\n\n/* Outputs:\nphp > test('myNonceNoncet');\nIV: \"myNonceNonce\"\nTag: \"t\"\nCT: \"\"\nphp > test('myNonceNonceta');\nIV: \"myNonceNonce\"\nTag: \"ta\"\nCT: \"\"\nphp > test('myNonceNoncetag');\nIV: \"myNonceNonce\"\nTag: \"tag\"\nCT: \"\"\n*/\n```\n\nWith a legit ciphertext in hand, this is enough to recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of).\nWith that key, any authenticated tags can be computed offline which allows for decryption of the ciphertext and forgery of arbitrary ciphertexts.\n\n### PoC\n1. Setup a server expecting XML with an encrypted assertion\n    - Run this php script [poc.php](https://github.com/user-attachments/files/24426600/poc.php.txt) with `php -S 127.0.0.1:8888` (taken from [this saml test case](https://github.com/robrichards/xmlseclibs/blob/69fd63080bc47a8d51bc101c30b7cb756862d1d6/tests/saml/saml-decrypt.phpt#L62))\n    - The script expects this private key: [sp-private-key.pem.](https://github.com/user-attachments/files/24426620/sp-private-key.pem.txt)\n2. Create an XML document with an encrypted assertion (encrypted with `aes-256-gcm`)\n    - Here is the `SAMLResponse` used in the video below: [saml_response.txt](https://github.com/user-attachments/files/24426638/saml_response.txt)\n\n**Note:** The steps from 3 to 6 are implemented in this exploit script: [nonce_reuse_with_fmt_val_oracle.py](https://github.com/user-attachments/files/24426645/nonce_reuse_with_fmt_val_oracle.py).\nYou can run the script with `sage -python nonce_reuse_with_fmt_val_oracle.py -s 'url-encoded_and_base64-encoded_samlresponse'`\n\n3. Take the content of the `<xenc:CipherValue>` node and apply the following modifications\n    1. Base64-decode the content\n    2. Take the first 12 bytes and save them as the nonce\n    3. Take the last 16 bytes and save them as the tag\n    4. Now brute-force the tag of an empty ciphertext\n        1. Loop through all 256 possible byte values (let's call that `byte_tag_attempt`)\n        2. Concatenate together the nonce and the `byte_tag_attempt`\n        3. Base64-encode the result\n        4. Replace the content of the `<xenc:CipherValue>` node with this result\n        5. On http errors 500, we learn that the tag is valid\n        6. Do the same for the next byte of the tag until all 16 bytes have been brute-forced\n4. With this new tag and the empty ciphertext, compute the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) (the way to do this has been described in this [blog post](https://frereit.de/aes_gcm/))\n5. Use this [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) to compute authentication tags offline for arbitrary ciphertexts\n6. Decryption is done by observing XML parsing errors that occur after modifying the ciphertext, those can be seen as http errors 500\n\n[poc.webm](https://github.com/user-attachments/assets/2f6e4a7e-4384-4350-b423-7ddd77aa9152)\n\n\n### Impact\nThe general impact is:\n- XML nodes encrypted with AES-GCM can be decrypted by observing parsing differences\n- XML nodes encrypted with AES-GCM can be modified to decrypt to an arbitrary value\n- The GCM internal [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) can be recovered\n\nIn cases where the encryption key is embedded in the XML and is encrypted with the Service Provider's public key (like often done with SAML), the last two items don't have a big impact.\nThis is because: \n- With the Service Provider's public key, an arbitrary ciphertext can be created with a known symmetric key\n- The symmetric keys are generated on the fly every time the IdP creates a new `SAMLResponse`\n\nIn any case, secrets that are embedded in the XML, whether coming from an IdP, or from another scheme, can be decrypted.\n\n**Important:** If static symmetric keys are used, as the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) could have leaked, you must rotate those keys.\n\n### References\nFor additional information on the issue, you can refer to this [blog post](https://sideni.xyz/posts/exploiting_openssl_api/) about the OpenSSL issue and how it can be exploited.",
                    "title": "osv - https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/Packagist%2FGHSA-4v26-v6cg-g6f9.json?alt=media"
                },
                {
                    "category": "description",
                    "text": "xmlseclibs is a library written in PHP for working with XML Encryption and Signatures. Prior to 3.1.5, XML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length. An attacker can use this to brute-force an authentication tag, recover the GHASH key, and decrypt the encrypted nodes. It also allows to forge arbitrary ciphertexts without knowing the encryption key. This vulnerability is fixed in 3.1.5.",
                    "title": "nvd - https://nvd.nist.gov/vuln/detail/CVE-2026-32313"
                },
                {
                    "category": "description",
                    "text": "### Summary\nXML nodes encrypted with either aes-128-gcm, aes-192-gcm, or aes-256-gcm lack validation of the authentication tag length.\nAn attacker can use this to brute-force an authentication tag, recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of), and decrypt the encrypted nodes.\nIt also allows to forge arbitrary ciphertexts without knowing the encryption key.\n\n### Details\nWhen decrypting with either aes-128-gcm, aes-192-gcm, or aes-256-gcm [here](https://github.com/robrichards/xmlseclibs/blob/2bdfd742624d739dfadbd415f00181b4a77aaf07/src/XMLSecurityKey.php#L467-L479), the `$authTag` is set from a `substr()`, but never has its length validated (it should be validated with something like `strlen($authTag) == self::AUTHTAG_LENGTH`).\nFor that reason, a shorter than expected data blob will allow for the `$authTag` to have as short a tag as only one byte (see [PHP's documentation](https://www.php.net/manual/en/function.openssl-decrypt.php#:~:text=The%20length%20of%20the%20tag%20is%20not%20checked%20by%20the%20function.%20It%20is%20the%20caller%27s%20responsibility%20to%20ensure%20that%20the%20length%20of%20the%20tag%20matches%20the%20length%20of%20the%20tag%20retrieved%20when%20openssl_encrypt()%20has%20been%20called.%20Otherwise%20the%20decryption%20may%20succeed%20if%20the%20given%20tag%20only%20matches%20the%20start%20of%20the%20proper%20tag.)).\n\nSee this example:\n```php\nfunction test($data) {\n    $ivSize = 12;\n    $tagSize = 16;\n\n    $iv = substr($data, 0, $ivSize);\n    $data = substr($data, $ivSize);\n    $offset = 0 - $tagSize;\n    $tag = substr($data, $offset);\n    $ct = substr($data, 0, $offset);\n\n    echo 'IV: \"' . $iv . '\"' . PHP_EOL;\n    echo 'Tag: \"' . $tag . '\"' . PHP_EOL;\n    echo 'CT: \"' . $ct . '\"' . PHP_EOL;\n}\n\n/* Outputs:\nphp > test('myNonceNoncet');\nIV: \"myNonceNonce\"\nTag: \"t\"\nCT: \"\"\nphp > test('myNonceNonceta');\nIV: \"myNonceNonce\"\nTag: \"ta\"\nCT: \"\"\nphp > test('myNonceNoncetag');\nIV: \"myNonceNonce\"\nTag: \"tag\"\nCT: \"\"\n*/\n```\n\nWith a legit ciphertext in hand, this is enough to recover the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of).\nWith that key, any authenticated tags can be computed offline which allows for decryption of the ciphertext and forgery of arbitrary ciphertexts.\n\n### PoC\n1. Setup a server expecting XML with an encrypted assertion\n    - Run this php script [poc.php](https://github.com/user-attachments/files/24426600/poc.php.txt) with `php -S 127.0.0.1:8888` (taken from [this saml test case](https://github.com/robrichards/xmlseclibs/blob/69fd63080bc47a8d51bc101c30b7cb756862d1d6/tests/saml/saml-decrypt.phpt#L62))\n    - The script expects this private key: [sp-private-key.pem.](https://github.com/user-attachments/files/24426620/sp-private-key.pem.txt)\n2. Create an XML document with an encrypted assertion (encrypted with `aes-256-gcm`)\n    - Here is the `SAMLResponse` used in the video below: [saml_response.txt](https://github.com/user-attachments/files/24426638/saml_response.txt)\n\n**Note:** The steps from 3 to 6 are implemented in this exploit script: [nonce_reuse_with_fmt_val_oracle.py](https://github.com/user-attachments/files/24426645/nonce_reuse_with_fmt_val_oracle.py).\nYou can run the script with `sage -python nonce_reuse_with_fmt_val_oracle.py -s 'url-encoded_and_base64-encoded_samlresponse'`\n\n3. Take the content of the `<xenc:CipherValue>` node and apply the following modifications\n    1. Base64-decode the content\n    2. Take the first 12 bytes and save them as the nonce\n    3. Take the last 16 bytes and save them as the tag\n    4. Now brute-force the tag of an empty ciphertext\n        1. Loop through all 256 possible byte values (let's call that `byte_tag_attempt`)\n        2. Concatenate together the nonce and the `byte_tag_attempt`\n        3. Base64-encode the result\n        4. Replace the content of the `<xenc:CipherValue>` node with this result\n        5. On http errors 500, we learn that the tag is valid\n        6. Do the same for the next byte of the tag until all 16 bytes have been brute-forced\n4. With this new tag and the empty ciphertext, compute the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) (the way to do this has been described in this [blog post](https://frereit.de/aes_gcm/))\n5. Use this [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) to compute authentication tags offline for arbitrary ciphertexts\n6. Decryption is done by observing XML parsing errors that occur after modifying the ciphertext, those can be seen as http errors 500\n\n[poc.webm](https://github.com/user-attachments/assets/2f6e4a7e-4384-4350-b423-7ddd77aa9152)\n\n\n### Impact\nThe general impact is:\n- XML nodes encrypted with AES-GCM can be decrypted by observing parsing differences\n- XML nodes encrypted with AES-GCM can be modified to decrypt to an arbitrary value\n- The GCM internal [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) can be recovered\n\nIn cases where the encryption key is embedded in the XML and is encrypted with the Service Provider's public key (like often done with SAML), the last two items don't have a big impact.\nThis is because: \n- With the Service Provider's public key, an arbitrary ciphertext can be created with a known symmetric key\n- The symmetric keys are generated on the fly every time the IdP creates a new `SAMLResponse`\n\nIn any case, secrets that are embedded in the XML, whether coming from an IdP, or from another scheme, can be decrypted.\n\n**Important:** If static symmetric keys are used, as the [GHASH key](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of) could have leaked, you must rotate those keys.\n\n### References\nFor additional information on the issue, you can refer to this [blog post](https://sideni.xyz/posts/exploiting_openssl_api/) about the OpenSSL issue and how it can be exploited.",
                    "title": "github - https://api.github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "other",
                    "text": "0.00025",
                    "title": "EPSS"
                },
                {
                    "category": "other",
                    "text": "3.8",
                    "title": "NCSC Score"
                },
                {
                    "category": "other",
                    "text": "There is exploit data available from source Nvd, There is cwe data available from source Nvd, Exploit code publicly available",
                    "title": "NCSC Score top decreasing factors"
                }
            ],
            "product_status": {
                "known_affected": [
                    "CSAFPID-5825959",
                    "CSAFPID-4469520",
                    "CSAFPID-4469521",
                    "CSAFPID-4469522",
                    "CSAFPID-4469523",
                    "CSAFPID-4469524",
                    "CSAFPID-4469525",
                    "CSAFPID-4469526",
                    "CSAFPID-4469527",
                    "CSAFPID-5238956",
                    "CSAFPID-5238957",
                    "CSAFPID-5238958",
                    "CSAFPID-5238959",
                    "CSAFPID-5238960",
                    "CSAFPID-5827344",
                    "CSAFPID-5238949",
                    "CSAFPID-5238950",
                    "CSAFPID-5238951",
                    "CSAFPID-5238952",
                    "CSAFPID-5238953",
                    "CSAFPID-5238954",
                    "CSAFPID-5238955",
                    "CSAFPID-5828138",
                    "CSAFPID-5839261"
                ]
            },
            "references": [
                {
                    "category": "external",
                    "summary": "Source - cveprojectv5",
                    "url": "https://www.cve.org/CVERecord?id=CVE-2026-32313"
                },
                {
                    "category": "external",
                    "summary": "Source raw - cveprojectv5",
                    "url": "https://raw.githubusercontent.com/CVEProject/cvelistV5/main/cves/2026/32xxx/CVE-2026-32313.json"
                },
                {
                    "category": "external",
                    "summary": "Source - github",
                    "url": "https://github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "external",
                    "summary": "Source raw - github",
                    "url": "https://api.github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "external",
                    "summary": "Source - first",
                    "url": "https://api.first.org/data/v1/epss?cve=CVE-2026-32313"
                },
                {
                    "category": "external",
                    "summary": "Source raw - first",
                    "url": "https://api.first.org/data/v1/epss?limit=10000&offset=0"
                },
                {
                    "category": "external",
                    "summary": "Source - osv",
                    "url": "https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/GIT%2FCVE-2026-32313.json?alt=media"
                },
                {
                    "category": "external",
                    "summary": "Source - osv",
                    "url": "https://www.googleapis.com/download/storage/v1/b/osv-vulnerabilities/o/Packagist%2FGHSA-4v26-v6cg-g6f9.json?alt=media"
                },
                {
                    "category": "external",
                    "summary": "Source - nvd",
                    "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-32313"
                },
                {
                    "category": "external",
                    "summary": "Source raw - nvd",
                    "url": "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-32313"
                },
                {
                    "category": "external",
                    "summary": "Source - github",
                    "url": "https://api.github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "external",
                    "summary": "Source - first",
                    "url": "https://api.first.org/data/v1/epss?limit=10000&offset=0"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; nvd; osv",
                    "url": "https://github.com/robrichards/xmlseclibs/security/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; nvd; osv",
                    "url": "https://github.com/robrichards/xmlseclibs/commit/03062be78178cbb5e8f605cd255dc32a14981f92"
                },
                {
                    "category": "external",
                    "summary": "Reference - cveprojectv5; github; nvd; osv",
                    "url": "https://github.com/robrichards/xmlseclibs/releases/tag/3.1.5"
                },
                {
                    "category": "external",
                    "summary": "Reference - github",
                    "url": "https://github.com/advisories/GHSA-4v26-v6cg-g6f9"
                },
                {
                    "category": "external",
                    "summary": "Reference - osv",
                    "url": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/32xxx/CVE-2026-32313.json"
                },
                {
                    "category": "external",
                    "summary": "Reference - github; osv",
                    "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-32313"
                }
            ],
            "scores": [
                {
                    "cvss_v3": {
                        "version": "3.1",
                        "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N",
                        "baseScore": 8.2,
                        "baseSeverity": "HIGH"
                    },
                    "products": [
                        "CSAFPID-4469520",
                        "CSAFPID-4469521",
                        "CSAFPID-4469522",
                        "CSAFPID-4469523",
                        "CSAFPID-4469524",
                        "CSAFPID-4469525",
                        "CSAFPID-4469526",
                        "CSAFPID-4469527",
                        "CSAFPID-5238949",
                        "CSAFPID-5238950",
                        "CSAFPID-5238951",
                        "CSAFPID-5238952",
                        "CSAFPID-5238953",
                        "CSAFPID-5238954",
                        "CSAFPID-5238955",
                        "CSAFPID-5238956",
                        "CSAFPID-5238957",
                        "CSAFPID-5238958",
                        "CSAFPID-5238959",
                        "CSAFPID-5238960",
                        "CSAFPID-5825959",
                        "CSAFPID-5827344",
                        "CSAFPID-5828138",
                        "CSAFPID-5839261"
                    ]
                }
            ],
            "title": "CVE-2026-32313"
        }
    ]
}