[Bug] Fix feed fetching on IPv6-only hosts using NAT64
FreshRSS currently rejects IPv6 addresses from the RFC 6052 NAT64 well-known prefix (64:ff9b::/96) when building the CURLOPT_RESOLVE list.
On an IPv6-only host with NAT64 connectivity, this causes FreshRSS to discard the reachable NAT64 address and retain only the IPv4 A record. Since IPv4 connectivity is unavailable, cURL then fails with error 7 (Could not connect to server).
This change allows NAT64 addresses while preserving the existing SSRF protections by validating the IPv4 address embedded in the NAT64 address.
Problem
For example, DNS for hackaday.com on an affected system returns:
A 192.0.66.96
AAAA 64:ff9b::c000:4260The second address is the NAT64 representation of 192.0.66.96.
FreshRSS currently has 64:ff9b::/96 in PRIVATE_SUBNETS, so the NAT64 address is discarded before being passed to cURL. The resulting CURLOPT_RESOLVE contains only:
hackaday.com:443:192.0.66.96On an IPv6-only system this results in:
CURLE_COULDNT_CONNECT (7)cURL itself supports the NAT64 address correctly and can successfully connect using:
64:ff9b::c000:4260Fix
NAT64 addresses from 64:ff9b::/96 are handled separately:
- Detect the NAT64 address.
- Extract the embedded IPv4 address.
- Apply the existing
FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGEvalidation to that IPv4 address. - Apply the existing
PRIVATE_SUBNETSCIDR checks to the embedded IPv4 address. - Only allow the original NAT64 IPv6 address when the embedded IPv4 address passes all existing safety checks.
This means the change does not simply allow the entire NAT64 prefix.
For example:
64:ff9b::c000:4260 -> 192.0.66.96 allowed
64:ff9b::a9fe:a9fe -> 169.254.169.254 blocked
64:ff9b::7f00:1 -> 127.0.0.1 blocked
64:ff9b::c0a8:0101 -> 192.168.1.1 blockedVerification
The fix was tested on an IPv6-only host with NAT64 connectivity.
Before the fix, FreshRSS generated:
hackaday.com:443:192.0.66.96and cURL failed with:
ERRNO: 7
Could not connect to serverAfter the fix, FreshRSS generates:
hackaday.com:443:192.0.66.96,[64:ff9b::c000:4260]and cURL successfully connects using:
PRIMARY_IP: 64:ff9b::c000:4260
ERRNO: 0The embedded-private-address test also correctly rejects:
64:ff9b::a9fe:a9fe -> 169.254.169.254Impact
This fixes feed fetching for FreshRSS installations running on IPv6-only networks where IPv4 destinations are reached through NAT64, without disabling or weakening the existing SSRF protections for private and reserved addresses.
To Reproduce
- Run FreshRSS on an IPv6-only host with working NAT64 connectivity.
- Configure a feed whose hostname has both an IPv4 A record and an IPv6 address generated by NAT64. For example:
https://hackaday.com/feed/ - Run the FreshRSS feed updater.
- Observe that the feed fails with cURL error 7 (
Could not connect to server). - Inspect the cURL options generated by FreshRSS. The
CURLOPT_RESOLVEentry contains only the IPv4 address, for example:hackaday.com:443:192.0.66.96 - Verify that direct IPv6/NAT64 connectivity works independent
Expected behavior
FreshRSS should allow valid NAT64 IPv6 addresses to be included in CURLOPT_RESOLVE when the embedded IPv4 address is publicly routable.
On an IPv6-only host with NAT64 connectivity, FreshRSS should therefore be able to fetch feeds from IPv4-only destinations successfully.
NAT64 addresses mapping to private, loopback, link-local, or otherwise reserved IPv4 addresses should continue to be rejected to preserve the existing SSRF protections.
FreshRSS version
1.30.0
System information
- Database version: SQLite
- PHP version: PHP 8.5.11
- Installation type: git
- Web server type: Apache
- Device: Server
- OS: Alpine Linux edge 3.25.0_alpha20260805
- Browser: N/A (server-side feed fetching issue)
Additional context
No response
Source: FreshRSS/FreshRSS