Skip to main content

libssh CVE-2025-4878

LOW
Use After Free (CWE-416)
2025-07-22 secalert@redhat.com
3.6
CVSS 3.1 · Vendor: redhat
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Local user access
  2. Delivery
    Craft non-existent key filename
  3. Exploit
    Call privatekey_from_file() with crafted path
  4. Execution
    Trigger uninitialized variable read
  5. Persist
    Heap corruption or data leak
  6. Impact
    Disrupt SSH authentication or leak sensitive memory

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Memory lifecycle management
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Privilege Escalation

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

The vulnerability requires the following specific conditions: (1) libssh's privatekey_from_file() function must be called by an application with a filename parameter that references a non-existent file; (2) the caller must be a local user (not remote) with authenticated access to the system; (3) the application must not validate the filename before passing it to libssh. The flaw does NOT require non-default configuration or special compilation flags - it exists in standard libssh builds. However, exploitation is limited to scenarios where an attacker can influence the filename parameter passed to privatekey_from_file(). Applications that only load hardcoded or administrator-controlled key paths are not vulnerable. The high CVSS complexity factor (AC:H) reflects that heap layout must be in a particular state for meaningful exploitation; reliable exploitation of memory corruption is non-trivial without detailed knowledge of the target application's heap behavior.

Impact

Real-world risk is LOW to MODERATE despite the concerning CWE-416 (use-after-free). Multiple signals support this assessment: CVSS 3.6 is below the critical threshold, attack vector is LOCAL (not network-accessible), privilege requirement is LOW (authenticated user), and attack complexity is HIGH. The vulnerability requires an authenticated attacker with local access who can trigger a specific code path by providing a non-existent filename to an application using libssh's privatekey_from_file(). EPSS data is unavailable for comparison, but the combination of local-only access, authentication requirement, and high complexity significantly constrains real-world exploitability compared to a network-reachable use-after-free. KEV status is unknown, indicating this may not be actively exploited at scale. However, the CWE-416 classification is serious - use-after-free vulnerabilities can escalate to code execution under specific heap conditions, though the CVSS score (which omits code execution from the impact assessment) suggests the vendor assesses practical impact as limited to confidentiality and integrity of the SSH signing operation. Risk is elevated in scenarios where libssh handles untrusted filename inputs from local users, particularly in privilege-separated SSH utilities or configuration management tools.

Exploit ScenarioDerived

A local authenticated user on a system running an application that uses libssh (e.g., a configuration management tool or privilege-separated SSH utility) supplies a non-existent filename path to the application's key-loading functionality. The application calls libssh's privatekey_from_file() with this path, triggering the uninitialized variable condition. Depending on heap state, the attacker may leak sensitive data from memory or corrupt heap structures, potentially disrupting SSH authentication or triggering a crash. While direct remote exploitation is not possible, a local attacker could chain this with other vectors to escalate privileges or disrupt services.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
No patch listed yet 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 06, 2026

Uninitialized variable in libssh's privatekey_from_file() function can cause heap corruption or signing failures when a non-existent key file is specified, allowing local authenticated attackers to trigger memory corruption with potential for information disclosure. CVSS 3.6 reflects local attack vector and high complexity; exploitation requires authenticated access and specific file conditions.

RemediationAI

Apply the upstream fix by upgrading libssh to a version containing commit 697650caa97eaf7623924c75f9fcfec6dd423cd1 or b35ee876adc92a208d47194772e99f9c71e0bedb, or use the next stable release after these patches are integrated. For distribution packages, follow https://access.redhat.com/security/cve/CVE-2025-4878 for Red Hat/CentOS updates or equivalent vendor advisories for other distributions. If immediate patching is not possible, mitigate by ensuring that applications using libssh validate filenames before passing them to privatekey_from_file() and do not accept untrusted filename inputs from local users; however, this workaround relies on application-level validation and does not address the underlying library flaw. Additionally, restrict local access to systems running vulnerable libssh instances and apply the principle of least privilege to processes using libssh authentication.

Affected ProductsAI

libssh is affected in versions prior to the patches identified in commits 697650caa97eaf7623924c75f9fcfec6dd423cd1 and b35ee876adc92a208d47194772e99f9c71e0bedb. No specific version ranges are provided in the available data; however, the upstream commits represent the fixes. CPE identifiers for libssh should be checked against the Red Hat security advisory at https://access.redhat.com/security/cve/CVE-2025-4878 and the libssh advisory at https://www.libssh.org/security/advisories/CVE-2025-4878.txt for precise affected version ranges and distribution-specific patched versions.

Affects your stack

Find out whether the stacks and servers you run are on an affected version.

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

libssh is a C SSH client library that implements the SSH protocol for secure remote shell access. The vulnerability exists in the privatekey_from_file() function, which handles loading private key files for authentication. When a filename parameter references a non-existent file, the function fails to properly initialize a variable before use, creating a use-after-free (CWE-416) condition. This uninitialized memory can contain residual heap data, leading to either memory corruption when the uninitialized variable is dereferenced, or information disclosure if the uninitialized data is read. The flaw is particularly dangerous in multi-threaded environments or scenarios where heap state is predictable, as attackers may be able to influence what data resides in the uninitialized memory location.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (redhat) PRIMARY 3.6 LOW
AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N

Primary rating from Vendor (redhat) · only source for this CVE.

CVSS VectorVendor: redhat

Attack Vector
Local
Attack Complexity
High
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
None

DescriptionCVE.org

A vulnerability was found in libssh, where an uninitialized variable exists under certain conditions in the privatekey_from_file() function. This flaw can be triggered if the file specified by the filename doesn't exist and may lead to possible signing failures or heap corruption.

Threat Intelligence Overview

EPSS Score
0.0%
Top 91% exploitable
Data Quality
3 sources
Confidence: Low

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.0%
Patch available No
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Defer
Exploitation· derived
None
System Exposure· derived
Small
Automatable· derived
No
Human Impact· derived
Low

Priority Score

18
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +18
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Use-after-free vulnerabilities occur when a program continues to access memory through a pointer after that memory has been deallocated.

Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.

Information disclosure occurs when an application unintentionally exposes sensitive data that aids attackers in reconnaissance or directly compromises security.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy