Skip to content

logging: Reject out-of-range ip_mask CIDRs - #8241

Merged
francislavoie merged 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-ip-mask-cidr-range
Oct 19, 2026
Merged

francislavoie merged 1 commit into
caddyserver:masterfrom
jayhemnani9910:fix-ip-mask-cidr-range

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Closes #8240

ip_mask accepted any integer as a CIDR size. A value outside 0-32 (IPv4) or 0-128 (IPv6) made net.CIDRMask return nil, and every address of that family was then logged as <nil>. Provision now returns an error for those values, so caddy validate and caddy run report it instead.

This does not change what happens to a family with no size set; that question is in the issue.

Test: TestIPMaskInvalidCIDR checks that 33, -1 (IPv4) and 129, -8 (IPv6) fail to provision, and that 32/128 leave addresses unchanged. It fails without the change.

go test ./... passes, golangci-lint reports 0 issues for modules/logging.

Manual check: with ip_mask 33, v2.11.7 says "Valid configuration" and logs remote_ip as <nil>; with the change, caddy validate fails with invalid IPv4 mask: 33 (must be between 0 and 32).

Assistance Disclosure

AI used (Claude Code).

Copilot AI balanced review requested due to automatic review settings October 17, 2026 05:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@francislavoie francislavoie added this to the v2.12.0 milestone Oct 19, 2026
@francislavoie francislavoie added the bug 🐞 Something isn't working label Oct 19, 2026
@francislavoie
francislavoie enabled auto-merge (squash) October 19, 2026 05:45
@francislavoie
francislavoie merged commit e3649f2 into caddyserver:master Oct 19, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logging: ip_mask logs <nil> for IPv6 clients when only an IPv4 mask is set

3 participants