1
0
forked from mirrors/pacman

Compare commits

...

2 Commits

Author SHA1 Message Date
Allan McRae
1bf7672343 Release v5.1.3
Signed-off-by: Allan McRae <allan@archlinux.org>
2019-03-01 11:28:53 +10:00
Andrew Gregory
9702703633 Sanitize file name received from Content-Disposition header
When installing a remote package with "pacman -U <url>", pacman renames
the downloaded package file to match the name given in the
Content-Disposition header. However, pacman does not sanitize this name,
which may contain slashes, before calling rename(). A malicious server (or
a network MitM if downloading over HTTP) can send a content-disposition
header to make pacman place the file anywhere in the filesystem,
potentially leading to arbitrary root code execution. Notably, this
bypasses pacman's package signature checking.

For example, a malicious package-hosting server (or a network
man-in-the-middle, if downloading over HTTP) could serve the following
header:

Content-Disposition: filename=../../../../../../usr/share/libalpm/hooks/evil.hook

and pacman would move the downloaded file to
/usr/share/libalpm/hooks/evil.hook. This invocation of "pacman -U" would
later fail, unable to find the downloaded package in the cache directory,
but the hook file would remain in place. The commands in the malicious
hook would then be run (as root) the next time any package is installed.

Discovered-by: Adam Suhl <asuhl@mit.edu>
Signed-off-by: Allan McRae <allan@archlinux.org>
(cherry picked from commit d197d8ab82)
2019-03-01 11:25:46 +10:00
3 changed files with 6 additions and 3 deletions

2
NEWS
View File

@@ -1,5 +1,7 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
5.1.3 - Sanitize file path received from Content-Disposition header
to fix potential arbitary code execution
5.1.2 - pacman-conf: add missing DisableDownloadTimeout support
- Include version when checking optdepend install status
during -Qi (FS#60106)

View File

@@ -42,12 +42,12 @@ AC_PREREQ(2.64)
# pacman_version_micro += 1
m4_define([lib_current], [11])
m4_define([lib_revision], [2])
m4_define([lib_revision], [3])
m4_define([lib_age], [0])
m4_define([pacman_version_major], [5])
m4_define([pacman_version_minor], [1])
m4_define([pacman_version_micro], [2])
m4_define([pacman_version_micro], [3])
m4_define([pacman_version],
[pacman_version_major.pacman_version_minor.pacman_version_micro])

View File

@@ -534,7 +534,8 @@ static int curl_download_internal(struct dload_payload *payload,
if(payload->content_disp_name) {
/* content-disposition header has a better name for our file */
free(payload->destfile_name);
payload->destfile_name = get_fullpath(localpath, payload->content_disp_name, "");
payload->destfile_name = get_fullpath(localpath,
get_filename(payload->content_disp_name), "");
} else {
const char *effective_filename = strrchr(effective_url, '/');
if(effective_filename && strlen(effective_filename) > 2) {