git-secret: GnuPG2 2.2 vs 2.1 conflicts in keybox format
What are the steps to reproduce this issue?
- Initialize
git-secreton a machine usinggnupg2version 2.2 - Use
git-secret(tell,add,hide, etc.) and publish the changes - Clone your
gitrepo onto a machine usinggnupg2version 2.1 (w/ the proper keys imported) git secret reveal
What happens?
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
gpg: skipped packet of type 12 in keybox
And no secrets are revealed.
What were you expecting to happen?
The secrets to be revealed.
Any other comments?
After digging around, it seems that GnuPG 2.2 added some things to the keybox format that older versions don’t have. I realize this is a result of problems with underlying libraries. What I’m hoping is there’s some way for you to force an interoperable format by specifying a flag when creating the keybox (or just force use of the older .gpg keyring format instead of the newer .kbx).
What versions of software are you using?
Operating system:
Darwin hank-mbpr 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64Linux falcon 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
git-secret path:
*/usr/local/bin/git-secret
/usr/bin/git-secret
git-secret version:
0.2.20.2.2
git version:
git version 2.16.2git version 2.7.4
Shell type and version:
zsh 5.4.2 (x86_64-apple-darwin17.3.0)GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
gpg version:
gpg (GnuPG/MacGPG2) 2.2.3gpg (GnuPG) 2.1.11
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 48 (8 by maintainers)
Commits related to this issue
- fix: gpg2 issue about https://github.com/sobolevn/git-secret/issues/136 — committed to NCI-CGR/TypeSeq2 by weizhu365 2 months ago
For anyone else arriving here, I created a Docker image that contains git-secret and gpg 2.2 to solve this problem for me. The repo (with usage documentation) is here:
https://github.com/ncpierson/git-secret
I get why the external format of a key is stable (people exchange keys) yet the key ring format may not be forwards compatible (people upgrade, but dont downgrade, and it’s unusual to be sharing key rings rather than keys).
How about we switch to storing keys in the public key format and don’t commit the keyring that can “cache them” for repeated use:
git secret tellexports the key into a.gitsecretfolder in the standard export formatgit secret hidetries to encrypt using a keyring marked as.gitignoreso as not to be committed:The advantages of this approach should be:
git secret cleancommand to do that. Meanwhile it is a problem for only for that one user.That’s just a rough sketch I may have missed something but fundermentally using a shared key ring rather than exported public keys is an “optimisation” over the approach above. Our current “optimisation” of a shared public key ring is causing teams who use different distributions or operating systems a compatibility challenge. So we should “downgrade” our approach to have logic that uses a local ignored keyring as a “cache”.
@joshrabinowitz @sobolevn @notjames From my perspective, there’s not an ideal solution to this from the
git-secretside of things: upstream broke something they shouldn’t have. The least bad solution, imo, is to ignore the most specific error code you can ignore so long as the command seems to have worked, and then maybe issue a warning onSTDERR. It’s never fun to have workarounds in your code for weird stuff like this, but I’d say that was the best bet at working for something that’s likely to be a fairly common failure mode without accidentally ignoring real problems.@simbo1905 @sobolevn I like the RFC, I think it’s a big step forward. Would love to see 0.2.x released before this development starts though!
Because we do not want to pollute user’s main keyring with our keys. That was the main point for me in the past.
That’s good input about documenting how to export and import keys, I’ll add a ticket about that @emacdona
For bonus marks I think we can make the new approach forwards compatible with the current approach. Let’s say we version the new approach
0.3.0. We want it to be forward compatible with the current0.2.x. It’s likely that any team that stated on0.2.xwill have one new team member join who first installs0.3.0:.gitsecret/cacheand if it doesn’t exist tell the user “This repo was initialised by a previous version of git-secret, please rungit secret migrateto upgrade. The migration will keep backwards compatibility with older versions.”migratecan export out all the keys from the old keyring into the new format described above. It can the create thecachefolder, add it to.gitignore, and create the ignored personal keyring “cache” within that folder, and load in all the exported keys into it.This would mean:
We will have to maintain the old logic in the code base for a while. We can give a deprecated warning and at some future 0.4 (or 1.0!) drop that logic. I think backwards compatibility is worth the effort though as the new logic simply needs to runs the old logic and have a migrate step. We can keep an eye on how much maintenance the old logic needs and make a call to ditch it sooner rather than later if the burden is high.
So how do we make the decision to adopt the proposed approach? One idea is I could make an “RFC001.md” containing the described approach and send a PR. We can then do a code review of it and update it and use the usual “LGTM” approach. Once we are happy to merge to master its the new design. Then we can open a fresh ticket to implement it. That would avoid these long and heavy comments in the future!
I think what @simbo1905 is suggesting is that
.gitsecret/keyscontain one or more files with text representations of the public keys of the users that can access the repo, and that these text file(s) would get checked in to git.The file(s) of public keys in text representation would be portable across gpg versions. (You can see a public key in text representation with:
gpg --export --armor email@id.)The actual gpg keychains used on each given system (for each repo using git-secret) would be created, cached, and re-created from the public keys (and at least one of the needed private keys, which are probably in the user’s keychain in
~/.gnupg) as needed.The idea is that keychain files, which differ across gpg versions, would not be checked into the git repo.
In this way git-secret would avoid issues with different systems’ versions of gpg reading and writing files in
.gitsecret/keysdifferently, as these files would not get checked into the git repo or shared between systems.@notjames as I understood @simbo1905’s suggestion, we are not going to use the default keyring in
$HOME. We are going to still use the same keyring location as we use now.But, this keyring will be ignored by the
git. This way we can recreate a keyring on every machine with just importing the public keys.I like the idea of moving away from managing keyrings by ourself. Currently I can not even see any disadvantages in this approach.
@joshrabinowitz I’m actually fairly booked up for the next couple of days. Can you give me a 50,000 ft overview of what
import / exportactually involves?@joshrabinowitz @sobolevn I like that idea. Depending on whether
gpg -n --list-keysreturns a unique error code for this specific case, it may be possible to just check for that instead of parsingstdout/stderr(since parsing that kind of thing is always a hassle), but I have a suspicion it will need to be thestdout/stderrapproach.@gthank @sobolevn
So, is this the desired logic?
gpg -n --list-keyscommand,gpg: skipped packet of type 12 in keyboxPerhaps related: https://github.com/StackExchange/blackbox/issues/222 https://lists.gnupg.org/pipermail/gnupg-devel/2017-May/032846.html