getsops / getsops/sops

Binary files are not encrypted when encrypted_suffix is specified

Open
#986 0 comments 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

Hello,

I'm using 3.7.1 on Ubuntu 20.04.3 LTS. I noticed that binary files are not encrypted by sops, when encrypted_suffix is provided in .sops.yaml. See below files for an example.

# secret.txt
this is a secret value
# .sops.yaml
---
creation_rules:
  - path_regex: 'secret\.txt'
    encrypted_suffix: _encrypted
    key_groups:
      - pgp:
          - ... # valid fingerprint

Next enter the following command: sops -e secret.txt > secret.txt.sopsenc.json. As a result of this command I get the following file:

{
	"data": "this is a secret value",
	"sops": {
		"...": null,
		"mac": "ENC[...]",
		"pgp": [
			{
				"created_at": "2022-01-10T14:25:14Z",
				"enc": "...",
				"fp": "..."
			}
		],
		"encrypted_suffix": "_encrypted",
		"version": "3.7.1"
	}
}

But I expect such a file:

{
	"data_encrypted": "ENC[...]",
	"sops": {
		"...": null,
		"mac": "ENC[...]",
		"pgp": [
			{
				"created_at": "2022-01-10T14:25:14Z",
				"enc": "...",
				"fp": "..."
			}
		],
		"encrypted_suffix": "_encrypted",
		"version": "3.7.1"
	}
}

I see two solutions for this case:

  1. automatic append value of encrypted_suffix key to data key name, but in this case encrypted_regex still will not work,
  2. add new configuration key, like data_key_name, that will have value data_encrypted in my case, so will work regardless of encrypted_* setting.

Thank you in advance for considering my request

Regards
Piotr Minkina

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 report with the shown .sops.yaml and sops -e secret.txt command, comparing the produced JSON with the expected data_encrypted output. Trace how encrypted_suffix is handled for the binary/JSON output path, then add coverage for the reported case and verify that the resulting data key is encrypted without regressing other encrypted_* settings.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.