07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.3.3.1. Auditing Packages: debsums and its Limits<br />

GOING FURTHER<br />

Protecting against upstream<br />

changes<br />

debsums is useful in detecting changes to files coming from a Debian package,<br />

but it will be useless if the package itself is compromised, for instance if the Debian<br />

mirror is compromised. Protecting against this class of aacks involves<br />

using APT's digital signature verification system (see Section 6.5, “Checking<br />

Package Authenticity” (page 119)), and taking care to only install packages<br />

from a certified origin.<br />

debsums is an interesting tool since it allows finding what installed files have been modified<br />

(potentially by an attacker), but this should be taken with a grain of salt. First, because not<br />

all Debian packages provide the fingerprints required by this program (they can be found in<br />

/var/lib/dpkg/info/package.md5sums when they exist). As a reminder: a fingerprint is a<br />

value, often a number (even though in hexadecimal notation), that contains a kind of signature<br />

for the contents of a file. This signature is calculated with an algorithm (MD5 or SHA1 being wellknown<br />

examples) that more or less guarantee that even the tiniest change in the file contents<br />

implies a change in the fingerprint; this is known as the “avalanche effect”. This allows a simple<br />

numerical fingerprint to serve as a litmus test to check whether the contents of a file have<br />

been altered. These algorithms are not reversible; in other words, for most of them, knowing<br />

a fingerprint doesn't allow finding the corresponding contents. Recent mathematical advances<br />

seem to weaken the absoluteness of these principles, but their use is not called into question<br />

so far, since creating different contents yielding the same fingerprint still seems to be quite a<br />

difficult task.<br />

In addition, the md5sums files are stored on the hard disk; a thorough attacker will therefore<br />

update these files so they contain the new control sums for the subverted files.<br />

The first drawback can be avoided by asking debsums to base its checks on a .deb package instead<br />

of relying on the md5sums file. But that requires downloading the matching .deb files<br />

first:<br />

# apt-get --reinstall -d install `debsums -l`<br />

[ ... ]<br />

# debsums -p /var/cache/apt/archives -g<br />

It is also worth noting that, in its default configuration, debsums automatically generates the<br />

missing md5sums files whenever a package is installed using APT.<br />

The other problem can be avoided in a similar fashion: the check must simply be based on<br />

a pristine .deb file. Since this implies having all the .deb files for all the installed packages,<br />

and being sure of their integrity, the simplest way is to grab them from a Debian mirror. This<br />

operation can be slow and tedious, and should therefore not be considered a proactive technique<br />

to be used on a regular basis.<br />

# apt-get --reinstall -d install `grep-status -e 'Status: install ok<br />

➥ installed' -n -s Package`<br />

[ ... ]<br />

Chapter 14 — Security<br />

385

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!