The vulnerability, CVE-2026-47674, exists in the ip-restriction middleware of the Hono framework. The root cause was the use of string comparison to check if an incoming IP address matched a static deny or allow rule. IPv6 has multiple valid string representations (canonical, compressed, IPv4-mapped, etc.) for the same address. The middleware would store the rules in a canonical form, but would not normalize the incoming IP address from a request before the comparison. This discrepancy allowed an attacker to bypass a deny rule by sending the IP in a non-canonical form.
The patch addresses this by shifting from string-based comparison to a numerical one. It introduces new utility functions in src/utils/ipaddr.ts (convertIPv4ToBinary, convertIPv6ToBinary) that parse and convert IP addresses into a canonical bigint representation, rejecting any invalid formats. The core middleware logic in src/middleware/ip-restriction/index.ts was updated to use these functions. Now, both the configured IP rules and the incoming remote IP address are converted to their binary bigint form before being compared. This ensures that different string representations of the same IP address are correctly matched, closing the bypass vulnerability. The primary vulnerable function is ipRestriction, as it contains the flawed checking logic.