VYPR
Critical severity9.8NVD Advisory· Published Apr 24, 2026· Updated Apr 28, 2026

CVE-2026-41681

CVE-2026-41681

Description

rust-openssl provides OpenSSL bindings for the Rust programming language. From 0.10.39 to before 0.10.78, EVP_DigestFinal() always writes EVP_MD_CTX_size(ctx) to the out buffer. If out is smaller than that, MdCtxRef::digest_final() writes past its end, usually corrupting the stack. This is reachable from safe Rust. This vulnerability is fixed in 0.10.78.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
opensslcrates.io
>= 0.10.39, < 0.10.780.10.78

Affected products

1

Patches

1
826c3888b77a

Error for short out in MdCtxRef::digest_final() (#2608)

https://github.com/rust-openssl/rust-opensslTheo BuehlerApr 19, 2026via ghsa
1 file changed · +13 0
  • openssl/src/md_ctx.rs+13 0 modified
    @@ -242,6 +242,10 @@ impl MdCtxRef {
         pub fn digest_final(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack> {
             let mut len = u32::try_from(out.len()).unwrap_or(u32::MAX);
     
    +        if self.size() > len as usize {
    +            return Err(ErrorStack::get());
    +        }
    +
             unsafe {
                 cvt(ffi::EVP_DigestFinal(
                     self.as_ptr(),
    @@ -549,4 +553,13 @@ mod test {
             // Validate result of digest of "World"
             assert_eq!(reset_result, world_expected);
         }
    +
    +    #[test]
    +    fn digest_final_checks_length() {
    +        let mut ctx = MdCtx::new().unwrap();
    +        ctx.digest_init(Md::sha256()).unwrap();
    +        ctx.digest_update(b"Some Crypto Text").unwrap();
    +        let mut digest = [0; 16];
    +        assert!(ctx.digest_final(&mut digest).is_err());
    +    }
     }
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

6

News mentions

0

No linked articles in our index yet.