A blocked_networks entry written in the IPv4-mapped form is accepted but refuses nothing #301

Closed
opened 2026-10-16 06:38:19 +02:00 by clawbot · 1 comment
Collaborator

Where: internal/config/config.go, parseCIDRList, and internal/httpfetcher/httpfetcher.go, isBlockedIP, on next at 3a6b3bc. Found by the review of #300.

What is wrong: parseCIDRList accepts a blocked_networks entry written in the IPv4-mapped form, such as ::ffff:10.0.0.0/104, but isBlockedIP reads every mapped address as the IPv4 address it holds before matching, so that entry never matches anything. pixa starts without a word and fetches from the range the operator meant to block.

How it fails: an operator writes an IPv4 range in the mapped form in blocked_networks; requests to hosts in that range are fetched.

Severity: medium (a range the operator blocks is silently not blocked).

Definition of done:

  1. A blocked_networks entry in the IPv4-mapped form is either refused at startup with an error naming the setting, or turned into the IPv4 range it covers; README.md says which. Recommended: turn it into the IPv4 range, as the address it holds is how pixa matches.
  2. Test first; make check green.

Package: internal/config (and internal/httpfetcher only if the matching changes).

Model: opus-5-5

Where: `internal/config/config.go`, `parseCIDRList`, and `internal/httpfetcher/httpfetcher.go`, `isBlockedIP`, on `next` at `3a6b3bc`. Found by the review of https://git.eeqj.de/sneak/pixa/pulls/300. What is wrong: `parseCIDRList` accepts a `blocked_networks` entry written in the IPv4-mapped form, such as `::ffff:10.0.0.0/104`, but `isBlockedIP` reads every mapped address as the IPv4 address it holds before matching, so that entry never matches anything. pixa starts without a word and fetches from the range the operator meant to block. How it fails: an operator writes an IPv4 range in the mapped form in `blocked_networks`; requests to hosts in that range are fetched. Severity: medium (a range the operator blocks is silently not blocked). Definition of done: 1. A `blocked_networks` entry in the IPv4-mapped form is either refused at startup with an error naming the setting, or turned into the IPv4 range it covers; `README.md` says which. Recommended: turn it into the IPv4 range, as the address it holds is how pixa matches. 2. Test first; `make check` green. Package: `internal/config` (and `internal/httpfetcher` only if the matching changes). Model: opus-5-5
clawbot self-assigned this 2026-10-16 06:38:27 +02:00
Author
Collaborator

Plan: build the recommended option, in internal/config only.

  • parseCIDRList turns a blocked_networks entry written in the IPv4-mapped form, with a prefix of 96 bits or more, into the IPv4 range it covers: ::ffff:10.0.0.0/104 becomes 10.0.0.0/8. Matching in internal/httpfetcher is unchanged, since it already reads a mapped address as the IPv4 address it holds.
  • A mapped-form entry with a prefix shorter than 96 bits covers more than the IPv4 addresses and is not one IPv4 range; pixa refuses it at startup with an error naming blocked_networks.
  • README.md, where it describes blocked_networks, says both.

Test first: a new test in internal/config shows the mapped entry blocking an address in the IPv4 range, and fails before the fix. No existing test changes.

Model: opus-5-5

Plan: build the recommended option, in `internal/config` only. - `parseCIDRList` turns a `blocked_networks` entry written in the IPv4-mapped form, with a prefix of 96 bits or more, into the IPv4 range it covers: `::ffff:10.0.0.0/104` becomes `10.0.0.0/8`. Matching in `internal/httpfetcher` is unchanged, since it already reads a mapped address as the IPv4 address it holds. - A mapped-form entry with a prefix shorter than 96 bits covers more than the IPv4 addresses and is not one IPv4 range; pixa refuses it at startup with an error naming `blocked_networks`. - `README.md`, where it describes `blocked_networks`, says both. Test first: a new test in `internal/config` shows the mapped entry blocking an address in the IPv4 range, and fails before the fix. No existing test changes. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#301