Skip to content

mempool: bind the backend to services.mempool.address - #69

Merged
prusnak merged 2 commits into
bitcoinix:masterfrom
bobberb:bobberb/mempool-bind-address-d69e78ad
Oct 22, 2026
Merged

prusnak merged 2 commits into
bitcoinix:masterfrom
bobberb:bobberb/mempool-bind-address-d69e78ad

Conversation

@bobberb

@bobberb bobberb commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #75.

Stock mempool calls server.listen(HTTP_PORT) with no host, so the backend
listens on all interfaces. services.mempool.address (default 127.0.0.1)
only told nginx where to proxy; it never limited the listener. Without netns
isolation, the backend API on 8999 is reachable from any network the host
firewall admits.

This patches the backend to take MEMPOOL.HTTP_HOST (default 127.0.0.1)
and sets it to services.mempool.address. Under netns isolation that is the
mempool namespace address, which is what nginx already proxies to.

The second commit does the same for the MariaDB server mempool enables: it
listens on all interfaces by default although mempool only uses the unix socket,
so bind-address now defaults to 127.0.0.1 (mkDefault). The versioning entry
and the test cover both listeners.

Because it narrows the listener for every mempool user, it adds a 0.1.1
entry to modules/versioning.nix (modelled on the 0.1.0 lndconnect/clnrest
one). master is already at 0.1.1 (Liquid removal, clightning-rest), so the
entry sits next to those two and examples/configuration.nix needs no bump.

Test: @test("mempool") now asserts that the backend listens on
127.0.0.1:8999 only, in non-netns scenarios (under netns it runs in its own
namespace).

Tested locally: ./test/run-tests.sh (default, netns, netnsRegtest),
nix flake check --all-systems, ./test/shellcheck.sh. The patch applies to
the packaged mempool 3.2.1.

🤖 Generated with Claude Code

bobberb and others added 2 commits October 22, 2026 19:17
Stock mempool calls `server.listen(HTTP_PORT)` without a host, so the
backend has listened on all interfaces. `services.mempool.address`
(default 127.0.0.1) only told nginx where to proxy; it never limited the
listener. Without netns isolation, the backend API on port 8999 was
reachable from any network the host firewall lets through.

Patch the backend to take `MEMPOOL.HTTP_HOST` and set it to
`services.mempool.address`. Under netns isolation this is the mempool
namespace address, which is what nginx already proxies to.

This narrows the listener for mempool users. Add a 0.1.2 migration
entry and upgrade documentation, and test the configured address both
with and without network namespace isolation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Codex (GPT-6)
mempool connects to MariaDB over the unix socket, but the server it
enables listens on all interfaces (MariaDB's default), so port 3306 was
reachable from any network the host firewall admits. Default
`bind-address` to 127.0.0.1 (mkDefault, for setups that use MariaDB over
the network), document it in the 0.1.2 migration notes, and assert the
host-namespace listener with and without network namespace isolation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assisted-by: Codex (GPT-6)
@prusnak
prusnak force-pushed the bobberb/mempool-bind-address-d69e78ad branch from b63525f to f1826c3 Compare October 22, 2026 17:23
@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix area: packages pkgs/ and flake pins labels Oct 22, 2026
@prusnak
prusnak merged commit 4452d89 into bitcoinix:master Oct 22, 2026
12 checks passed
@seberm seberm added breaking Changes existing user config; needs a versioning.nix entry type: security Hardening or vulnerability (public-safe only) labels Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix area: packages pkgs/ and flake pins breaking Changes existing user config; needs a versioning.nix entry type: security Hardening or vulnerability (public-safe only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mempool: backend listens on all interfaces, ignoring services.mempool.address

3 participants