You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SOPS 3.11 unable to encrypt a file with encryption context on AWS KMS #1972
I have a KMS key set up with an alias, and a policy that requires an encryption context. Using 3.11.0, I'm unable to encrypt a fresh file:
❯ sops --verbose -i -e --encryption-context AppName:vantage values.encrypted.yaml
[AWSKMS] INFO[0000] Encryption failed arn="arn:aws:kms:eu-west-2:123412341234:alias/shearn89-sandbox-myapp-sops"
Could not generate data key: [failed to encrypt new data key with master key "arn:aws:kms:eu-west-2:123412341234:alias/shearn89-sandbox-myapp-sops": failed to encrypt sops data key with AWS KMS: operation error KMS: Encrypt, https response error StatusCode: 400, RequestID: guid, api error AccessDeniedException: User: arn:aws:iam::123412341234:user/alex.shearn is not authorized to perform: kms:Encrypt on resource: arn:aws:kms:eu-west-2:123412341234:key/key-guid with an explicit deny in a resource-based policy]
If I remove the context statement, it works. If I downgrade to 3.10.2, it also works...
Happy to help with testing any branch fixes, or setting up example keys/policies. The policy in the first post is what we use, and then we set --encryption-context AppName:myapp on first encryption.
Hi - any chance this can be investigated? The git bisect clearly shows where the bug was introduced, and I've included an example KMS policy to require the context being passed.
I will try and get time myself but I'm not familiar with the code base.
The policy linked here doesn't actually Deny if the context is missing, so it passes anyway. The policy in my original post does Deny, hence the failure.
Hi - any chance this can be investigated? The git bisect clearly shows where the bug was introduced, and I've included an example KMS policy to require the context being passed.
I had this on my list of things to look at, but there was too much going on in the last months and I forgot about it... Sorry. I'm glad you were able to create a PR to fix t.
Activity
matheuscscp commentedon Oct 21, 2025
This works for me:
Result:
Decryption also works:
Result:
shearn89 commentedon Oct 21, 2025
Would you mind sharing a redacted snippet of the KMS key policy applied to the key, I wonder if that's my problem?
matheuscscp commentedon Oct 21, 2025
Here you go:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Enable IAM User Permissions", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<redacted>:root" }, "Action": "kms:*", "Resource": "*" }, { "Sid": "Allow kustomize-controller to decrypt using the key", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<redacted>:role/flux-d2-kustomize-controller" }, "Action": [ "kms:Decrypt", "kms:DescribeKey" ], "Resource": "*" } ] }felixfontein commentedon Oct 21, 2025
This is more likely caused by a dependency upgrade (i.e. some behavior change in Amazon's SDK).
shearn89 commentedon Oct 21, 2025
Okay - work is busy this week but if I get time I’ll try and build from source so I can do a git bisect to find the issue…
shearn89 commentedon Oct 22, 2025
Okay - ran a
git bisect, and 84c7673 is the first bad commit.shearn89 commentedon Oct 22, 2025
Introduced in #1939, @felixfontein.
shearn89 commentedon Oct 22, 2025
Happy to help with testing any branch fixes, or setting up example keys/policies. The policy in the first post is what we use, and then we set
--encryption-context AppName:myappon first encryption.shearn89 commentedon Dec 16, 2025
Hi - any chance this can be investigated? The git bisect clearly shows where the bug was introduced, and I've included an example KMS policy to require the context being passed.
I will try and get time myself but I'm not familiar with the code base.
shearn89 commentedon Dec 16, 2025
The policy linked here doesn't actually Deny if the context is missing, so it passes anyway. The policy in my original post does Deny, hence the failure.
felixfontein commentedon Dec 16, 2025
I had this on my list of things to look at, but there was too much going on in the last months and I forgot about it... Sorry. I'm glad you were able to create a PR to fix t.
shearn89 commentedon Jan 7, 2026
Any chance of a bugfix release for 3.11 anytime soon? 😁
felixfontein commentedon Jan 11, 2026
Since features already have been merged the next release will be 3.12.0.