Using gpg in combination with --decrypt mode can overwrite the input file
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
On Linux, when you execute:
sops ... --decrypt /dev/stdin ... < file1 > file2
Due to the < redirection, file1 is attached (read-only) as fd 0. This is fine, except if you're using gpg, and then the included gopgagent grabs a r/w copy of the fd (here, I think).
It looks like gopgagent assumes that /proc/self/fd/0 is a terminal, and so it writes the password prompt to it. Goodbye file contents.
Of course, the safe workaround is to use cat file1 | sops ... --decrypt ... > file2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Linux command using /dev/stdin, input redirection, and gpg, then inspect gpgagent.go at the linked location to understand how fd 0 is opened and used. Done means decrypt mode no longer overwrites the redirected input file, while the documented cat pipeline remains a safe workaround.
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