getsops / getsops/sops

SOPS_AGE_KEY_FILE not being able to read from file descriptors in SSS setups

Open
#2,162 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently, I am building a system where I fetch one or more AGE keys from a remote storage and pass them to SOPS dynamically without touching the disk or polluting environment variables. To meet strict security requirements (preventing the key from leaking via /proc//environ or persisting on disk), I am passing the keys via a file descriptor (e.g., /dev/fd/X or bash process substitution <(fetch_key)).

However, SOPS fails to process the key this way. Because file descriptors/pipes are read-once streams (non-seekable), if SOPS attempts to read the file multiple times during its execution, the stream is already exhausted after the first read, resulting in a failure.

I'd like for SOPS to support from read-once streams (like /dev/fd/* or named pipes). The ideal behavior would be for SOPS to read the contents of the key file into memory exactly once during initialization, and reuse that buffered in-memory value for all decryption operations, rather than attempting to reopen or read from the file path multiple times.

Some alternatives I've tried:

  1. Using SOPS_AGE_KEY: Rejected due to strict security policies. Environment variables are visible to other processes via /proc/PPID/environ and can easily leak in crash dumps or child processes.
  2. Writing to /tmp or /dev/shm: Rejected because writing secrets to the filesystem (even temporary or memory-backed ones) creates a risk of lingering files if the process crashes before cleanup.

I am willing to contribute and fix this! I plan to open a PR shortly to buffer the AGE key upon the first read, which should seamlessly add support for file descriptors. I'm opening this issue to track the problem and discuss the approach.

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

Start by tracing how SOPS_AGE_KEY_FILE is loaded and where the key file is read during initialization and decryption. Reproduce the failure with a /dev/fd path or named pipe, then verify that buffering the key once allows repeated decryption operations without rereading the stream.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, security
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.