Skip to content

slice bounds out of range #463

@danielepolencic

Description

@danielepolencic

I'm not sure what I did wrong, but I created a new key with gpg2 --gen-key and the following details:

  • RSA and RSA
  • 4096 bit
  • Passphrase
  • Valid email address

I can see the key in the keyring:

$ gpg2 --list-keys
/Users/pole/.gnupg/pubring.gpg
------------------------------
pub   4096R/A1212CC9 2019-05-04
uid       [ultimate] CI Learnk8s <ci@learnk8s.io>
sub   4096R/D4E8760A 2019-05-04

When I try to sops --pgp "A1212CC9" , it crashes:

sops --pgp "A1212CC9" secret2.enc.json
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
go.mozilla.org/sops/pgp.(*MasterKey).encryptWithGPGBinary(0xc0000201c0, 0xc00002e3a0, 0x20, 0x20, 0x1a81ee0, 0xc0004f2080)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/pgp/keysource.go:69 +0x340
go.mozilla.org/sops/pgp.(*MasterKey).Encrypt(0xc0000201c0, 0xc00002e3a0, 0x20, 0x20, 0x100dff8, 0xc00000e060)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/pgp/keysource.go:170 +0xbc
go.mozilla.org/sops/keyservice.(*Server).encryptWithPgp(0xc00018e468, 0xc000068050, 0xc00002e3a0, 0x20, 0x20, 0x20, 0x17d8860, 0xc00018e3f0, 0xc00018e470, 0x100d769)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/keyservice/server.go:24 +0x6c
go.mozilla.org/sops/keyservice.Server.Encrypt(0xc000032000, 0x1a93a60, 0xc0000d2030, 0xc00000e060, 0x1868b40, 0xc00000e001, 0xc00000e060)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/keyservice/server.go:106 +0x530
go.mozilla.org/sops/keyservice.LocalClient.Encrypt(...)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/keyservice/client.go:30
go.mozilla.org/sops.(*Metadata).UpdateMasterKeysWithKeyServices(0xc00021c0c0, 0xc00002e3a0, 0x20, 0x20, 0xc000068020, 0x1, 0x1, 0x0, 0x0, 0x2)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/sops.go:549 +0x2fc
go.mozilla.org/sops.(*Tree).GenerateDataKeyWithKeyServices(0xc00021c0c0, 0xc000068020, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1753d8c)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/sops.go:440 +0x23a
main.editExample(0x1a88ce0, 0xc0002103c0, 0x1a99280, 0x2089cf8, 0x1a99280, 0x2089cf8, 0x7ffeefbff97c, 0x10, 0x0, 0xc000068020, ...)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/cmd/sops/edit.go:77 +0x36d
main.main.func5(0xc000128f20, 0x0, 0x0)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/cmd/sops/main.go:607 +0x2192
go.mozilla.org/sops/vendor/gopkg.in/urfave/cli%2ev1.HandleAction(0x17f8060, 0x1947088, 0xc000128f20, 0x0, 0x0)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/vendor/gopkg.in/urfave/cli.v1/app.go:490 +0xc8
go.mozilla.org/sops/vendor/gopkg.in/urfave/cli%2ev1.(*App).Run(0xc00019da00, 0xc0000c6000, 0x4, 0x4, 0x0, 0x0)
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/vendor/gopkg.in/urfave/cli.v1/app.go:264 +0x590
main.main()
        /private/tmp/sops-20190418-79323-1cw3pqc/sops-3.3.0/src/go.mozilla.org/sops/cmd/sops/main.go:649 +0x2578

More details:

$ sops -v
sops 3.3.0 (latest)
$ gpg2 --version
gpg (GnuPG/MacGPG2) 2.0.30
libgcrypt 1.6.6
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA, RSA, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2 

I'm on Mac 10.14.4.
Happy to share the keys as well (every time I generate a new one I can see that error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions