CVE-2025-7844: wolfTPM library wrapper function `wolfTPM2_RsaKey_TpmToWolf` copies external data to a fixed-size stack buffer without length validation potentially causing stack-based buffer overflow
Exporting a TPM based RSA key larger than 2048 bits from the TPM could overrun a stack buffer if the default MAXRSAKEYBITS=2048 is used. If your TPM 2.0 module supports RSA key sizes larger than 2048 bit and your applications supports creating or importing an RSA private or public key larger than 2048 bits and your application calls wolfTPM2RsaKeyTpmToWolf on that key, then a stack buffer could be overrun. If the MAXRSAKEYBITS build-time macro is set correctly (RSA bits match what TPM hardware is capable of) for the hardware target, then a stack overrun is not possible.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Rebuild wolfTPM with the `MAX_RSA_KEY_BITS` build-time macro set correctly so the RSA key bit size range matches what the TPM 2.0 module can support for the deployment target.
wolfTPM (wolfTPM2_RsaKey_TpmToWolf) MAX_RSA_KEY_BITS = Set to match the TPM hardware’s supported RSA key sizes for the specific build-time hardware target (do not leave default MAX_RSA_KEY_BITS=2048 if TPM supports >2048). - Compensating control
If TPM 2.0 supports RSA key sizes larger than 2048 and applications may create/import RSA keys >2048 and call `wolfTPM2_RsaKey_TpmToWolf` on them, use external controls to prevent those operations (e.g., disallow or block importing/processing RSA keys larger than 2048 bits until `MAX_RSA_KEY_BITS` is set appropriately and length validation is in place).
Event History
Frequently Asked Questions
What is the severity of CVE-2025-7844?
CVE-2025-7844 has not been assigned a specific severity score but poses a risk of stack buffer overflow due to improperly managed RSA key sizes.
How do I fix CVE-2025-7844?
To mitigate CVE-2025-7844, ensure that you configure your TPM to not use RSA keys larger than 2048 bits or upgrade to a more secure implementation if available.
Which software is affected by CVE-2025-7844?
CVE-2025-7844 primarily affects the wolfSSL wolfTPM software when exporting RSA keys larger than 2048 bits.
What happens if I use larger RSA keys with CVE-2025-7844?
Using RSA keys larger than 2048 bits with CVE-2025-7844 may lead to a stack buffer overflow, potentially compromising system integrity.
Is there a workaround for CVE-2025-7844?
A workaround for CVE-2025-7844 is to limit the RSA key size to 2048 bits in affected applications until an official patch is released.