3 ms·
Fun fact: you can do even weirder shit with IP addresses, and it can break a ton of filters and other processing as well. Take news.ycombinator.com. At the mom
by mschuster91 2y ago
Fun fact: you can do even weirder shit with IP addresses, and it can break a ton of filters and other processing as well.
Take news.ycombinator.com. At the moment it resolves to 209.216.230.207 - and running curl on it will yield a redirect to the canonical domain name. But so will do "curl -v 0xD1D8E6CF" (hex) or "curl -v 3520653007" (decimal) or "curl -v 032166163317" (octal joined) or "curl -v 0321.0330.0346.0317" (octal split). And curl isn't the only application - ping on macOS works just the same.
All of that are valid representations of IP addresses that many libc/OS or whatever IP stack implementations will resolve [1] and you should be very careful when trying to check for URLs. I think there's also a binary form but can't find one that works in curl at the moment.
Funnier Fact: cURL has a bug in here. I'd expect the Host header to equal just what I wrote, not a normalized form:
$ curl -v 032166163317
* Trying 209.216.230.207:80...
* Connected to 209.216.230.207 (209.216.230.207) port 80
> GET / HTTP/1.1
> Host: 209.216.230.207
[1] https://daniel.haxx.se/blog/2021/04/19/curl-those-funny-ipv4-addresses/ https://daniel.haxx.se/blog/2021/04/19/curl-those-funny-ipv4...