5 ms·
Wget Arbitrary Commands Execution
- raimue 10y agoI hate it when blog posts do not have any date and time somewhere on the article page. The only indicator is that it was filed into "July 2016" in the archive sidebar.
- sigcode 10y agoNote to securiteam: ns2.beyondsecurity.com 209.40.99.8 appears to be dead Edit: Ignore this. I was blocking AWS.
- nilved 10y agoAm I alone in thinking that this behaviour is expected and intuitive? To the extent that I had to verify cURL didn't have the same behaviour.
- andrewstuart2 10y agoNot at all. Though following redirects and not using the original "file" name by default may be a bad idea. The whole purpose of wget is to get a file from the web and store it locally, by default using the remote filename in the working directory.
- raimue 10y agoIt is important to make a difference between a remote filename supplied in a Content-Disposition header or the substring that can be extracted from the given URL by splitting at slashes. wget by default uses the latter, appending the QSA (?foo=bar) even when not intended. Same behavior for `curl -O`. You have to use `wget --content-disposition` or `curl -O -J` to explicitly trust the filename send by the server.
- pierrec 10y agoIt's kind of a gray area, but looking closely I find it leans heavily towards the buggy, "unexpected behavior" side of things. Here's why: when encountering HTTP->HTTP redirects, wget already ignores the redirected file name and writes to the original file name that was provided in the URL. It was strangely inconsistent that it specifically didn't do this for HTTP->FTP redirects, and at the very least the behavior should be consistent by default. This is clarified in the linked release notes, and also explains why they had no hesitation in considering it a wget bug and fixing it immediately. As for the question of whether using redirected file names is more expected and intuitive, IMO providing a URL without specifying an output filename is basically a shorthand that merges the two arguments into one.
- peterwwillis 10y agoIf you specifically issue the command as trying to download a file called "safe_file.txt", and then the actual file that gets downloaded is not only a different file but even a different file name, this is definitely unexpected and un-intuitive.
- RubyPinch 10y agoeh, the path the url contains isn't a file system path, its a string of characters that a server can treat in a million different ways, so its not exactly practical to rely on that e.g. if the url was along the lines of http://example.com/dl/f3ct4t3c4c3/ what do you expect the file name to be?
- peterwwillis 10y ago"index.html", as Wget creates a default name (defined by the "default-page" option) when you download a directory path using HTTP. The path in a URL is defined as the following (https://en.wikipedia.org/wiki/Uniform_Resource_Identifier https://en.wikipedia.org/wiki/Uniform_Resource_Identifier) : A path, which contains data, usually organized in hierarchical form, that appears as a sequence of segments separated by slashes. Such a sequence may resemble or map exactly to a file system path, but does not always imply a relation to one.[9] The path must begin with a single slash (/) if an authority part was present, and may also if one was not, but must not begin with a double slash. You can rely on the path to be made up of parts that will not begin with a double slash, and will be separated by slashes, and be defined by a specific character set. URLs also contain a query and a fragment after the path, and the client can choose whether to keep those in the file name or not. Wget has many options which define how file names are created, mainly to better serve in mirroring large complex websites. But in general, whatever the "path" was, the final part of the path will be the file name, or a default one is provided. There are options for enforcing suffixes, creating directory structures recursively, changing accepted character sets for file names, and hundreds more options.
- RubyPinch 10y agoYou are taking my comment a bit too literally (especially since the only thing I was trying to convey was: url files != filesystem files). I don't mean defined behavior, I mean what is expected, since that is what you were talking about. If we go with defined behavior, then wget using the server-provided name just like a web browser does (resolving the redirects, and then explicitly noting that the file is being saved with that new file name), is completely expected, no?
- Puts 10y agoIt's not a security hole and it's not a bug. Wget even prints out all the things that are happening. Everybody seems to be grasping at straws right now just to be able to make the next branded vulnerability.
- deleted 10y ago[deleted]
- icebraining 10y agoThe wget developers disagree, they call it a security vulnerability. I'm inclined to agree because knowing that HTTP → HTTP redirections don't have this behaviour, it's dangerous for HTTP → FTP to have it. Whether wget prints it out is irrelevant, as it's often used in scripts. http://lists.gnu.org/archive/html/info-gnu/2016-06/msg00004.html http://lists.gnu.org/archive/html/info-gnu/2016-06/msg00004....
- simula67 10y agoShouldn't we stop storing configuration files at $HOME ? Most terminal emulators also start at $HOME by default which compounds this problem.
- tokenizerrr 10y agoWhere else would you like to put them?
- simula67 10y agoHow about /etc/username ?
- icebraining 10y agoAnd then you can't install a package because its name conflicts with the name of some user?
- tokenizerrr 10y agoWould the user still be able to write to that directory without bumping their privileges? If so, how does this help anything?
- viraptor 10y agoThere are better places than directly in `$HOME`. One is some abstracted service like windows registry. Another is just separating the configs better, like `$HOME/.config`. Both are good ideas.
- tokenizerrr 10y ago`$HOME/.config` is a good idea, but doesn't help anything really. It's still within $HOME, and writable by any process that runs under the user. The Windows registry is just awful, and does not offer any actual protection that the filesystem cannot provide.
- 10y ago
- _wmd 10y agoPeppering your description with 100 uses of the word "arbitrary" and "crafted" does not cause expected behaviour to become a security vulnerability! That's not a "crafted" location header, it's a perfectly normal location header.
- rtpg 10y agoWell, "good" to see a bug that wouldn't have been solved by using Rust. I had never really thought about this attack vector though. Writing to `.bash_profile` is effectively the same as writing executable code. Though I like the whole "everything is a file" concept (I know this isn't exactly that but...), it seems like we should be striving for something safer. For example, I guess in something like Plan9 you could have wget start playing sound out of your speakers? Crazy. File handles shouldn't cause RCE vulnerabilities, right? I suppose sandboxing is one way of dealing with this. Another is having to explicitly "give a file" to wget and co. for editing. None of this "oh, here you go program, write to anything in my home directory".