原文出处:http://www.cs.arizona.edu/people/justin/packagemanagersecurity/attacks-on-package-managers.html
Overview
Security vulnerabilities are often the result of software bugs. It isimportant to keep software up-to-date, as malicious parties often can exploit bugs in outdated software. Package managers were created to automatethe process of package update and installation, however, if the package manageris not secure, it may represent another avenue of attack!
Package managers are normally run with unrestricted access inorder to allow them to modify critical system software. The packagemanager's actions, therefore, affect the entire system and make thesecurity of package managers vital.
Given their critical role, the expectation would be for package managers to be extremely secure.Weexamined ten popular package managers (APT, YUM, YaST, etc.) for Linuxand BSD systems and found vulnerabilities in all of them. Theattacks discussed here can give attackers the ability to read or eraseany file on your computer, capture passwords, set up a backdoor intoyour system, etc. without needing to compromise any keys or passwords.
Attack Anatomy: Replay Attacks
To provide an example of the sorts of attacks an attacker can launch on packagemanagers, this page describes an example attack called areplay attack.Other attacksare described on a separatepage.
The First Piece: Metadata Replay
Packages are essentially trusted forever once they or repositorymetadata describing them has been signed. This means that even after apackage has a vulnerability discovered in it, clients will continue tobe willing to install that insecure package.An attacker can replaythe correctly signed packages or metadata from a previous release andyour computer will install software with flaws that the attacker canexploit.
The default behavior of package managers is to install the mostrecent version of a requested package that is available from thedistribution. Keeping a client safe would seem to be just a matter ofretrieving the latest repository metadata provided by the distributionon a regular basis.
The Second Piece: Mirror Control
Unfortunately, replay attacks on package managers are still verypossible even if a client frequently requests updated repositorymetadata. The problem is that most distributions use a network ofpublicly provided servers to host their mirrors. In most cases,the people and organizations running these mirrors are only superficially examinedbefore they are listed as an official public mirror. Once listed as apublic mirror, a distribution will begin directing requests to themirror.
To give an example of how easy it is for a malicious party toobtain a mirror, we ran an experiment where we created a fakeadministrator and company name and leased a server from a hostingprovider. We were able to get our mirror listed on every distributionwe tried (Ubuntu, Fedora, OpenSuSE, CentOS, and Debian) and our mirrorswere contacted by thousands of clients, even including military andgovernment computers!
Since there is so little verification of who owns and runs a mirror, there is no guarantee that the mirror is benevolent.Theymay, in fact, be talking to an attacker who has setup a mirror andbecome listed as an official mirror for the distribution.
Some distributions do simple checking that the mirrors respondwith updated and valid content. However, such checks only serve todiscover benevolent mirrors that have fallen behind. They are unable todetect a maliciously operated mirror. Attackers can respond to thedistribution's queries with the expected answer while at the same timetargeting the public at large or individual clients with differentresponses. These targeted responses can include old signed files ormanipulated unsigned files.
Impact: What Can an Attacker Do With a Replay Attack?
Vulnerable Package Installation
When a user installs a package, their package manager retrieves froma repository mirror the list of available packages. A malicious mirrorcan respond to the client with an outdated signed list of packages oran arbitrary list of outdated packages, depending on characteristics ofthe package manager (described in theFAQ).Theclient only knows that files it receives are properly signed by theirdistribution. They do not know that what they have received is an oldlist of packages.
Due to the way existing package managers are currentlyimplemented, it is even possible to provide a client an older list offiles than a list they have already seen. That is, if a client alreadyobtained an updated, signed list of packages yesterday but they aretalking to a malicious mirror today, the malicious mirror can providethe client a signed list of packages from the year before. Themalicious mirror needs only to have a copy of signed files that weremade available by the distribution.They do not need to have compromised the signing key.
Preventing Security Updates
A malicious mirror doesn't have to provide a client outdatedpackages with vulnerabilities known to the attacker in order to leavethe client vulnerable. All that an attacker needs to do is tocontinuously serve the client the same repository metadata. Over time,even though vulnerabilities become known in various packages and newversions become available, the client will never see them whenupdating.
For example, it is known that an earlier version of OpenSSLfor Debian has a security flaw. The list of files from the repositorythat previously included this package is still correctly signed. Usingthis old signed file list, a malicious mirror can keep a client on theinsecure version of OpenSSL by responding to the client's packagemanager with the old list of files.
Protecting Yourself
Things You Can Do Today:
- Use repositories you trust.Use only mirrors thatbelong to reputable organizations. Don't randomly choose mirrors, evenfrom official lists. The official lists of public repositories oftencontain many superficially verified mirrors.
- Manually update your systems (and local mirror caches).Know when package updates become available and what the versions shouldbe. Manually verify and install the updated packages (or add them toyour local mirror cache that your systems update from) rather thanrelying on automated updates. We have observed mirrors many months outof date for some distributions, so you should check periodically thatyour mirror is being updated.
- Use signed repository metadata.If your package manager or distribution does not yet support signedmetadata but only signed packages, at least require signed packagesuntil signed metadata is supported.
- Use HTTPS for mirror communication.Unfortunately, this is generally only available with paid supportservices (and only protects you against man-in-the-middle attacks, notmalicious mirrors). However, by running a distribution with HTTPSsupport on their mirrors, a man-in-the-middle attacker cannot easilylaunch an attack as though it were a mirror.
In the future:
- Use package managers that sign repository metadata.Unsigned repository metadata gives malicious partiesmore leverage in their attacks.
- Use package managers that implement metadata expiration.If there is no way in a package manager for metadata to ever expire, replay attacks will be able to go unnoticed.
- Use distributions that properly make use of the package manager's security features.If a distribution doesn't sign repository metadata or expire thesesigned files even though the package manager supports doing so, itdoesn't help you stay secure.
People
Justin Cappos,Justin Samuel,Scott Baker,John H. Hartman.
Contact us at:or if you prefer want to use GPG, contactusing the GPG key withgpg key fingerprint: 66EF 84E2 F184 B140 712B 55A7 2B96 AB8F DDF1 F3EEathttps://www.cs.arizona.edu/~jsamuel/
Acknowledgments
We would like to thank Ryan Giobbi and the CERT Coordination Center for contacting many of the major package managers and distributions.We appreciate James Hamilton ofOffshoot Inc.creating the logoat the top of this page.We also appreciate the comments given to us by Ryan Giobbi, Igor Crk,Michael Piatek, Angelos Stavrou, Chris Gniady, Yoshi Kohno, and Wenjun Hu.