monero.loveA little love for the network.
← All news

Monero

Proposed Monero fix targets unreliable IPv4 ban checks

Monero PR #11776 targets mixed-up IPv4 address strings. What the author reproduced, how the patch works, and why FreeBSD review remains open.

A laptop and two servers connected across a cream-paper landscape by an orange path.

Monero contributor alhudz has proposed a change to how monerod turns IPv4 addresses into text. The reported problem can make a ban check look up the wrong address when several threads format addresses at once. PR #11776 remained open and unmerged when checked on 21 November 2026. No backport or released fix was verified.

How an address can get mixed up

A node keeps records about peers, including which hosts it has banned. For IPv4, its host_str() function obtains a readable address through get_ip_string_from_int32. Before the proposed change, that helper used inet_ntoa.

On implementations with one shared output buffer, simultaneous callers can overwrite each other's results. Imagine two workers writing different addresses on the same reusable note. One worker may copy the second worker's address before finishing its own lookup. Returning a C++ string does not prevent a mix-up that happens before the copy.

This matters beyond log messages. The reviewed code uses address strings for the host ban lookup, peer failure scores, and connection host identity, which feeds per-host connection counts. A wrong string could therefore misdirect filtering or accounting. A lock protecting the ban list does not protect an address buffer used elsewhere.

What the author reproduced

In the PR description, alhudz reports running four threads on macOS, each repeatedly formatting a different IPv4 address. Between 58 and 132 of 400,000 calls returned another thread's address. In a separate ban-check experiment, a banned address was reported as not blocked 41 to 71 times per 100,000 checks while three other threads formatted other addresses.

The author identifies overlapping work in peer-to-peer threads checking incoming connections and RPC threads formatting peer lists. Those separate activities can reach the same formatter. The author also reports that the new threaded test fails before the change.

Those are the author's results. We have not independently repeated either experiment, and they do not establish a failure rate for a running public node.

The platform distinction matters. The author also identifies FreeBSD and musl, a C library used by some Linux systems. Their inspected implementations contain ordinary static output buffers: FreeBSD source and musl source. That supports the proposed mechanism, but is not a reproduced Monero ban-check failure on those platforms. It also does not justify treating every Linux build as affected.

The replacement and its test

At reviewed commit 75c44f0, the replacement calls inet_ntop with a local INET_ADDRSTRLEN buffer. Each invocation supplies its own storage before returning the string. The existing failure return remains, and Windows gains the ws2tcpip.h include.

The added StringTools.GetIpStringThreaded test starts four threads, makes 100,000 conversions per thread and counts mismatches atomically. It joins the threads and expects zero mismatches. This checks concurrent formatting, not a complete incoming-connection or ban-enforcement scenario. Thread scheduling also means a passing run alone cannot prove the old race absent.

Review is unfinished. GitHub reported 17 successful checks and one FreeBSD failure for this commit. Reviewer Ap4sh said AF_INET was undeclared and requested <sys/socket.h> in the non-Windows includes. Successful jobs, including Ubuntu's tests, do not resolve that build failure or independently confirm the macOS reproduction.

What public-node operators should take from this

A node connected to several peers, with a magnifying glass over the connections.

Public nodes depend on reliable peer filtering. If address identities change during a lookup, a host ban could intermittently miss its intended target, while failure scores or connection counts could attach to the wrong host. The reviewed sources do not establish exploitation, an eclipse attack or a network incident.

Operators can follow the PR's review and official release notes, recording their daemon build and platform when investigating unexpected filtering. This report does not support installing the unfinished patch in production or naming affected and fixed versions. Platform-specific runtime impact and release inclusion remain unverified. For context on how nodes serve wallets, see our introduction to Monero wallets and nodes.

Support Monero Love

Help keep the public nodes and packages running. Send any amount of XMR.

Scan with a Monero wallet to donate to Monero Love.89hGTKxRVA3AUeKAbCRBt5TMSzq3MQZooNNsezCpNFjp2oeJPRx8AJeGKA8ziHZNqab78f4Vr1ntxhPDxX5298nnGZjHkhm