Skip to content

Missing MAX_PACKET_SIZE check in BPP layer allows memory exhaustion from malicious server #2626

Open

Description

@igorg1312

Summary

The read_message() function in packet.py does not validate
packet_size against a maximum value before calling read_all().

A malicious SSH server can send a BPP packet with packet_size = 0xFFFFFFFF
(4GB), causing the client to attempt reading 4GB from the socket,
resulting in indefinite blocking or memory exhaustion.

Location

paramiko/packet.py — read_message():

packet_size = struct.unpack(">I", header[:4])[0]
# No maximum size check here
buf = self.read_all(packet_size + self.__mac_size_in - len(leftover))

Suggested Fix

Add a check before allocating:

MAX_BPP_PACKET_SIZE = 35000  # OpenSSH default
if packet_size > MAX_BPP_PACKET_SIZE:
    raise SSHException(f"Packet too large: {packet_size}")

Impact

  • Prerequisite: connection to a malicious SSH server
  • Effect: client process blocks indefinitely or exhausts memory
  • Severity: Low/Medium hardening suggestion

Environment

  • paramiko 2.11.0
  • Python 3.x

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions