| 1 |
|
| 2 |
|
| 3 |
Package Verification with dpkg: Implementation |
| 4 |
|
| 5 |
John Goerzen <[email protected]> |
| 6 |
|
| 7 |
Version 5; January 4, 2001 |
| 8 |
|
| 9 |
1 Introduction |
| 10 |
|
| 11 |
As part of a continuing effort to improve the security of |
| 12 |
users of Debian and Debian-based systems, one step that |
| 13 |
is important to take is to allow the users to verify for |
| 14 |
themselves that .deb packages that they have are from an |
| 15 |
authentic source. This mechanism is intended to prevent |
| 16 |
various types of attacks. Some are: |
| 17 |
|
| 18 |
* Preventing people from setting up a fake Debian archive, |
| 19 |
containing potentially trojaned packages, and masquerading |
| 20 |
as a real Debian archive. This attack can be thwarted |
| 21 |
by checking an origin signature, checking archive signatures, |
| 22 |
or checking maintainer signatures. |
| 23 |
|
| 24 |
* Preventing altered .deb packages from being installed undetected. |
| 25 |
Since all signatures are applied to the contents, any |
| 26 |
signature that is checked will protect against this attack. |
| 27 |
|
| 28 |
* Preventing people from separating or inserting forged data |
| 29 |
or metadata into a package. Because all signatures are |
| 30 |
applied to both the control and the data chunks together, |
| 31 |
separating them will not be possible without causing a |
| 32 |
signature failure. |
| 33 |
|
| 34 |
* Helping to prevent old packages from being presented as |
| 35 |
new. By checking the signature date, policy files can |
| 36 |
be set to reject packages that contain old signatures. |
| 37 |
Sites might re-sign their packages periodically with an |
| 38 |
"archive" or a "timeliness" |
| 39 |
signature that could be used specifically for this purpose. |
| 40 |
|
| 41 |
* Allowing verification to ensure that a given package was |
| 42 |
part of a particular archive site, distribution, made |
| 43 |
by a particular developer, etc. Signatures could be applied |
| 44 |
for various stages of development -- approval by QA managers, |
| 45 |
release managers, etc. The multiple signature per .deb |
| 46 |
architecture outlined in this proposal allows this. |
| 47 |
|
| 48 |
* Allowing verification of an isolated .deb, even in the |
| 49 |
absence of an Internet connection or access to an archive. |
| 50 |
By including the signatures inside the .deb itself, it |
| 51 |
is not necessary to download signed index files to verify |
| 52 |
a signature. |
| 53 |
|
| 54 |
1.1 Unaddressed Problems |
| 55 |
|
| 56 |
The approach set forth in this document leaves one hole that |
| 57 |
must be solved by other means. That problem is the task |
| 58 |
of insuring the integrity of the keys, policy files, and |
| 59 |
programs themselves used to carry out the verification. |
| 60 |
One potential solution is to modify apt-get to support https |
| 61 |
and use trusted third-party (e.g., Thawte) to shore up this |
| 62 |
problem. |
| 63 |
|
| 64 |
The mechanism used to ensure old packages are not presented |
| 65 |
as new might be resource-intensive on the server in some |
| 66 |
situations. One potential avenue to explore there might |
| 67 |
be to provide signed Packages files on the server. |
| 68 |
|
| 69 |
1.2 Rationale |
| 70 |
|
| 71 |
Some thought has gone into the design of this particular |
| 72 |
solution. For benefit of future discussions, here is some |
| 73 |
information on how this mechanism was chosen and reasons |
| 74 |
for it. Here are the main alternatives that have been considered: |
| 75 |
|
| 76 |
GPG The additional complexity of doing so and the possibility |
| 77 |
of separating the signature from the .deb makes this approach |
| 78 |
undesirable. |
| 79 |
|
| 80 |
GPG unusable without a current dpkg and GPG installed |
| 81 |
on the system. Since it breaks backward compatibility |
| 82 |
in such a severe way, this approach is also undesirable. |
| 83 |
|
| 84 |
Sig-per-chunk A sig-per-chunk system would place separate |
| 85 |
sigs in the ar file for the data and the control chunks. |
| 86 |
Unfortunately, this would allow someone to mix and match |
| 87 |
data and control data in making trojan .debs, which can |
| 88 |
also be a security threat. |
| 89 |
|
| 90 |
Sig-per-repository A sig-per-repository system would place |
| 91 |
an md5sum of a .deb into the Packages files and sign those. |
| 92 |
However, this omits fine-grained control and prevents |
| 93 |
verification of a .deb in absence of the Packages file |
| 94 |
from the Internet. It also requires solutions to problems |
| 95 |
of determining which archive a package came from. |
| 96 |
|
| 97 |
The policy files (see section [Policy Definitions]) |
| 98 |
are designed to be simple, straightforward, and easy to |
| 99 |
both write and parse. By keeping them as simple as possible, |
| 100 |
the potential for both human authoring errors and parsing |
| 101 |
errors in software can be minimized. |
| 102 |
|
| 103 |
2 Modifications to .deb |
| 104 |
|
| 105 |
Currently, a .deb consists of an ar archive containing debian-binary, |
| 106 |
control.tar.gz, and data.tar.gz files. These files represent |
| 107 |
package meta-data and package contents, respectively. Each |
| 108 |
signature will be applied to the debian-binary, control.tar.gz, |
| 109 |
and data.tar.gz files concatenated together in that order. |
| 110 |
The files should not be decompressed before applying the |
| 111 |
signature. |
| 112 |
|
| 113 |
Each signature file will be stored in the ar archive and |
| 114 |
have a name of this form: |
| 115 |
|
| 116 |
_gpgtype |
| 117 |
|
| 118 |
Therefore, an origin signature would be named _gpgorigin. |
| 119 |
The "type" string must not exceed 10 characters |
| 120 |
in length nor be less than 1 character. |
| 121 |
|
| 122 |
Therefore, an origin signature in GnuPG format would be named |
| 123 |
_sig-origin.gpg. At this time, all signatures must be in |
| 124 |
GnuPG format. |
| 125 |
|
| 126 |
3 Signatures and Types |
| 127 |
|
| 128 |
Each .deb file that is signed must have at least an origin |
| 129 |
signature. This signature should be unique per entity. For |
| 130 |
instance, Debian, Helix, and Progeny would each provide |
| 131 |
an origin signature. The origin signature is used as a key |
| 132 |
into the policy database such that the proper policy description |
| 133 |
can be loaded to describe the file. |
| 134 |
|
| 135 |
Beyond the origin signature, the signature types that are |
| 136 |
present or required are defined by the site policy. Examples |
| 137 |
of other signatures might be a maintainer signature from |
| 138 |
the person that built the package, a signature from quality |
| 139 |
assurance certifying that the package has passed QA tests, |
| 140 |
a signature from a release manager certifying that a package |
| 141 |
was part of a given distribution release, and a signature |
| 142 |
from an archive maintainer certifying that the package went |
| 143 |
into an archive. |
| 144 |
|
| 145 |
4 A Runthrough |
| 146 |
|
| 147 |
To make sure the entire process is entirely clear, here is |
| 148 |
what will occur when a package is processed: |
| 149 |
|
| 150 |
1. The Key ID of the origin signature will be obtained. This |
| 151 |
will be used to determine the directory in which to look |
| 152 |
for policy files and keyrings as specified in section |
| 153 |
[locations]. |
| 154 |
|
| 155 |
2. The checker will iterate over each policy file in that |
| 156 |
directory in an arbitrary order, doing the following: |
| 157 |
|
| 158 |
(a) Compare the Origin: line in the policy file (see section |
| 159 |
[Origin line]) with the Key ID of the origin signature. |
| 160 |
If there is a difference, immediately die because of |
| 161 |
suspected corrupted policy files. |
| 162 |
|
| 163 |
(b) Evaluate the selection clauses, if any, in the policy |
| 164 |
file. If there are any that do not pass, skip to the |
| 165 |
next policy file. If all of them pass, or there are |
| 166 |
no selection clauses, adopt the current policy file |
| 167 |
as authoritative for the package. |
| 168 |
|
| 169 |
(c) If no appropriate policy files are found, reject the |
| 170 |
package as having a bad (unverifyable) signature. |
| 171 |
|
| 172 |
3. Given the appropriate policy file, the checker will iterate |
| 173 |
over every verification clause in that file. If all of |
| 174 |
them pass, the package is considered to pass the test. |
| 175 |
If any of them fail, the package is considered to have |
| 176 |
failed the test and processing immediately exits. No other |
| 177 |
policy files will ever be tested after this point. If |
| 178 |
the policy file contains no verification clauses, it will |
| 179 |
be rejected as invalid. |
| 180 |
|
| 181 |
It is possible that other package verifiers that use the |
| 182 |
same .deb architecture but different verification procedures |
| 183 |
may be introduced in the future. This section is not intended |
| 184 |
to imply a prohibition against such. |
| 185 |
|
| 186 |
5 File Locations |
| 187 |
|
| 188 |
The following locations are defined for files that comprise |
| 189 |
this system:<locations> |
| 190 |
|
| 191 |
* /etc/debsigs/policy/Origin-ID/* contains one or more policy |
| 192 |
files that are to be applied for .debs whose Origin key |
| 193 |
was signed by the Key ID as listed in the path. The policies |
| 194 |
are tried in a non-deterministic order until one matches |
| 195 |
the selection criteria. Once one matches the selection |
| 196 |
criteria, the success or failure of the entire check is |
| 197 |
entirely contingent upon the success or failure of the |
| 198 |
verification clauses. If no policy file matches the selection |
| 199 |
criteria, then the entire operation is determined to fail. |
| 200 |
|
| 201 |
* /usr/share/debsigs/keyrings/Origin-ID/* contains one or |
| 202 |
more keyrings that are used by the policy files for the |
| 203 |
given origin. They may be symlinks to keyrings located |
| 204 |
elsewhere if desired. This is used as the directory for |
| 205 |
the keyrings in the RequiredSig and OptionalSig lines |
| 206 |
unless an absolute path is specified there. |
| 207 |
|
| 208 |
The policy files are located in /etc because sites may opt |
| 209 |
to alter the criteria for installing files on their site. |
| 210 |
The keyrings are located in /usr/share because they should |
| 211 |
not be altered locally. Because of the multi-file and multi-directory |
| 212 |
nature, it is easy for organizations to provide packages |
| 213 |
providing information for verification of certain things. |
| 214 |
For instance, Debian could provide a debian-debsigs-potato |
| 215 |
package which contains a policy file and a potato release |
| 216 |
file. It could depend on debian-debsigs-main package, which |
| 217 |
contains the keyring for the origin field, a symlink to |
| 218 |
the main Debian keyring for the maintainers field, and a |
| 219 |
dependency on debian-keyring. |
| 220 |
|
| 221 |
6 Related Documents |
| 222 |
|
| 223 |
References |
| 224 |
|
| 225 |
de Winter, Brenno. Gnu Privacy Guard Mini Howto at http://www.dewinter.com/gnupg_howto/english/. |
| 226 |
|
| 227 |
References |
| 228 |
|
| 229 |
Free Software Foundation. The GNU Privacy Handbook at http://www.gnupg.org/gph/en/manual.html. |
| 230 |
|
| 231 |
References |
| 232 |
|
| 233 |
Free Software Foundation. gpg manpage available on local |
| 234 |
systems with gpg or at http://www.gnupg.org/gpgman.html. |
| 235 |
|
| 236 |
References |
| 237 |
|
| 238 |
Braakman, Dorman, et al. Debian Packaging Manual at http://www.debian.org/doc/packaging-manuals/packaging.html/. |
| 239 |
|
| 240 |
References |
| 241 |
|
| 242 |
Quinlan, Daniel. Filesystem Hierarchy Standard at http://www.pathname.com/fhs/. |