getsops / getsops/sops

SOPS not working in custom Gitpod workspace

Open
#935 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
23.1k
Forks
1.1k
Avg merge
1d 11h
Merged PRs (30d)
9

Description

Bug description

SOPS is not working in my custom image. I get the following error:

~ $ sops -d --in-place test.yaml
Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  31F8CE55BE04D165DBE7C5562E8BD8308FC62F66: FAILED
    - | could not decrypt data key with PGP key:
      | golang.org/x/crypto/openpgp error: Could not load secring:
      | open /home/gitpod/.gnupg/secring.gpg: no such file or
      | directory; GPG binary error: exit status 2

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.

I had previously encrypted the file with no problems:

my: ENC[AES256_GCM,data:YZV3QA==,iv:63Tuoc1S/P2kH8lyA2g2NE67Ld4m1vjzj2++1oZ+hZQ=,tag:47ZkFQOOiTSe1+olsefuWg==,type:str]
very: ENC[AES256_GCM,data:LmoCsaFpiAdi,iv:QQA9Q79eZz1jROHF+9htKX6IssNaEdbLAWU0qHV6f1Q=,tag:gsiRZCP5oVYqzKZE6wFu8Q==,type:str]
sops:
    kms: []
    gcp_kms: []
    azure_kv: []
    hc_vault: []
    age: []
    lastmodified: "2021-09-09T19:36:26Z"
    mac: ENC[AES256_GCM,data:TgGxanEhrCGuiz/ThBi0wdanBkpycKC7X3/e2xPSd29Pl/EatIyuP0RrU1GLaXOt244RUGKBq8gyOrpzAqq4pQx7z6Snr3/1Y6Ns10qA2P/aTz5627k6fC1eXzzJZ9VUCz5GDjRlgYLozpbnr1ewpisJlYTa5/vFLz0ulI2GinI=,iv:NpxLimDPTMLEbGFRy4wUksZl2/3iFIG0A3B10KzGf2I=,tag:UKwx6/yEHMN9LRrdUkpiJw==,type:str]
    pgp:
        - created_at: "2021-09-09T19:36:26Z"
          enc: |
            -----BEGIN PGP MESSAGE-----

            hQGMAxWBySvYZYwIAQwApty1xnCdPgaW6rsfaL6x/ErPgF2nz8TyTIV7r93+Z3Zr
            qX70eZT67LitWp9RLrUact95IGvUYCILSgwpi1cSEF258q3GgfRKI+gTz97ZoX/n
            iICaXhmgKQWgSRwsGHLnM+yK1GhDDRPpUUV6nY3otx7XSr2e05RPrc6/9iDosyQq
            RpgqkJJ++ksClLHYWvKu9Pf5yonfOJss9s8hnKtTYFw3zhuRlkW14AT/3EYzluCK
            USP+jXKjmYRNV2pVdoKiPEqTA4F6DqpACWAP0TQzZwTS1EvvU8lkViqyWT0Z5K1X
            5iM7hmNMZG7RBj2v8FA4JUmRhAYCL8PrR9VJvuB1KFu3g1tFl9jlJMU1mERi9stL
            tOSOhoV7zc61u97HFyJl6sLNvfdUUyzV6u/ZNJ/Uq9XfBuepCMvP1O2d6SHqIqDR
            2JdJlL8EKYKDhVmBlZ9qTgSEzOH+Etluveb2gbslldTo8qAey05GzkOA8Pghva2x
            Kzlfn/v0lZ3/ysQzkaRw0l4BZAaTOdPff8I9r2tRQm47QJozo2QjUAxwXC9amJpU
            XQQ9Jxcbzu+LigVrWNbIHwtR3knLVBCRS4OtAiFJ6Vbjc8kmaRUOWv1oKdYLve3a
            fiqwl3ID0aYAsWXmJnOp
            =2RnQ
            -----END PGP MESSAGE-----
          fp: 31F8CE55BE04D165DBE7C5562E8BD8308FC62F66
    unencrypted_suffix: _unencrypted
    version: 3.7.1
Steps to reproduce
# create key manually
~ $ gpg --generate-key

# list keys
~ $ gpg --list-keys
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2023-09-09
/home/gitpod/.gnupg/pubring.kbx
-------------------------------
pub   rsa4096 2014-10-28 [SC]
      409B6B1796C275462A1703113804BB82D39DC0E3
uid           [ unknown] Michal Papis (RVM signing) <mpapis@gmail.com>
uid           [ unknown] Michal Papis <michal.papis@toptal.com>
uid           [ unknown] [jpeg image of size 5015]
sub   rsa2048 2015-11-02 [E]

pub   rsa4096 2016-11-11 [SC]
      7D2BAF1CF37B13E2069D6956105BD0E739499BDB
uid           [ unknown] Piotr Kuczynski <piotr.kuczynski@gmail.com>
sub   rsa4096 2016-11-11 [E]

pub   rsa3072 2021-09-09 [SC] [expires: 2023-09-09]
      31F8CE55BE04D165DBE7C5562E8BD8308FC62F66
uid           [ultimate] testing <test@test.com>
sub   rsa3072 2021-09-09 [E] [expires: 2023-09-09]

# export the key fingerprint for future use
~ $ export SOPS_PGP_FP="31F8CE55BE04D165DBE7C5562E8BD8308FC62F66"

# encrypt the test file
~ $ sops -e --in-place test.yaml

# decrypt - the error appears
~ $ sops -d --in-place test.yaml
Failed to get the data key required to decrypt the SOPS file.

Group 0: FAILED
  31F8CE55BE04D165DBE7C5562E8BD8308FC62F66: FAILED
    - | could not decrypt data key with PGP key:
      | golang.org/x/crypto/openpgp error: Could not load secring:
      | open /home/gitpod/.gnupg/secring.gpg: no such file or
      | directory; GPG binary error: exit status 2

Recovery failed because no master key was able to decrypt the file. In
order for SOPS to recover the file, at least one key has to be successful,
but none were.
Anything else?
~ $ gpg --version
gpg (GnuPG) 2.2.19
libgcrypt 1.8.5
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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: /home/gitpod/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
~ $ sops --version
sops 3.7.1 (latest)

I did not install gpg. I did install SOPS, like so:

RUN curl -sSL -o /tmp/sops "https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux" && \
    chmod +x /tmp/sops && \
    mv /tmp/sops /usr/bin

Here is my custom image Dockerfile.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the encryption and decryption commands with the stated SOPS 3.7.1 and GnuPG 2.2.19 versions, then trace the PGP decryption path that reports the missing secring.gpg. Check the linked custom-image Dockerfile and verify that the encrypted test.yaml can decrypt successfully in that workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.