From 5f65583f443d5178e7aabbd5bbf70fa3897b7c2c Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 5 Oct 2016 01:01:10 +0000 Subject: [PATCH] MFC r306417: portsnap: only move expected snapshot contents from snap/ to files/ Previously it was possible to smuggle in addional files that would used by later portsnap runs. Now we only move those files expected to be in the snapshot into files/ and require that there are no unexpected files. This was used by portsnap attacks 2, 3, and 4 in the "non-cryptanalytic attacks against FreeBSD update components" anonymous gist. git-svn-id: svn://svn.freebsd.org/base/stable/9@306701 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/portsnap/portsnap/portsnap.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh index 498ae4e4d..d18c986cc 100644 --- a/usr.sbin/portsnap/portsnap/portsnap.sh +++ b/usr.sbin/portsnap/portsnap/portsnap.sh @@ -649,6 +649,13 @@ fetch_snapshot() { fetch_index_sanity || return 1 # Verify the snapshot contents cut -f 2 -d '|' INDEX.new | fetch_snapshot_verify || return 1 + cut -f 2 -d '|' tINDEX.new INDEX.new | sort -u > files.expected + find snap -mindepth 1 | sed -E 's^snap/(.*)\.gz^\1^' | sort > files.snap + if ! cmp -s files.expected files.snap; then + echo "unexpected files in snapshot." + return 1 + fi + rm files.expected files.snap echo "done." # Move files into their proper locations -- 2.45.0