-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: should expand IP address 1.1 to 1.0.0.1 #36822
Comments
Looking at http://man7.org/linux/man-pages/man5/resolv.conf.5.html, Why did you expect that Go would be able to use |
|
Do you have a citation for that? I didn't think that IEEE 1003.1 talked about networking at all. Thanks. |
|
Sorry Ian, but technically he is right. Couldn't find a way to link into
the relevant part of the spec. Rgds, Nigel Vickers
The Open Group Base Specifications Issue 7, 2018 edition
IEEE Std 1003.1™-2017 (Revision of IEEE Std 1003.1-2008)
Copyright © 2001-2018 IEEE and The Open Group
#include <arpa/inet.h>
in_addr_t inet_addr(const char *cp);
char *inet_ntoa(struct in_addr in);
DESCRIPTION
The inet_addr() function shall convert the string pointed to by cp, in the
standard IPv4 dotted decimal notation, to an integer value suitable for use
as an Internet address.
The inet_ntoa() function shall convert the Internet host address specified
by in to a string in the Internet standard dot notation.
The inet_ntoa() function need not be thread-safe.
All Internet addresses shall be returned in network order (bytes ordered
from left to right).
Values specified using IPv4 dotted decimal notation take one of the
following forms:
a.b.c.d
When four parts are specified, each shall be interpreted as a byte of data
and assigned, from left to right, to the four bytes of an Internet address.
a.b.c
When a three-part address is specified, the last part shall be interpreted
as a 16-bit quantity and placed in the rightmost two bytes of the network
address. This makes the three-part address format convenient for specifying
Class B network addresses as "128.net.host".
a.b
When a two-part address is supplied, the last part shall be interpreted as
a 24-bit quantity and placed in the rightmost three bytes of the network
address. This makes the two-part address format convenient for specifying
Class A network addresses as "net.host".
a
When only one part is given, the value shall be stored directly in the
network address without any byte rearrangement.
All numbers supplied as parts in IPv4 dotted decimal notation may be
decimal, octal, or hexadecimal, as specified in the ISO C standard (that
is, a leading 0x or 0X implies hexadecimal; otherwise, a leading '0'
implies octal; otherwise, the number is interpreted as decimal).
…On Tue, 28 Jan 2020 at 16:25, Ian Lance Taylor ***@***.***> wrote:
This is part of POSIX (IEEE 1003.1).
Do you have a citation for that? I didn't think that IEEE 1003.1 talked
about networking at all. Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#36822?email_source=notifications&email_token=ABAB73CP5DM7F6MOV672SZ3RABE5JA5CNFSM4KMLTTQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKDWG6A#issuecomment-579298168>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABAB73GUHRTR33H4XTS7SULRABE5JANCNFSM4KMLTTQQ>
.
|
Thanks for the pointer. |
Indeed, TIL! |
Well, that's just about all the internet I can handle today. Good evening |
Are there any security issues related to this potentially changing behavior in higher level packages(net/http, etc)? I think it may be a good idea to make a note about the potential for SSRF and other security problems on the release notes if/when this is changed. ie if you are filtering some internal address like |
Good point (and that's an awesome presentation.) I'm not clear on what exact attack vector you're suggesting here -- are we talking about URL routing with embedded IP's, general input sanitation, other protocols, etc. It seems like most naive implementations that would be expecting an IPv4 at all should also enforce a dotted-quad input sanitation filter, since any developer that would just allow untrusted input without even the bare minimum of bounds checking for some sort of properly formed IP (whatever that means to the developer!) will probably have far larger issues anyway. Even if the developer has some inscrutable take on what an IPv4 "looks" like, in practice this expansion isn't really much different from how you can drop octets in IPv6, so perhaps the behavior should match whatever is currently done for IPv6 octets. |
One POSIX online reference is on opengroup |
Change https://golang.org/cl/268259 mentions this issue: |
Punting to Go1.17, as per guidance on the CL after the need for clarification. |
In addition, e.g., "0x7F.010" should correspond to "127.0.0.8". $ wget http://0x7F.010
--2021-03-13 16:38:50-- http://0x7f.010/
Resolving 0x7f.010 (0x7f.010)... 127.0.0.8
... |
The "7.4. Rare IP Address Formats" section of RFC3986 has explanation about the rare formats, though not formal definition: https://tools.ietf.org/html/rfc3986#section-7.4
|
FWIW, I don't think POSIX has really made up its mind on this consistently either:
You could argue that RFC 6943 section 3.1.1 referred in that issue also talks of this distinction between "strict" and "loose" forms:
|
The RFC 6943 reference is very interesting, especially that part you quoted:
|
The RFC 6943 mentions this because it wanted to point out the imprecise wording in other protocols, not that it was trying to defend the loose form. In fact, the RFC 6943 is arguably against using the loose form. It says:
|
If we wish to parse the loose form, I personally hope we could keep a function recognizing only the strict form to implement various protocols more faithfully (including the URIs mentioned above--- Two security concerns could be related here, though the first one is not limited to the loose form:
|
Add support for parsing partial IPv4 IPs (such as "10.20"). See https://man7.org/linux/man-pages/man3/inet_addr.3.html Fixes golang#36822
The above PR is my understanding of the issue. |
it was noted on CL 544955 that we don't want this. |
nameserver 1.1
in/etc/resolv.conf
not parsedWhat did you do?
go get github.com/kevinburke/twilio-go
What did you see instead?
Workaround
Change 1.1 to 1.0.0.1 or 1.1.1.1 in
/etc/resolv.conf
The text was updated successfully, but these errors were encountered: