Red Hat Bugzilla – Bug 833831
When redirected, wget should use the original page name for saving
Last modified: 2016-05-31 21:43:12 EDT
Description of problem: When wget fetches a page which is redirected to another page it uses the redirected page name for file creation which could be something user is not expecting and could probably present a security issue. This is correctly fixed in latest wget in RHEL7. Version-Release number of selected component (if applicable): wget-1.12-1.4.el6.x86_64 Steps to Reproduce: 1. Set up some redirection on the server 2. wget the redirected page Actual results: For example: wget --max-redirect=40 http://localhost/wget/redir/00.html --2012-06-20 16:39:28-- http://localhost/wget/redir/00.html Resolving localhost... ::1, 127.0.0.1 Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/01.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/01.html Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/02.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/02.html Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/03.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/03.html ... HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/28.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/28.html Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/29.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/29.html Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://localhost/wget/redir/30.html [following] --2012-06-20 16:39:28-- http://localhost/wget/redir/30.html Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 15 [text/html] Saving to: `30.html' Expected results: Connecting to localhost|::1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 15 [text/html] Saving to: `00.html'
This request was not resolved in time for the current release. Red Hat invites you to ask your support representative to propose this request, if still desired, for consideration in the next release of Red Hat Enterprise Linux.
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development. This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.
This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate, in the next release of Red Hat Enterprise Linux.
Created attachment 648415 [details] [PATCH] Introduce --trust-server-names option
Wget WITHOUT patch: $ ./wget http://localhost/wget/00.php --2012-11-20 12:45:40-- http://localhost/wget/00.php Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/01.php [following] --2012-11-20 12:45:40-- http://localhost/wget/01.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/02.php [following] --2012-11-20 12:45:40-- http://localhost/wget/02.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/03.php [following] --2012-11-20 12:45:40-- http://localhost/wget/03.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/index.html [following] --2012-11-20 12:45:40-- http://localhost/index.html Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 127 [text/html] Saving to: `index.html' 100%[==============================================================>] 127 --.-K/s in 0s 2012-11-20 12:45:40 (7.76 MB/s) - `index.html' saved [127/127] Wget WITH patch: $ ./wget http://localhost/wget/00.php --2012-11-20 12:51:20-- http://localhost/wget/00.php Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/01.php [following] --2012-11-20 12:51:20-- http://localhost/wget/01.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/02.php [following] --2012-11-20 12:51:20-- http://localhost/wget/02.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/03.php [following] --2012-11-20 12:51:20-- http://localhost/wget/03.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/index.html [following] --2012-11-20 12:51:20-- http://localhost/index.html Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 127 [text/html] Saving to: `00.php' 100%[==============================================================>] 127 --.-K/s in 0s 2012-11-20 12:51:20 (6.52 MB/s) - `00.php' saved [127/127] $ ./wget --trust-server-names http://localhost/wget/00.php --2012-11-20 12:51:38-- http://localhost/wget/00.php Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/01.php [following] --2012-11-20 12:51:38-- http://localhost/wget/01.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/02.php [following] --2012-11-20 12:51:38-- http://localhost/wget/02.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/wget/03.php [following] --2012-11-20 12:51:38-- http://localhost/wget/03.php Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://localhost/index.html [following] --2012-11-20 12:51:38-- http://localhost/index.html Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 127 [text/html] Saving to: `index.html' 100%[==============================================================>] 127 --.-K/s in 0s 2012-11-20 12:51:38 (8.27 MB/s) - `index.html' saved [127/127]
Same problem when using wget for downloading archives from github. For example: wget http://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz --2014-01-31 11:31:28-- http://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz Resolving github.com... 192.30.252.130 Connecting to github.com|192.30.252.130|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz [following] --2014-01-31 11:31:34-- https://github.com/LibreCAD/LibreCAD/archive/2.0.2.tar.gz Connecting to github.com|192.30.252.130|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://codeload.github.com/LibreCAD/LibreCAD/tar.gz/2.0.2 [following] --2014-01-31 11:31:34-- https://codeload.github.com/LibreCAD/LibreCAD/tar.gz/2.0.2 Resolving codeload.github.com... 192.30.252.146 Connecting to codeload.github.com|192.30.252.146|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 15429871 (15M) [application/x-gzip] Saving to: “2.0.2” 2014-01-31 11:32:17 (414 KB/s) - “2.0.2” saved [15429871/15429871] But file must be saved as 2.0.2.tar.gz And same problem when github archive uses as Source0 in rpm package for RHEL6. Please, update wget.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2014-0151.html