# CVE-2021-21239: Open default xmlsec1 key-type preference

> Attackers can bypass SAML signature verification in PySAML2 by exploiting default xmlsec1 key-type preferences, allowing forged authentication assertions.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 21 Jan 2021
- **Updated:** 3 Aug 2024
- **Also known as:** DEBIAN-CVE-2021-21239, GHSA-5p3x-r448-pc62, PYSEC-2021-49, UBUNTU-CVE-2021-21239, USN-5066-1, USN-5066-2

## What is CVE-2021-21239?

CVE-2021-21239 is a medium-severity vulnerability in Debian Debian Linux, published on 21 Jan 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

PySAML2 is a pure python implementation of SAML Version 2 Standard. PySAML2 before 6.5.0 has an improper verification of cryptographic signature vulnerability. Users of pysaml2 that use the default CryptoBackendXmlSec1 backend and need to verify signed SAML documents are impacted. PySAML2 does not ensure that a signed SAML document is correctly signed. The default CryptoBackendXmlSec1 backend is using the xmlsec1 binary to verify the signature of signed SAML documents, but by default xmlsec1 accepts any type of key found within the given document. xmlsec1 needs to be configured explicitly to only use only _x509 certificates_ for the verification process of the SAML document signature. This is fixed in PySAML2 6.5.0.

Weakness: CWE-347 (Improper Verification of Cryptographic Signature)

## Which versions are affected by CVE-2021-21239?

3 open source packages ship an affected version, including pysaml2. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pysaml2` | PyPI | All versions | 6.5.0 |
| `pysaml2` | PyPI | All versions | 6.5.0 |
| `pysaml2` | PyPI | All versions | 6.5.0 |

Products: Debian Debian Linux, Pysaml2 Project Pysaml2.

## How do I fix CVE-2021-21239?

Upgrade pysaml2 to 6.5.0 or later.

## Is CVE-2021-21239 being exploited?

There is no known exploitation of CVE-2021-21239 in the wild and no public exploit code.

Public exploit code:

- Report documentation of this script is below (github_poc): https://github.com/RyanBoomer30/CVE-2021-21239-Exploit
- A Dockerized Redash instance that is vulnerable to CVE-2021-21239 (github_poc): https://github.com/GrantBirki/redash-vulnerable
- https://github.com/illera88/CVE-2021-21239 (github_poc): https://github.com/illera88/CVE-2021-21239
- A script to exploit a vulnerability in xmlsec1 where xmlsec ignores loaded public keys (github_poc): https://github.com/Crims-on/CVE-2021-21239

## Other vulnerabilities in Debian Debian Linux

- [CVE-2015-3306](https://insights.sbomify.com/CVE-2015-3306/): ProFTPD Improper Access Control (critical 10.0, exploited in the wild)
- [CVE-2025-49113](https://insights.sbomify.com/CVE-2025-49113/): RoundCube Webmail Deserialization of Untrusted Data (critical 9.9, exploited in the wild)
- [CVE-2026-24061](https://insights.sbomify.com/CVE-2026-24061/): GNU InetUtils Argument Injection (critical 9.8, exploited in the wild)
- [CVE-2025-39682](https://insights.sbomify.com/CVE-2025-39682/): Linux Kernel Improper Check for Unusual or Exceptional Conditions (critical 9.8, exploited in the wild)
- [CVE-2024-9680](https://insights.sbomify.com/CVE-2024-9680/): Mozilla Firefox Use-After-Free (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21239 and fix it if it is affected.

What it is: CVE-2021-21239 is a medium-severity vulnerability in Debian Debian Linux, published on 21 Jan 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-21239 in the wild and no public exploit code.

Affected packages and fixed versions:
- pysaml2 (PyPI): affected all versions; fixed in 6.5.0
- pysaml2 (PyPI): affected all versions; fixed in 6.5.0
- pysaml2 (PyPI): affected all versions; fixed in 6.5.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-21239/ (Markdown: https://insights.sbomify.com/CVE-2021-21239/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-21239
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-21239
- OSV: https://osv.dev/vulnerability/CVE-2021-21239

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-21239/
Summaries are generated and may contain mistakes; the official description above is the record.
