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::BEP53 - Magnet URI Parser and Generator

SYNOPSIS

use Net::BitTorrent::Protocol::BEP53;

# Parse an incoming URI
my $m = Net::BitTorrent::Protocol::BEP53->parse( $uri_string );

say 'Name: ' . $m->name;
say 'V2 Hash: ' . unpack('H*', $m->infohash_v2) if $m->infohash_v2;

# Generate a new URI
my $new_uri = Net::BitTorrent::Protocol::BEP53->new(
    inf_hash_v2  => $ih2,
    name         => 'Special Linux Distro',
    trackers     => ['udp://tracker.example.com:80']
)->to_string();

DESCRIPTION

Net::BitTorrent::Protocol::BEP53 implements the magnet URI extension (BEP 53). It provides a robust parser and generator for magnet links, specifically updated to support the multihash SHA-256 identifiers required for BitTorrent v2.

Multihash Support

This module correctly identifies and extracts:

v1 (legacy): urn:btih:... (SHA-1)
v2 (modern): urn:btmh:1220... (SHA-256 multihash)

METHODS

parse( $uri )

Parses a Magnet URI string.

my $m = Net::BitTorrent::Protocol::BEP53->parse( $uri );

This method parses the query parameters of a magnet link and returns a new Net::BitTorrent::Protocol::BEP53 object. It handles multihash identifiers (BEP 53).

Expected parameters:

$uri

The Magnet URI string.

to_string( )

Generates a Magnet URI string.

my $uri = $m->to_string();

This method returns the URI-encoded magnet representation of the object's current state.

infohash_v1( )

Returns the 20-byte binary v1 infohash.

my $ih = $m->infohash_v1();

infohash_v2( )

Returns the 32-byte binary v2 infohash.

my $ih = $m->infohash_v2();

trackers( )

Returns the list of tracker URLs.

my $tr = $m->trackers();

name( )

Returns the display name (dn).

my $name = $m->name();

nodes( )

Returns the list of DHT bootstrap nodes (x.pe).

my $nodes = $m->nodes();

SPECIFICATIONS

  • BEP 09: Magnet URI format (Foundational)

  • BEP 53: Magnet URI extension (v2 and multihash)

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.