TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fun with IP address parsing (2020)

34 pointsby marbu26 days ago

8 comments

orangeboats26 days ago
The &quot;IPv6 with trailing IPv4&quot;-style address is still relevant in NAT64 (and by extension, XLAT464), which are sorta widely deployed among cellular ISPs, and likely will get more and more useful as networks transition to become IPv6-mostly.<p>You upgrade an IPv4 address to an IPv6 address by appending it to 64:ff9b::&#x2F;96, or whichever &#x2F;96 prefix your ISP has chosen. For example, in an NAT64-enabled network, connecting to 64:ff9b::1.1.1.1 will get you to 1.1.1.1 as expected.
ryan-c25 days ago
Did I inspire posting this?<p><a href="https:&#x2F;&#x2F;infosec.exchange&#x2F;@ryanc&#x2F;114386921335051196" rel="nofollow">https:&#x2F;&#x2F;infosec.exchange&#x2F;@ryanc&#x2F;114386921335051196</a>
评论 #43803580 未加载
dang22 days ago
Discussed at the time:<p><i>Fun with IP address parsing</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25545967">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25545967</a> - Dec 2020 (146 comments)
timnetworks25 days ago
&gt; Let’s use 192.168.140.255 as an example. That’s an IPv4 address that people would look at and go “yes, that sure is an IPv4 address.” How else can we write that exact same address?<p>&gt; This is the same IP address: 3232271615. You get that by interpreting the 4 bytes of the IP address as a big-endian unsigned 32-bit integer, and print that. This leads to a classic parlor trick: if you try to visit <a href="http:&#x2F;&#x2F;3232271615" rel="nofollow">http:&#x2F;&#x2F;3232271615</a> , Chrome will load <a href="http:&#x2F;&#x2F;192.168.140.255" rel="nofollow">http:&#x2F;&#x2F;192.168.140.255</a>.<p>murkans have been using ten digits as phone numbers for some decades now (no country code), I&#x27;m kinda bummed there isn&#x27;t some saudi royalty paying four billion for a set of matching ip address and phone number.
o11c26 days ago
The fact that there are still octal-supporting parsers in the wild means that it is a security bug to accept 0-prefixed addresses as decimal, since they will produce a <i>different</i> valid value.<p>All the other questions are much safer since they will at worst produce a failure, but it would probably be best to be extra-strict for them too.
nly25 days ago
We can&#x27;t really criticise modern application developers for looking at this complexity, shrugging, and just using the only API available - inet_pton<p>In a sensible world inet_pton would be deprecated with a compiler warning and replaced with inet_pton2 that just accepted the sensible subset.<p>The HTTP RFCs actually do restrict the format within URIs, but modern browsers are still more liberal<p><a href="https:&#x2F;&#x2F;www.rfc-editor.org&#x2F;rfc&#x2F;rfc3986#section-3.2.2" rel="nofollow">https:&#x2F;&#x2F;www.rfc-editor.org&#x2F;rfc&#x2F;rfc3986#section-3.2.2</a><p>One thing I&#x27;ve previously lamented is how IPv6 requires parens for IP:port pair string - particularly problematic if you want to be able to have a default port when the suffix is missing.
9834759824 days ago
It’s also common to see ::ffff:0:0&#x2F;96 IPv6 addresses with embedded IPv4, like ::ffff:127.0.0.1. These show up when you open an IPv6 socket that also accepts IPv4 packets.
dan_linder26 days ago
I wonder how many firewalls would break with some of these? I hope they would fail closed (block unexpected traffic). Their stacks probably work on the packet binary data...but the GUI?
评论 #43802394 未加载