Skip to content

publickey: fix potential OOB read in libssh2_publickey_list_fetch() - #2202

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pubkeyuninitptr
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pubkeyuninitptr

Conversation

@vszakats

@vszakats vszakats commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Reported-by: Vladimir Eli Tokarev
Fixes GHSA-w6g9-cpfp-22gc

Reported-by: Vladimir Eli Tokarev
Fixes GHSA-w6g9-cpfp-22gc

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses GHSA-w6g9-cpfp-22gc by adding a missing length check to prevent a potential out-of-bounds read while parsing comment_len in libssh2_publickey_list_fetch().

Changes:

  • Add a bounds check ensuring the comment field fits within listFetch_data before using it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/publickey.c
Comment on lines +932 to +936
if(pkey->listFetch_s + comment_len >
pkey->listFetch_data + pkey->listFetch_data_len) {
ssh2_err(session, LIBSSH2_ERROR_BUFFER_TOO_SMALL,
"ListFetch data too short");
goto err_exit;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer capping the size to sane values. Also for other similar cases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

→ PRs #2203, #2204, #2207

@vszakats vszakats closed this in a13bb6c Jul 4, 2026
@vszakats
vszakats deleted the pubkeyuninitptr branch July 4, 2026 10:31
shivammathur added a commit to winlibs/libssh2 that referenced this pull request Aug 2, 2026
Backport upstream libssh2 bounds checking for public-key comment lengths in src/publickey.c.

CVE-2026-66034: heap out-of-bounds read via a crafted publickey-subsystem version 1 response, remotely triggerable by a malicious SSH server in libssh2 through 1.11.1.

CWE: CWE-125, CWE-908

CVSS: 4.0/AV:N/AC:H/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N (7.7 HIGH)

Upstream-Commit: a13bb6c773f0d55ad1628cede57e99803cd898d9

Upstream-PR: libssh2/libssh2#2202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants