Decrypt fails (IncompleteSignatureException) depending on path, cwd
This is on a Mac, I was unable to reproduce this on my Linux machine.
The encrypted file is in, for example, /Users/myself/some/random/path.
If calling sops -d /Users/myself/some/random/path/file.enc.json, the following error occurs:
Group 0: FAILED
arn:aws:kms:us-east-1:831617005271:key/9f8c0d27-f319-42bd-9e54-e20f59b44ae3: FAILED
- | Error decrypting key: IncompleteSignatureException: 'access'
| not a valid key=value pair (missing equal-sign) in
| Authorization header: 'AWS4-HMAC-SHA256 Credential=paste
| access key/20180117/us-east-1/kms/aws4_request,
| SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-target,
| Signature=e56c097f7ec0554816b86dff449a0c3b3b6d2b3867d73c3799f08393938255a9'.
| status code: 400, request id:
| 284ea281-fbaf-11e7-ad69-3f88f6957d83
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.
From /Users/myself/another_dir, if running sops -d ../some/random/path/file.enc.json, the error also occurs.
Only case we can get it to work is by cd'ing into /Users/myself/some/random/path and running sops -d file.enc.json.
File is encrypted with a KMS key and confirmed the user can access the key.
Just checking if I understand this correctly -- you can only decrypt files in the current working directory, but not files outside of it? I'll see if I can reproduce.
Thank you!
Yes, for this user, that seems to be the case. He and I can only reproduce on his Mac, though, so I am wondering if it might be environment specific. Another colleague with a Mac can decrypt just fine.
They are both using 3.0.0, I can check on the OS version or any other details if you need them.
The error seems odd to me given how we reproduced this, that it would crop up as an issue with the access token we are using to retrieve the KMS key so I am wondering if it is failing in some silent or unobvious way well before this, say wherever the input file path parsing is happening.
Did you paste the error message sops output as it was, or did you redact anything? I ask because paste access key in the Authorization header for the AWS request looks suspicious:
Authorization header: 'AWS4-HMAC-SHA256 Credential=paste access key/20180117/us-east-1/kms/aws4_request,SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-target,
This is just a wild guess, but with the current information I have the most likely cause seems misconfigured AWS credentials. Perhaps when you try from a different directory, you have a different environment (as in environment variables, which the AWS Go SDK might use for credentials).
Grepping through this user's home directory for that string might be helpful.
I did not redact anything, I will check with him, tomorrow, to follow up on your suggestion. It seems a likely hypothesis, thanks!
Any news on this?
Oh, yes, sorry. Turns out you were right however that string came from a not obvious place. The user has direnv so in different directories, would have different env vars, including in the failing cases AWS_ACCESS_KEY="paste access key".
I know this is already closed but wanna document the solution for my problem as well and this was the first result in google. I happened to face this issue on Jenkins using helm secrets. The issue there was that the AWS credentials were injected as AWS access key and secret and somehow it tampered with the credential format. Use the credentials as standard username/password separated with the proper names (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) to solve it.