From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejJcM-00039B-0m for guix-patches@gnu.org; Wed, 07 Feb 2018 01:54:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejJcI-0005r6-Qv for guix-patches@gnu.org; Wed, 07 Feb 2018 01:54:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:52911) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejJcI-0005qH-IR for guix-patches@gnu.org; Wed, 07 Feb 2018 01:54:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ejJcI-0002LP-8m for guix-patches@gnu.org; Wed, 07 Feb 2018 01:54:02 -0500 Subject: [bug#30378] [PATCH] gnu: mpv: Fix CVE-2018-6360. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejJbl-0002xO-UN for guix-patches@gnu.org; Wed, 07 Feb 2018 01:53:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejJbi-0005HQ-EU for guix-patches@gnu.org; Wed, 07 Feb 2018 01:53:29 -0500 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:37155) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejJbh-0005GZ-Up for guix-patches@gnu.org; Wed, 07 Feb 2018 01:53:26 -0500 Received: by mail-pf0-x231.google.com with SMTP id p1so1758240pfh.4 for ; Tue, 06 Feb 2018 22:53:24 -0800 (PST) From: Alex Vong Date: Wed, 07 Feb 2018 14:53:12 +0800 Message-ID: <87tvuts33b.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30378@debbugs.gnu.org --=-=-= Content-Type: text/plain Tags: security Hello, This patch fixes CVE-2018-6360, which is about mpv maybe get tricked into playing unsafe url returned by youtube-dl. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-gnu-mpv-Fix-CVE-2018-6360.patch Content-Transfer-Encoding: quoted-printable >From 2a6538067bdad659672f1d19811bad8a5b8d9d56 Mon Sep 17 00:00:00 2001 From: Alex Vong Date: Wed, 7 Feb 2018 14:39:40 +0800 Subject: [PATCH] gnu: mpv: Fix CVE-2018-6360. * gnu/packages/patches/mpv-CVE-2018-6360-1.patch, gnu/packages/patches/mpv-CVE-2018-6360-2.patch, gnu/packages/patches/mpv-CVE-2018-6360-3.patch: New files. * gnu/local.mk (dist_patch_DATA): Add them. * gnu/packages/video.scm (mpv)[source]: Use them. --- gnu/local.mk | 5 +- gnu/packages/patches/mpv-CVE-2018-6360-1.patch | 138 +++++++++++++++++++++= ++++ gnu/packages/patches/mpv-CVE-2018-6360-2.patch | 59 +++++++++++ gnu/packages/patches/mpv-CVE-2018-6360-3.patch | 84 +++++++++++++++ gnu/packages/video.scm | 5 +- 5 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/mpv-CVE-2018-6360-1.patch create mode 100644 gnu/packages/patches/mpv-CVE-2018-6360-2.patch create mode 100644 gnu/packages/patches/mpv-CVE-2018-6360-3.patch diff --git a/gnu/local.mk b/gnu/local.mk index ca400dae6..0d3da924d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -9,7 +9,7 @@ # Copyright =C2=A9 2016 Adonay "adfeno" Felipe Nogueira # Copyright =C2=A9 2016, 2017 Ricardo Wurmus # Copyright =C2=A9 2016 Ben Woodcroft -# Copyright =C2=A9 2016, 2017 Alex Vong +# Copyright =C2=A9 2016, 2017, 2018 Alex Vong # Copyright =C2=A9 2016, 2017 Efraim Flashner # Copyright =C2=A9 2016, 2017 Jan Nieuwenhuizen # Copyright =C2=A9 2017 Tobias Geerinckx-Rice @@ -911,6 +911,9 @@ dist_patch_DATA =3D \ %D%/packages/patches/mhash-keygen-test-segfault.patch \ %D%/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch \ %D%/packages/patches/mpc123-initialize-ao.patch \ + %D%/packages/patches/mpv-CVE-2018-6360-1.patch \ + %D%/packages/patches/mpv-CVE-2018-6360-2.patch \ + %D%/packages/patches/mpv-CVE-2018-6360-3.patch \ %D%/packages/patches/module-init-tools-moduledir.patch \ %D%/packages/patches/mongodb-support-unknown-linux-distributions.patch \ %D%/packages/patches/mozjs17-aarch64-support.patch \ diff --git a/gnu/packages/patches/mpv-CVE-2018-6360-1.patch b/gnu/packages/= patches/mpv-CVE-2018-6360-1.patch new file mode 100644 index 000000000..55fc7daaf --- /dev/null +++ b/gnu/packages/patches/mpv-CVE-2018-6360-1.patch @@ -0,0 +1,138 @@ +Fix CVE-2018-6360: + +https://github.com/mpv-player/mpv/issues/5456 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=3DCVE-2018-6360 +https://security-tracker.debian.org/tracker/CVE-2018-6360 + +Patch copied from upstream source repository: + +https://github.com/mpv-player/mpv/commit/e6e6b0dcc7e9b0dbf35154a179b3dc1fc= fcaff43 + +To apply the patch to mpv 0.28.0 release tarball, hunk #4 is removed. Hunk= #4 +checks if 'mpd_url' is safe, but the support for 'mpd_url' is not available +for the 0.28.0 release. So it should be safe to remove hunk #4. + +From e6e6b0dcc7e9b0dbf35154a179b3dc1fcfcaff43 Mon Sep 17 00:00:00 2001 +From: Ricardo Constantino +Date: Fri, 26 Jan 2018 01:19:04 +0000 +Subject: [PATCH] ytdl_hook: whitelist protocols from urls retrieved from + youtube-dl + +Not very clean since there's a lot of potential unsafe urls that youtube-dl +can give us, depending on whether it's a single url, split tracks, +playlists, segmented dash, etc. +--- + player/lua/ytdl_hook.lua | 54 +++++++++++++++++++++++++++++++++++++++++--= ----- + 1 file changed, 47 insertions(+), 7 deletions(-) + +diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua +index dd96ecc01d..b480c21625 100644 +--- a/player/lua/ytdl_hook.lua ++++ b/player/lua/ytdl_hook.lua +@@ -16,6 +16,18 @@ local ytdl =3D { +=20 + local chapter_list =3D {} +=20 ++function Set (t) ++ local set =3D {} ++ for _, v in pairs(t) do set[v] =3D true end ++ return set ++end ++ ++local safe_protos =3D Set { ++ "http", "https", "ftp", "ftps", ++ "rtmp", "rtmps", "rtmpe", "rtmpt", "rtmpts", "rtmpte", ++ "data" ++} ++ + local function exec(args) + local ret =3D utils.subprocess({args =3D args}) + return ret.status, ret.stdout, ret +@@ -183,6 +195,9 @@ local function edl_track_joined(fragments, protocol, i= s_live, base) +=20 + for i =3D offset, #fragments do + local fragment =3D fragments[i] ++ if not url_is_safe(join_url(base, fragment)) then ++ return nil ++ end + table.insert(parts, edl_escape(join_url(base, fragment))) + if fragment.duration then + parts[#parts] =3D +@@ -208,6 +223,15 @@ local function proto_is_dash(json) + or json["protocol"] =3D=3D "http_dash_segments" + end +=20 ++local function url_is_safe(url) ++ local proto =3D type(url) =3D=3D "string" and url:match("^(.+)://") o= r nil ++ local safe =3D proto and safe_protos[proto] ++ if not safe then ++ msg.error(("Ignoring potentially unsafe url: '%s'"):format(url)) ++ end ++ return safe ++end ++ + local function add_single_video(json) + local streamurl =3D "" + local max_bitrate =3D 0 +@@ -238,14 +264,18 @@ local function add_single_video(json) + edl_track =3D edl_track_joined(track.fragments, + track.protocol, json.is_live, + track.fragment_base_url) ++ local url =3D edl_track or track.url ++ if not url_is_safe(url) then ++ return ++ end + if track.acodec and track.acodec ~=3D "none" then + -- audio track + mp.commandv("audio-add", +- edl_track or track.url, "auto", ++ url, "auto", + track.format_note or "") + elseif track.vcodec and track.vcodec ~=3D "none" then + -- video track +- streamurl =3D edl_track or track.url ++ streamurl =3D url + end + end +=20 +@@ -264,7 +294,13 @@ local function add_single_video(json) +=20 + msg.debug("streamurl: " .. streamurl) +=20 +- mp.set_property("stream-open-filename", streamurl:gsub("^data:", "dat= a://", 1)) ++ streamurl =3D streamurl:gsub("^data:", "data://", 1) ++ ++ if not url_is_safe(streamurl) then ++ return ++ end ++ ++ mp.set_property("stream-open-filename", streamurl) +=20 + mp.set_property("file-local-options/force-media-title", json.title) +=20 +@@ -526,14 +562,18 @@ mp.add_hook(o.try_ytdl_first and "on_load" or "on_lo= ad_fail", 10, function () + site =3D entry["webpage_url"] + end +=20 +- if not (site:find("https?://") =3D=3D 1) then +- site =3D "ytdl://" .. site ++ -- links with only youtube id as returned by --flat-p= laylist ++ if not site:find("://") then ++ table.insert(playlist, "ytdl://" .. site) ++ elseif url_is_safe(site) then ++ table.insert(playlist, site) + end +- table.insert(playlist, site) +=20 + end +=20 +- mp.set_property("stream-open-filename", "memory://" .. ta= ble.concat(playlist, "\n")) ++ if #playlist > 0 then ++ mp.set_property("stream-open-filename", "memory://" .= . table.concat(playlist, "\n")) ++ end + end +=20 + else -- probably a video +--=20 +2.16.1 + diff --git a/gnu/packages/patches/mpv-CVE-2018-6360-2.patch b/gnu/packages/= patches/mpv-CVE-2018-6360-2.patch new file mode 100644 index 000000000..b37e33a64 --- /dev/null +++ b/gnu/packages/patches/mpv-CVE-2018-6360-2.patch @@ -0,0 +1,59 @@ +Fix CVE-2018-6360: + +https://github.com/mpv-player/mpv/issues/5456 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=3DCVE-2018-6360 +https://security-tracker.debian.org/tracker/CVE-2018-6360 + +Patch copied from upstream source repository: + +https://github.com/mpv-player/mpv/commit/f8263e82cc74a9ac6530508bec39c7b0d= c02568f + +From f8263e82cc74a9ac6530508bec39c7b0dc02568f Mon Sep 17 00:00:00 2001 +From: Ricardo Constantino +Date: Fri, 26 Jan 2018 11:26:27 +0000 +Subject: [PATCH] ytdl_hook: move url_is_safe earlier in code + +lua isn't javascript. +--- + player/lua/ytdl_hook.lua | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua +index b480c21625..458c94af38 100644 +--- a/player/lua/ytdl_hook.lua ++++ b/player/lua/ytdl_hook.lua +@@ -84,6 +84,15 @@ local function edl_escape(url) + return "%" .. string.len(url) .. "%" .. url + end +=20 ++local function url_is_safe(url) ++ local proto =3D type(url) =3D=3D "string" and url:match("^(.+)://") o= r nil ++ local safe =3D proto and safe_protos[proto] ++ if not safe then ++ msg.error(("Ignoring potentially unsafe url: '%s'"):format(url)) ++ end ++ return safe ++end ++ + local function time_to_secs(time_string) + local ret +=20 +@@ -223,15 +232,6 @@ local function proto_is_dash(json) + or json["protocol"] =3D=3D "http_dash_segments" + end +=20 +-local function url_is_safe(url) +- local proto =3D type(url) =3D=3D "string" and url:match("^(.+)://") o= r nil +- local safe =3D proto and safe_protos[proto] +- if not safe then +- msg.error(("Ignoring potentially unsafe url: '%s'"):format(url)) +- end +- return safe +-end +- + local function add_single_video(json) + local streamurl =3D "" + local max_bitrate =3D 0 +--=20 +2.16.1 + diff --git a/gnu/packages/patches/mpv-CVE-2018-6360-3.patch b/gnu/packages/= patches/mpv-CVE-2018-6360-3.patch new file mode 100644 index 000000000..dc3e272d3 --- /dev/null +++ b/gnu/packages/patches/mpv-CVE-2018-6360-3.patch @@ -0,0 +1,84 @@ +Fix CVE-2018-6360: + +https://github.com/mpv-player/mpv/issues/5456 +https://cve.mitre.org/cgi-bin/cvename.cgi?name=3DCVE-2018-6360 +https://security-tracker.debian.org/tracker/CVE-2018-6360 + +Patch copied from upstream source repository: + +https://github.com/mpv-player/mpv/commit/ce42a965330dfeb7d2f6c69ea42d35454= 105c828 + +From ce42a965330dfeb7d2f6c69ea42d35454105c828 Mon Sep 17 00:00:00 2001 +From: Ricardo Constantino +Date: Fri, 26 Jan 2018 18:54:17 +0000 +Subject: [PATCH] ytdl_hook: fix safe url checking with EDL urls + +--- + player/lua/ytdl_hook.lua | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua +index 458c94af38..6c8e78657d 100644 +--- a/player/lua/ytdl_hook.lua ++++ b/player/lua/ytdl_hook.lua +@@ -264,18 +264,17 @@ local function add_single_video(json) + edl_track =3D edl_track_joined(track.fragments, + track.protocol, json.is_live, + track.fragment_base_url) +- local url =3D edl_track or track.url +- if not url_is_safe(url) then ++ if not edl_track and not url_is_safe(track.url) then + return + end + if track.acodec and track.acodec ~=3D "none" then + -- audio track + mp.commandv("audio-add", +- url, "auto", ++ edl_track or track.url, "auto", + track.format_note or "") + elseif track.vcodec and track.vcodec ~=3D "none" then + -- video track +- streamurl =3D url ++ streamurl =3D edl_track or track.url + end + end +=20 +@@ -284,6 +283,9 @@ local function add_single_video(json) + edl_track =3D edl_track_joined(json.fragments, json.protocol, + json.is_live, json.fragment_base_url) +=20 ++ if not edl_track and not url_is_safe(json.url) then ++ return ++ end + -- normal video or single track + streamurl =3D edl_track or json.url + set_http_headers(json.http_headers) +@@ -294,13 +296,7 @@ local function add_single_video(json) +=20 + msg.debug("streamurl: " .. streamurl) +=20 +- streamurl =3D streamurl:gsub("^data:", "data://", 1) +- +- if not url_is_safe(streamurl) then +- return +- end +- +- mp.set_property("stream-open-filename", streamurl) ++ mp.set_property("stream-open-filename", streamurl:gsub("^data:", "dat= a://", 1)) +=20 + mp.set_property("file-local-options/force-media-title", json.title) +=20 +@@ -499,6 +495,10 @@ mp.add_hook(o.try_ytdl_first and "on_load" or "on_loa= d_fail", 10, function () +=20 + msg.debug("EDL: " .. playlist) +=20 ++ if not playlist then ++ return ++ end ++ + -- can't change the http headers for each entry, so use t= he 1st + if json.entries[1] then + set_http_headers(json.entries[1].http_headers) +--=20 +2.16.1 + diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm index 8cbe590bf..5865713b8 100644 --- a/gnu/packages/video.scm +++ b/gnu/packages/video.scm @@ -6,7 +6,7 @@ ;;; Copyright =C2=A9 2015, 2016, 2017 Efraim Flashner ;;; Copyright =C2=A9 2015 Andy Patterson ;;; Copyright =C2=A9 2015 Ricardo Wurmus -;;; Copyright =C2=A9 2015, 2016, 2017 Alex Vong +;;; Copyright =C2=A9 2015, 2016, 2017, 2018 Alex Vong ;;; Copyright =C2=A9 2016, 2017 Alex Griffin ;;; Copyright =C2=A9 2016 Kei Kebreau ;;; Copyright =C2=A9 2016 Dmitry Nikolaev @@ -1018,6 +1018,9 @@ SVCD, DVD, 3ivx, DivX 3/4/5, WMV and H.264 movies.") (sha256 (base32 "1d2p6k3y9lqx8bpdal4grrj8ljy7pvd8qgdq8004fmr38afmbb7f")) + (patches (search-patches "mpv-CVE-2018-6360-1.patch" + "mpv-CVE-2018-6360-2.patch" + "mpv-CVE-2018-6360-3.patch")) (file-name (string-append name "-" version ".tar.gz")))) (build-system waf-build-system) (native-inputs --=20 2.16.1 --=-=-= Content-Type: text/plain Cheers, Alex --=-=-=--