|
| 1 | +(chisel_security_ref)= |
| 2 | + |
| 3 | +# Chisel Cryptographic Documentation |
| 4 | + |
| 5 | +Chisel downloads Debian packages from |
| 6 | +[archive.ubuntu.com](https://archive.ubuntu.com/), and extracts only selected |
| 7 | +few files from each package. The slice definition files in |
| 8 | +[chisel-releases](https://github.com/canonical/chisel-releases) specify the |
| 9 | +files to extract. |
| 10 | + |
| 11 | +Chisel is written in Go. |
| 12 | + |
| 13 | +## Detailed Process |
| 14 | + |
| 15 | +1. Chisel downloads and parses the YAMLs from |
| 16 | +[chisel-releases](https://github.com/canonical/chisel-releases) repo[^1]. The |
| 17 | +Go package [net/http](https://pkg.go.dev/net/http) is used and a tarball is |
| 18 | +downloaded over HTTPS. Checksum of the tarball is not checked after downloading. |
| 19 | + |
| 20 | + Chisel maintains a cache of these files[^2]. When making new requests to |
| 21 | + download a release, Chisel reads the Etag from cache and checks whether the |
| 22 | + cache is still valid. If it is valid, the cached release YAMLs are used. |
| 23 | + |
| 24 | +1. Chisel downloads a few *InRelease* files from the [Ubuntu Archive |
| 25 | +but](http://archive.ubuntu.com) these files are never cached. The InRelease |
| 26 | +files are signed by GPG, and Chisel verifies[^3] the integrity using the [Ubuntu |
| 27 | +Archive Automatic Signing |
| 28 | +Key](https://keyserver.ubuntu.com/pks/lookup?search=f6ecb3762474eda9d21b7022871920d1991bc93c&fingerprint=on&op=index).[^4] |
| 29 | +The key is specified in the [chisel.yaml in |
| 30 | +chisel-releases](https://github.com/canonical/chisel-releases/blob/a442b2e7208128df6366f859b7a858c0d3fce925/chisel.yaml#L47). |
| 31 | +The Go package [golang.org/x/crypto/openpgp](http://golang.org/x/crypto/openpgp) |
| 32 | +is used for these purposes. |
| 33 | + |
| 34 | +1. After parsing the *InRelease* files, Chisel downloads *Packages.gz* and |
| 35 | +subsequently *Packages* from the archive. Downloads are performed over HTTP and |
| 36 | +later the digests are cross-checked[^5]. The Go package |
| 37 | +[hash](https://pkg.go.dev/hash) is used. Chisel maintains a cache of these |
| 38 | +downloaded files. Each file is stored in the cache with their digest as the |
| 39 | +filename. |
| 40 | + |
| 41 | +1. The specified files in the slice definition files are extracted from the |
| 42 | +downloaded Debian packages. |
| 43 | + |
| 44 | +## (Relevant) Packages used by Chisel |
| 45 | + |
| 46 | +Following lists the relevant packages used by Chisel to support its |
| 47 | +cryptographic needs: |
| 48 | + |
| 49 | +* [golang.org/x/crypto/openpgp](http://golang.org/x/crypto/openpgp) (Go package) |
| 50 | + |
| 51 | +Additionally these Go standard library packages are used: |
| 52 | + |
| 53 | +* [net/http](https://pkg.go.dev/net/http) |
| 54 | +* [hash](https://pkg.go.dev/hash) |
| 55 | + |
| 56 | +## Cryptographic technology being exposed to the user |
| 57 | + |
| 58 | +Chisel needs a GPG public key specified in the [chisel.yaml in |
| 59 | +chisel-releases](https://github.com/canonical/chisel-releases/blob/a442b2e7208128df6366f859b7a858c0d3fce925/chisel.yaml#L47) |
| 60 | +to verify the signed InRelease files it downloads from the Ubuntu Archive. This |
| 61 | +file (chisel.yaml) is exposed to the user and Users can very much specify a |
| 62 | +different key on their forks. |
| 63 | + |
| 64 | +The default public key in the official repository is the RSA/4096-bit [Ubuntu |
| 65 | +Archive Automatic Signing Key |
| 66 | +(2018)](https://keyserver.ubuntu.com/pks/lookup?search=f6ecb3762474eda9d21b7022871920d1991bc93c&fingerprint=on&op=index) |
| 67 | +with ID 871920D1991BC93C. |
| 68 | + |
| 69 | +``` |
| 70 | +pub (4)rsa4096/f6ecb3762474eda9d21b7022871920d1991bc93c 2018-09-17T15:01:46Z |
| 71 | +uid Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com> |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +[^1]: [https://github.com/canonical/chisel/blob/v1.2.0/internal/setup/fetch.go#L32](https://github.com/canonical/chisel/blob/v1.2.0/internal/setup/fetch.go#L32) |
| 76 | + |
| 77 | +[^2]: [https://github.com/canonical/chisel/blob/v1.2.0/internal/cache/cache.go](https://github.com/canonical/chisel/blob/v1.2.0/internal/cache/cache.go) |
| 78 | + |
| 79 | +[^3]: The chain of trust here is that we fully trust GitHub so when we download the chisel-release from it we are also "downloading" the public keys. So, because the public keys are trusted, the downloads from the Ubuntu archives can also be trusted. |
| 80 | + |
| 81 | +[^4]: [https://github.com/canonical/chisel/blob/v1.2.0/internal/archive/archive.go#L285](https://github.com/canonical/chisel/blob/v1.2.0/internal/archive/archive.go#L285) |
| 82 | + |
| 83 | +[^5]: [https://github.com/canonical/chisel/blob/v1.2.0/internal/cache/cache.go#L72-L78](https://github.com/canonical/chisel/blob/v1.2.0/internal/cache/cache.go#L72-L78) |
0 commit comments