Skip to content

publickey: cap variable-length packet element sizes - #2207

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pubkey-more-caps
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pubkey-more-caps

Conversation

@vszakats

@vszakats vszakats commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

To avoid potential offset wrap in 32-bit builds when receiving overly
large values in length fields. Limit them to the maximum packet size.

Bug: #2205 (comment)


In a next patch it'd probably be worth it to factor out the heavy boilerplate
into local function(s) or macro(s).

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 hardens publickey subsystem packet parsing by adding explicit caps for variable-length fields, preventing oversized length values from being used in subsequent bounds calculations.

Changes:

  • Add LIBSSH2_PACKET_MAXPAYLOAD upper bounds checks for status packet descr_len and lang_len during publickey_init().
  • Add the same caps during libssh2_publickey_list_fetch() for status packet fields and key list elements (comment_len, name_len, blob_len, attribute name_len/value_len).

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

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