Skip to content

userauth: delete no-op code with memleaks in libssh2_userauth_publickey_sk() - #2294

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:userauth-sk-bugmore
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:userauth-sk-bugmore

Conversation

@vszakats

@vszakats vszakats commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

This code section was merged as part of PR #752, which seems to me
unrelated to the intent of the patch, and also possibly unrelated to
the description of its subcommit:
"Add support for certificate signing with ssh-agent"
55abcb0#diff-8213ab9c800f30c1a7aff37863954e756f946a3b3f6bd7be376d634fd9beb9f4R2369

"session->userauth_pblc_method is allocated in the ecdsa/ed25519
branches (lines 2393–2416), but then userauth_read_blob_pubkey is
called immediately afterward with &session->userauth_pblc_method as an
output parameter. Inside userauth_read_blob_pubkey, *method is
unconditionally overwritten with a newly allocated buffer (see the
*method = pubkey assignment), causing the allocation made just above
to be leaked. The allocation in the ecdsa/ed25519 branches should be
removed since userauth_read_blob_pubkey will derive and allocate the
method from the public key data itself."

Reported by GitHub Code Quality

Follow-up to bc4e619 #752
Follow-up to ed439a2 #698


/cc @MichaelBuckley

vszakats added 2 commits July 14, 2026 03:32
"`session->userauth_pblc_method` is allocated in the ecdsa/ed25519
branches (lines 2393–2416), but then `userauth_read_blob_pubkey` is
called immediately afterward with `&session->userauth_pblc_method` as an
output parameter. Inside `userauth_read_blob_pubkey`, `*method` is
unconditionally overwritten with a newly allocated buffer (see the
`*method = pubkey` assignment), causing the allocation made just above
to be leaked. The allocation in the ecdsa/ed25519 branches should be
removed since `userauth_read_blob_pubkey` will derive and allocate the
method from the public key data itself."
"`session->userauth_pblc_method` is allocated in the ecdsa/ed25519
branches (lines 2393–2416), but then `userauth_read_blob_pubkey` is
called immediately afterward with `&session->userauth_pblc_method` as an
output parameter. Inside `userauth_read_blob_pubkey`, `*method` is
unconditionally overwritten with a newly allocated buffer (see the
`*method = pubkey` assignment), causing the allocation made just above
to be leaked. The allocation in the ecdsa/ed25519 branches should be
removed since `userauth_read_blob_pubkey` will derive and allocate the
method from the public key data itself."

Follow-up to bc4e619 libssh2#752
Follow-up to ed439a2 libssh2#698
@vszakats vszakats closed this in cf8164b Jul 14, 2026
@vszakats
vszakats deleted the userauth-sk-bugmore branch July 14, 2026 03:28
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.

1 participant