Skip to content

Commit 1f31e80

Browse files
committed
add initial draft of 0034 Package Integrity
1 parent 13b5084 commit 1f31e80

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

rfcs/0034-package-integrity.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
feature: package-integrity
3+
start-date: 2018-09-28
4+
author: lrvick
5+
co-authors:
6+
related-issues:
7+
- https://github.com/NixOS/nix/issues/404
8+
- https://github.com/NixOS/nix/issues/613
9+
- https://github.com/NixOS/nix/issues/748
10+
---
11+
12+
# Summary
13+
[summary]: #summary
14+
15+
This RFC seeks to provide a strategy to allow NixOs to strongly attest who
16+
authored a package, who reviewed it, and that the package has not been tampered
17+
with.
18+
19+
# Motivation
20+
[motivation]: #motivation
21+
22+
Nix currently does not have any method to attest who authored a nixpkg, who
23+
reviewed it, or that a given binary cached package was actually built from
24+
a given .nix file in version control.
25+
26+
In practice this means that a bad actor can gain remote code execution on NixOS
27+
systems if any of the following are true:
28+
29+
* A Github employee is coerced or malicious
30+
* The Github account credentials of any maintainer are compromised
31+
* A successful BGP attack on github.com or similar to create an MITM
32+
* A cache server is compromised
33+
34+
Essentially NixOS has many single points of trust, and thus single, points of
35+
failure.
36+
37+
This is a serious design flaw and we can learn lessons from other package
38+
management systems that have been burned by similarly poor package management
39+
designs.
40+
41+
See examples of major security incidents in other package managers:
42+
43+
* Gentoo: https://archives.gentoo.org/gentoo-announce/message/dc23d48d2258e1ed91599a8091167002
44+
* Debian: https://lists.debian.org/debian-devel-announce/2006/07/msg00003.html
45+
* NPM: https://eslint.org/blog/2018/07/postmortem-for-malicious-package-publishes
46+
* PyPi: https://www.reddit.com/r/Python/comments/8hvzja/backdoor_in_sshdecorator_package/
47+
* Ubuntu Snap: https://github.com/canonical-websites/snapcraft.io/issues/651
48+
* Arch Linux AUR: https://lists.archlinux.org/pipermail/aur-general/2018-July/034153.html
49+
50+
# Detailed design
51+
[design]: #detailed-design
52+
53+
## Package Contributor
54+
55+
### Workflow
56+
57+
1. Author and test a nixpkg
58+
2. Builds a nixpkg and adds the hash of the binary to the nixpkg
59+
3. PR a signed commit adding adding nixpkg to NixOS/nixpkgs repo
60+
61+
### Notes
62+
63+
* Can be enforced by mandating all commits be signed in VCS settings
64+
* Contributors who choose not to sign will need someone else to PR for them
65+
66+
## Package Maintainer
67+
68+
### Workflow
69+
70+
1. Verify signing key ID is listed in maintainers list
71+
* Add key ID to maintainers list if not already present
72+
2. Verify signature on PR matches public key id in contributors list
73+
* Add key ID to contributors list if not already present
74+
3. Review content of new PR for general best practices
75+
4. Ensure signatures/hashes verified for third party code referenced
76+
5. Build package and verify artifact hash matches hash contained in nixpkg
77+
6. Make signed merge commit to master of NixOS/nixpkgs
78+
79+
### Notes
80+
81+
* Maintainer signatures should be a hard requirement
82+
* Maintainer and Contributor should never be the same person.
83+
* Some packages may not be reproducible and should get special flag set
84+
85+
## Cache maintainer
86+
87+
### Workflow
88+
89+
1. Pull code from VCS repo
90+
2. Compile all new nixpkgs
91+
3. Publish artifacts
92+
93+
### Notes
94+
95+
* signed nixpkgs now contain artifact hashes removing need for cache signing
96+
97+
## Nix Clients
98+
99+
### Workflow
100+
101+
1. Pull latest nixpkgs VCS repo
102+
2. Verify author/reviewer commit signatures for all nixpkg.
103+
3. Attempt to fetch cached artifact during install
104+
4. Verify artifact hash against hash in given nixpkg during install
105+
106+
### Notes
107+
108+
* Nix clients can opt to only trust reproducible builds with hashes.
109+
110+
# Drawbacks
111+
[drawbacks]: #drawbacks
112+
113+
Some contributors to NixOS may no longer contribute if doing so requires some
114+
additional security work.
115+
116+
# Alternatives
117+
[alternatives]: #alternatives
118+
119+
## Git Notes signing
120+
121+
Reviewer/maintainer signatures could be added to the Git Notes interface on
122+
a given ref allowing m-of-n signing for security critical packages.
123+
124+
This would additionally negate the need for merge commits and would allow
125+
VCS automatic merging to be used if desired.
126+
127+
## Patch ID
128+
129+
One could chose to sign a Git "patch-id" instead of a given ref hash. This
130+
would allow signatures to still be valid even if a git rebase was done that
131+
didn't add any LOC changes to a given changeset. This could add flexibility
132+
but will need more testing.
133+
134+
Example:
135+
136+
```
137+
git diff-tree -p "someref"..HEAD | git patch-id --stable | gpg -as
138+
```
139+
140+
## Detached signatures
141+
142+
We could avoid using VCS level signing at all and simply mandate maintainers
143+
add their detached .nix.sig files to a PR before it merges.
144+
145+
# Unresolved questions
146+
[unresolved]: #unresolved-questions
147+
148+
149+
# Future work
150+
[future]: #future-work
151+
152+
It may be desireable to continue to have an untrusted package repo like the
153+
one used today that users can install from by hand as they please.
154+
155+
This could be an analogue of the Arch Linux User Repository (AUR) vs the
156+
trusted/signed official repos.

0 commit comments

Comments
 (0)