---
id: CVE-2025-5987
title: >-
  A flaw was found in libssh when using the ChaCha20 cipher with the OpenSSL
  library
summary: >-
  A flaw was found in libssh when using the ChaCha20 cipher with the OpenSSL
  library. If an attacker manages to exhaust the heap space, this error is not
  detected and may lead to libssh using a partially initialized cipher context.
  This oc…
severity: high
cvss: 8.1
cvssVector: 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H'
cwe:
  - CWE-393
vendor: libssh
product: libssh
affected:
  - 'libssh >= 0.10.0, < 0.11.2'
patched:
  - libssh 0.11.2
published: '2025-07-07'
updated: '2026-06-25'
source: NVD
sourceUrl: 'https://nvd.nist.gov/vuln/detail/CVE-2025-5987'
references:
  - url: 'https://access.redhat.com/errata/RHSA-2025:23483'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2025:23484'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0427'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0428'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0430'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0431'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0702'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0978'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0980'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0985'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:0996'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:1539'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:1541'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/errata/RHSA-2026:3415'
    label: secalert@redhat.com
  - url: 'https://access.redhat.com/security/cve/CVE-2025-5987'
    label: secalert@redhat.com
  - url: 'https://bugzilla.redhat.com/show_bug.cgi?id=2376219'
    label: secalert@redhat.com
  - url: 'https://www.libssh.org/security/advisories/CVE-2025-5987.txt'
    label: secalert@redhat.com
tags:
  - nvd
epss: 0.01492
epssPercentile: 0.73015
ingestedAt: '2026-06-29T13:24:34.385Z'
---

## Overview

A flaw was found in libssh when using the ChaCha20 cipher with the OpenSSL library. If an attacker manages to exhaust the heap space, this error is not detected and may lead to libssh using a partially initialized cipher context. This occurs because the OpenSSL error code returned aliases with the SSH_OK code, resulting in libssh not properly detecting the error returned by the OpenSSL library. This issue can lead to undefined behavior, including compromised data confidentiality and integrity or crashes.

## Affected

- `libssh >= 0.10.0, < 0.11.2`

## Remediation

Upgrade past the affected range:

- `libssh 0.11.2`
