|
| 1 | +--- |
| 2 | +title: "SPEC 6 — Keys to the Castle" |
| 3 | +date: 2022-12-19 |
| 4 | +author: |
| 5 | + - "Stéfan van der Walt <stefanv@berkeley.edu>" |
| 6 | + - "Jarrod Millman <millman@berkeley.edu>" |
| 7 | +discussion: |
| 8 | +endorsed-by: |
| 9 | +--- |
| 10 | + |
| 11 | +## Description |
| 12 | + |
| 13 | +<!-- |
| 14 | +Briefly and clearly describe the proposal. |
| 15 | +Explain the general need and the advantages of this specific proposal. |
| 16 | +If relevant, include examples of how the new functionality would be used, |
| 17 | +intended use-cases, and pseudo-code illustrating its use. |
| 18 | +--> |
| 19 | + |
| 20 | +Projects engage with restricted resources all the time. |
| 21 | +Examples include access to add & remove team members, grant commit rights, or make uploads to certain hosts. |
| 22 | + |
| 23 | +**Documenting resources** is critical to ensuring uninterrupted operations. |
| 24 | +It is important that team members know _who_ have access to resources, and how to _gain access_ to resources. |
| 25 | +For example, if updated project documentation needs to be uploaded to a remote server via SSH, who are the team members that can do that, and by which process can a release manager request access? |
| 26 | + |
| 27 | +Furthermore, project developers sometimes have to **share secrets**, such as server passwords and social media logins. |
| 28 | +Typically, such secrets are distributed among those who need them, without any centralized system for tracking the secrets or who has access to them. |
| 29 | +When a server needs to be accessed, there is often a scramble to find someone with credentials. |
| 30 | + |
| 31 | +This SPEC discusses the requirements for a system to distribute secrets, provides an example implementation, and lists suitable hosted services. |
| 32 | + |
| 33 | +It should be noted that, in many cases, secrets & passwords can be avoided. |
| 34 | +Most online services (GitHub, PyPi, etc.), have permissioning systems through which developers can be given the required access. |
| 35 | +Access to servers can be given through SSH keys, which each developer has to safeguard. |
| 36 | +This document deals with the situation in which that is not possible, and secrets have to be shared. |
| 37 | + |
| 38 | +### Principles |
| 39 | + |
| 40 | +1. Restricted project resources must be documented. |
| 41 | + |
| 42 | + Examples include servers that host services or web pages, and the processes for adding/removing project members on GitHub, chat, mailing lists, etc. |
| 43 | + |
| 44 | +2. Assign the lowest privilege needed for a developer to do their work meaningfully. |
| 45 | + |
| 46 | + Review permissions regularly (say, every six months) to maintain minimal permissions. |
| 47 | + |
| 48 | +3. A system for distributing project secrets must have the following properties: |
| 49 | + |
| 50 | + - Secrets are stored encrypted in a central (remote) location. |
| 51 | + - It must be possible to grant access to the secrets to a select group of team members. |
| 52 | + - It must be possible to revoke future access to the secrets.[^future-access] |
| 53 | + - The system must not rely on closed source or commercial encryption facilities, that |
| 54 | + can later disappear or be made unavailable, although such a solution can be considered if it allows for all data to be exported. |
| 55 | + |
| 56 | + Whichever system is chosen, its user interface should match the capabilities of the intended users. |
| 57 | + This reduces the risk of passwords being copied out to less secure mechanisms such as sticky notes or text files. |
| 58 | + If the target audience is not used to GPG or the command prompt, for example, the `pass` implementation below may not work, and an alternative like 1password or bitwarden should be considered. |
| 59 | + |
| 60 | +4. _Tokens_ form a common subset of secrets stored. These should always be scoped (minimal necessary permissions), and set to expire after a reasonable time period (a year, typically). |
| 61 | + Instructions for rotating and revoking the token must be documented. |
| 62 | + |
| 63 | +[^future-access]: Revoking access to a service implies both (a) revoking access to secrets and (b) re-generating those secrets, since the actor could have copied them. |
| 64 | + |
| 65 | +## Implementation |
| 66 | + |
| 67 | +### Password storage: hosted |
| 68 | + |
| 69 | +The following hosted solutions conform to the principles in (2) above. |
| 70 | + |
| 71 | +Self-hosted solutions: |
| 72 | + |
| 73 | +- [vaultwarden](https://github.com/dani-garcia/vaultwarden); open source |
| 74 | + |
| 75 | +Paid solutions: |
| 76 | + |
| 77 | +- [bitwarden](https://bitwarden.com/) provides a non-profit discount of 25%; hosted open source |
| 78 | + |
| 79 | +Sponsored solutions: |
| 80 | + |
| 81 | +- [1password](https://github.com/1Password/1password-teams-open-source); closed source |
| 82 | + |
| 83 | +#### Password storage: offline |
| 84 | + |
| 85 | +[Pass](https://www.passwordstore.org/) is the standard unix password manager, which stores passwords as encrypted files on disk. |
| 86 | +[password vault](https://github.com/scientific-python/vault-template) is an example implementation that satisfies the principles listed above. |
| 87 | +The secrets are stored, encrypted, in a public Git repository. |
| 88 | +The vault uses [gopass](https://github.com/gopasspw/gopass), a more user friendly implementation of pass, to manage access via GPG keys. |
| 89 | +Each secret is encrypted using the public keys of all developers that should have access. |
| 90 | +If a developer's access is removed, the vault is re-encrypted so that that developer cannot read future copies of the repository (but secrets are considered compromised and must, thus, be rotated). |
| 91 | + |
| 92 | +### Other common scenarios |
| 93 | + |
| 94 | +- **Publishing packages**: PyPi provides a [trusted publisher](https://docs.pypi.org/trusted-publishers/using-a-publisher/) mechanism for avoiding passwords |
| 95 | + |
| 96 | +### Other security recommendations |
| 97 | + |
| 98 | +- **2FA**: Developers must use two-factor authentication for service logins. |
| 99 | + This reduces the risk of account takeovers and subsequent fraudulent software releases. |
| 100 | +- **Passwords** must be generated by a password manager. |
| 101 | + This ensures that they are of sufficient length and complexity. |
| 102 | +- **SSH keys** must have a password. Ed25519 is the current recommended key type, and can be generated with `ssh-keygen -t ed25519`. |
| 103 | + |
| 104 | +### Core Project Endorsement |
| 105 | + |
| 106 | +<!-- |
| 107 | +Discuss what it means for a core project to endorse this SPEC. |
| 108 | +--> |
| 109 | + |
| 110 | +### Ecosystem Adoption |
| 111 | + |
| 112 | +<!-- |
| 113 | +Discuss what it means for a project to adopt this SPEC. |
| 114 | +--> |
| 115 | + |
| 116 | +## Notes |
| 117 | + |
| 118 | +See [gopass's security goals](https://github.com/gopasspw/gopass/blob/master/docs/security.md#security-goals). |
| 119 | + |
| 120 | +<!-- |
| 121 | +Include a bulleted list of annotated links, comments, |
| 122 | +and other ancillary information as needed. |
| 123 | +--> |
0 commit comments