Closed
Description
-
Version:
N/A -
Platform:
N/A -
Subsystem:
I found this article.
According to the article, Java and Python has ftp protocol injection to decode CRLF in the url.
ftp://foo:bar%0d%0aINJECTED@example.net/file.png
The url has the newline(CRLF) in authority part. Java and Python ftp server recognize following injected code.
USER foo
PASS bar
INJECTED
TYPE I
EPSV ALL
PASV
...
And our url module has the same issue for CRLF.
> url.parse('ftp://foo:bar%0d%0aINJECTED@example.net/file.png')
Url {
protocol: 'ftp:',
slashes: true,
auth: 'foo:bar\r\nINJECTED',
host: 'example.net',
port: null,
hostname: 'example.net',
hash: null,
search: null,
query: null,
pathname: '/file.png',
path: '/file.png',
href: 'ftp://foo:bar%0D%0AINJECTED@example.net/file.png' }
I tried WHATWG URL
, the new url parser does not decode the authority part.
new URL('ftp://foo:bar%0d%0aINJECTED@example.net/file.png')
// Chrome
{
hash: "",
host: "example.net",
hostname: "example.net",
href: "ftp://foo:bar%0d%0aINJECTED@example.net/file.png",
origin: "ftp://example.net",
password: "bar%0d%0aINJECTED",
pathname: "/file.png",
port: "",
protocol: "ftp:",
search: "",
username: "foo"
}
// Node v7.8 REPL
URL {
href: ftp://foo:bar%0d%0aINJECTED@example.net/file.png
protocol: ftp:
username: foo
password: --------
hostname: example.net
pathname: /file.png
}
Question
Why our url.parse decode authority by default?
And should we fix this CRLF problem?
I tried to fix this problem to sanitize CRLF url. but this change breaks compatibility. so I would like to hear some opinions.
I tried some npm modules related to ftp, but I cannot find vulnerabilities using this problem.