CVE-2026-32313: xmlseclibs Missing AES-GCM Authentication Tag Validation Vulnerability

HIGH
Advisory Identifier: GHSA-4v26-v6cg-g6f9
CVSS 8.2
CWE-354
Published
Advisory Summary

CVE-2026-32313 is a HIGH (CVSS 8.2) missing aes-gcm authentication tag validation vulnerability (CWE-354: Improper Validation of Integrity Check Value) affecting xmlseclibs libraries in the Packagist ecosystem. The issue involves missing aes-gcm authentication tag validation on encrypted nodes allows for unauthorized decryption. Remediation is available by upgrading affected packages to version 3.1.5.

CVE-2026-32313 at a Glance

CVE Identifier CVE-2026-32313
GHSA Identifier GHSA-4v26-v6cg-g6f9
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-354: Improper Validation of Integrity Check Value
Affected Product xmlseclibs
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-32313

To remediate this vulnerability, upgrade all affected xmlseclibs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

robrichards/xmlseclibs fixed: 3.1.5
Upgrade robrichards/xmlseclibs to 3.1.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for robrichards/xmlseclibs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-32313, inspect your project dependencies for xmlseclibs:

inspect dependencies for robrichards/xmlseclibs

Analyze the terminal output to locate any version of xmlseclibs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-354: Improper Validation of Integrity Check Value, where the product does not validate or incorrectly validates the integrity check values or "checksums" of a message. this may prevent it from detecting if the data has been modified or corrupted in transmission. In xmlseclibs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary 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](https://en.wikipedia.org/wiki/Galois/Counter_Mode#:~:text=%29%20is%20the-,hash%20key,-%2C%20a%20string%20of), and decrypt the encrypted nodes. It also allows to forge arbitrary ciphertexts without knowing the encryption key. ### Details When 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`). For 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.)). See this example: ```php function test($data) { $ivSize = 12; $tagSize = 16; $iv = substr($data, 0, $ivSize); $data = substr($data, $ivSize); $offset = 0 - $tagSize; $tag = substr($data, $offset); $ct = substr($data, 0, $offset); echo 'IV: "' . $iv . '"' . PHP_EOL; echo 'Tag: "' . $tag . '"' . PHP_EOL; echo 'CT: "' . $ct . '"' . PHP_EOL; } /* Outputs: php > test('myNonceNoncet'); IV: "myNonceNonce" Tag: "t" CT: "" php > test('myNonceNonceta'); IV: "myNonceNonce" Tag: "ta" CT: "" php > test('myNonceNoncetag'); IV: "myNonceNonce" Tag: "tag" CT: "" */ ``` With 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). With that key, any authenticated tags can be computed offline which allows for decryption of the ciphertext and forgery of arbitrary ciphertexts. ### PoC 1. Setup a server expecting XML with an encrypted assertion - 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)) - The script expects this private key: [sp-private-key.pem.](https://github.com/user-attachments/files/24426620/sp-private-key.pem.txt) 2. Create an XML document with an encrypted assertion (encrypted with `aes-256-gcm`) - Here is the `SAMLResponse` used in the video below: [saml_response.txt](https://github.com/user-attachments/files/24426638/saml_response.txt) **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). You can run the script with `sage -python nonce_reuse_with_fmt_val_oracle.py -s 'url-encoded_and_base64-encoded_samlresponse'` 3. Take the content of the `<xenc:CipherValue>` node and apply the following modifications 1. Base64-decode the content 2. Take the first 12 bytes and save them as the nonce 3. Take the last 16 bytes and save them as the tag 4. Now brute-force the tag of an empty ciphertext 1. Loop through all 256 possible byte values (let's call that `byte_tag_attempt`) 2. Concatenate together the nonce and the `byte_tag_attempt` 3. Base64-encode the result 4. Replace the content of the `<xenc:CipherValue>` node with this result 5. On http errors 500, we learn that the tag is valid 6. Do the same for the next byte of the tag until all 16 bytes have been brute-forced 4. 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/)) 5. 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 6. Decryption is done by observing XML parsing errors that occur after modifying the ciphertext, those can be seen as http errors 500 [poc.webm](https://github.com/user-attachments/assets/2f6e4a7e-4384-4350-b423-7ddd77aa9152) ### Impact The general impact is: - XML nodes encrypted with AES-GCM can be decrypted by observing parsing differences - XML nodes encrypted with AES-GCM can be modified to decrypt to an arbitrary value - 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 In 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. This is because: - With the Service Provider's public key, an arbitrary ciphertext can be created with a known symmetric key - The symmetric keys are generated on the fly every time the IdP creates a new `SAMLResponse` In any case, secrets that are embedded in the XML, whether coming from an IdP, or from another scheme, can be decrypted. **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. ### References For 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.

CVE-2026-32313 Affected xmlseclibs Versions

1 component(s)
Fixed Versions:
3.1.5
Product / Package Ecosystem Affected Versions Fixed Version
robrichards/xmlseclibs
Packagist
< 3.1.5
3.1.5

References

Frequently Asked Questions

What is CVE-2026-32313?
CVE-2026-32313 is a security vulnerability in xmlseclibs involving Missing AES-GCM Authentication Tag Validation on Encrypted Nodes Allows for Unauthorized Decryption under CWE-354: Improper Validation of Integrity Check Value.
Which xmlseclibs versions are affected?
Affected versions include releases prior to 3.1.5 across affected packages: robrichards/xmlseclibs.
What version fixes CVE-2026-32313?
Upgrading to 3.1.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is robrichards/xmlseclibs affected?
Yes, robrichards/xmlseclibs is affected in releases prior to 3.1.5. Upgrade your dependency to 3.1.5 or later.
What is the CVSS score of CVE-2026-32313?
CVE-2026-32313 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N.
What CWE is associated with CVE-2026-32313?
CVE-2026-32313 is classified under CWE-354: Improper Validation of Integrity Check Value (The product does not validate or incorrectly validates the integrity check values or "checksums" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission.).
How can I check Packagist dependencies for CVE-2026-32313?
Run the dependency tree command: 'inspect dependencies for robrichards/xmlseclibs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4v26-v6cg-g6f9",
  "modified" : "2026-03-16T22:01:02Z",
  "published" : "2026-03-13T20:04:21Z",
  "aliases" : [ "CVE-2026-32313" ],
  "summary" : "xmlseclibs: Missing AES-GCM Authentication Tag Validation on Encrypted Nodes Allows for Unauthorized Decryption",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "robrichards/xmlseclibs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.1.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/robrichards/xmlseclibs/security/advisories/GHSA-4v26-v6cg-g6f9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32313"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/robrichards/xmlseclibs/commit/03062be78178cbb5e8f605cd255dc32a14981f92"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/robrichards/xmlseclibs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/robrichards/xmlseclibs/releases/tag/3.1.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-354" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-13T20:04:21Z",
    "nvd_published_at" : "2026-03-16T14:19:33Z"
  }
}