Security Advisories (2)
CVE-2026-57080 (2026-06-30)

Net::BitTorrent versions through 2.1.0 for Perl allow remote memory exhaustion via an uncapped peer-wire message-length prefix. The peer-wire framing in _process_messages trusts the 4-byte length prefix sent by a connected peer with no upper bound, while receive_data appends every inbound byte to the input buffer. A peer announces a length prefix of up to about 4 GiB and then streams bytes; the decoder waits until the buffer holds the full message before processing it, so the buffer grows without limit. Peer connections are unauthenticated, so any peer in the swarm exhausts the downloading process's memory. The largest legitimate message is a 16 KiB piece block, so any announced length far above that is anomalous.

CVE-2026-57081 (2026-06-30)

Net::BitTorrent versions through 2.1.0 for Perl allow remote memory exhaustion via deeply nested bencoded input. bdecode recurses once per nested list or dictionary level with no depth cap, and each recursive call receives the remaining buffer by value while the list and dictionary branches capture the whole remainder, so every live recursion frame keeps its own copy of the shrinking buffer (O(N^2) bytes for an N-deep input). The decoder runs on every untrusted bencode source: .torrent files, BEP09 metadata fetched from peers, DHT messages, and tracker responses. A bencoded input of roughly 150,000 nested lists (about 150 KB on the wire) drives multi-gigabyte peak memory, so one short message from any peer, or one crafted .torrent file or magnet link, terminates the client.

NAME

Net::BitTorrent::Protocol::BEP09 - Metadata Exchange Implementation

SYNOPSIS

# Inherits from Net::BitTorrent::Protocol::BEP10 (Extension Protocol)
use Net::BitTorrent::Protocol::BEP09;

my $proto = Net::BitTorrent::Protocol::BEP09->new(...);

# Request segment 0 of the info dictionary
$proto->send_metadata_request(0);

# Handle incoming metadata pieces
$proto->on(metadata_data => sub ( $emitter, $piece, $total, $data ) {
    say "Received metadata piece $piece of $total";
});

DESCRIPTION

Net::BitTorrent::Protocol::BEP09 implements the Extension for Peers to Send Metadata Files (BEP 09). This is the protocol that makes Magnet Links work by allowing a client to download the torrent's info dictionary directly from other peers when the local .torrent file is missing.

It works as a sub-protocol of the Extension Protocol (BEP 10), using the ut_metadata message name.

METHODS

send_metadata_request( $piece )

Sends a metadata piece request.

$proto->send_metadata_request( 0 );

This method sends a ut_metadata request for a 16KiB segment of the torrent's metadata.

Expected parameters:

$piece

The zero-based metadata piece index.

send_metadata_data( $piece, $total_size, $data )

Sends a metadata piece.

$proto->send_metadata_data( 0, 32768, $piece_data );

This method provides a segment of the info dictionary to a peer in response to a request.

Expected parameters:

$piece

The metadata piece index.

$total_size

The full length of the bencoded info dictionary in bytes.

$data

The raw 16KiB piece data.

send_metadata_reject( $piece )

Rejects a metadata request.

$proto->send_metadata_reject( 0 );

This method informs the peer that the requested metadata segment cannot be provided.

Expected parameters:

$piece

The metadata piece index.

metadata_request event

Emitted when a metadata request is received.

$proto->on( metadata_request => sub ( $self, $piece ) { ... } );

Expected parameters:

$piece

The requested metadata piece index.

metadata_data event

Emitted when metadata data is received.

$proto->on( metadata_data => sub ( $self, $piece, $total_size, $data ) { ... } );

Expected parameters:

$piece

The metadata piece index.

$total_size

The total size of the metadata.

$data

The received piece data.

metadata_reject event

Emitted when a metadata request is rejected.

$proto->on( metadata_reject => sub ( $self, $piece ) { ... } );

Expected parameters:

$piece

The piece index that was rejected.

SPECIFICATIONS

  • BEP 09: Extension for Peers to Send Metadata Files

AUTHOR

Sanko Robinson - https://github.com/sanko

COPYRIGHT

Copyright (C) 2008-2026 by Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.