Просмотр исходного кода

* apt-pkg/acquire-item.cc:
- remove 'old' InRelease file if we can't get a new one before
proceeding with Release.gpg to avoid the false impression of a still
trusted repository by a (still present) old InRelease file.
Thanks to Simon Ruderich for reporting this issue! (CVE-2012-0214)

Michael Vogt лет назад: 14
Родитель
Сommit
b7a6594d1e
3 измененных файлов с 43 добавлено и 2 удалено
  1. 7 0
      apt-pkg/acquire-item.cc
  2. 7 2
      debian/changelog
  3. 29 0
      test/integration/test-releasefile-verification

+ 7 - 0
apt-pkg/acquire-item.cc

@@ -1608,6 +1608,13 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*
 {
    if (AuthPass == false)
    {
+      // Remove the 'old' InRelease file if we try Release.gpg now as otherwise
+      // the file will stay around and gives a false-auth impression (CVE-2012-0214)
+      string FinalFile = _config->FindDir("Dir::State::lists");
+      FinalFile.append(URItoFileName(RealURI));
+      if (FileExists(FinalFile))
+	 unlink(FinalFile.c_str());
+
       new pkgAcqMetaSig(Owner,
 			MetaSigURI, MetaSigURIDesc, MetaSigShortDesc,
 			MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,

+ 7 - 2
debian/changelog

@@ -1,4 +1,4 @@
-apt (0.8.15.10) UNRELEASEDunstable; urgency=low
+apt (0.8.15.10) unstable; urgency=high
 
   [ David Kalnischkies ]
   * algorithms.cc:
@@ -7,6 +7,11 @@ apt (0.8.15.10) UNRELEASEDunstable; urgency=low
     - put <brackets> around email addresses
   * doc/po/de.po:
     - apply typo-fix from Michael Basse, thanks! (LP: #900770)
+  * apt-pkg/acquire-item.cc:
+    - remove 'old' InRelease file if we can't get a new one before
+      proceeding with Release.gpg to avoid the false impression of a still
+      trusted repository by a (still present) old InRelease file.
+      Thanks to Simon Ruderich for reporting this issue! (CVE-2012-0214)
 
   [ Chris Leick ]
   * German manpage translation update
@@ -27,7 +32,7 @@ apt (0.8.15.10) UNRELEASEDunstable; urgency=low
      Correct fi translation for hash sum mismatches (lp:420403)
      Thanks to Jani Uusitalo
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Tue, 06 Dec 2011 16:35:39 +0100
+ -- Michael Vogt <mvo@debian.org>  Tue, 06 Mar 2012 14:14:26 +0100
 
 apt (0.8.15.9) unstable; urgency=low
 

+ 29 - 0
test/integration/test-releasefile-verification

@@ -153,6 +153,35 @@ runtest() {
 	installaptold
 }
 
+runtest2() {
+	prepare ${PKGFILE}
+	rm -rf rootdir/var/lib/apt/lists
+	signreleasefiles 'Joe Sixpack'
+	msgtest 'Cold archive signed by' 'Joe Sixpack'
+	aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
+
+	# New .deb but now an unsigned archive. For example MITM to circumvent
+	# package verification.
+	prepare ${PKGFILE}-new
+	find aptarchive/ -name InRelease -delete
+	find aptarchive/ -name Release.gpg -delete
+	msgtest 'Warm archive signed by' 'nobody'
+	aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
+	testequal "$(cat ${PKGFILE}-new)
+" aptcache show apt
+	failaptnew
+
+	# Unsigned archive from the beginning must also be detected.
+	rm -rf rootdir/var/lib/apt/lists
+	msgtest 'Cold archive signed by' 'nobody'
+	aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
+	testequal "$(cat ${PKGFILE}-new)
+" aptcache show apt
+	failaptnew
+}
+runtest2
+
+
 DELETEFILE="InRelease"
 runtest
 DELETEFILE="Release.gpg"