Repository navigation
Description
This proposal explores ways to enable out-of-tree encryption backends in SOPS. The goal is to make it easy to add new encryption backends, including private ones.
Other components that could benefit from out-of-tree extensibility, such as stores and publishing backends, are out of scope.
Related PRs:
- Add support for OpenStack Barbican #683
- Add YC KMS provider support #1097
- Add Cloud.ru KMS support #1718
- ocikms: Oracle Cloud KMS support #1226
- Add support for OVH KMS in SOPS #1906
- feat(hckms): Add HuaweiCloud KMS support #2001
- [Feature] Support Tencent Cloud KMS #1984
As stated multiple times, maintainers are open to a plugin system for encryption backends. This avoids adding dependencies and responsibilities to core SOPS. In the future, moving even core providers out-of-tree would make evolving (and forking) them a lighter process.
I've explored two approaches, and I'm looking for maintainer feedback before investing more time.
Option 1: build on the existing key service infrastructure
This approach was discussed in #481, but I don't think it went anywhere.
I Hacked together sops-generic-keyservice, a proof-of-concept key service server compatible with Scaleway Key Manager and OVH Key Management Service. For a lack of better alternative, it currently piggybacks on AWS' --kms flag to pass arbitrary configuration to the KMS.
I believe this approach can get us far without requiring major/breaking changes in SOPS. Some backward-compatible improvements are needed to make "Generic KMS" a first class backend:
- Add support for
generic_keyin the key service API:message Key { oneof key_type { ... GenericKey generic_key = 7; // or google.protobuf.Struct ? } } message GenericKey { // Allow key service servers to filter only the requests they can handle. string kms_id = 1; map<string, google.protobuf.Value> configuration = 2; }
- Add the corresponding flags, e.g
--generic-kms '{"kms_id": "mykms", "configuration": {"foo": "bar"}}'. Passing a JSON object is inelegant but straightforward. One can also look at how Terraform handles complex dynamic values through flags and environment variables. - Add the corresponding configuration options
creation_rules: - generic_kms: - kms_id: mykms configuration: foo: bar
Option 2: build a plugin system
A fully fledged plugin system:
- Offers a sleeker user experience, without the need to start services and export environment variables before running SOPS.
- Offers a cleaner API than the keyservice one, purpose-built for providers to implement.
- Lays the groundwork to make other components pluggable, like stores and publishing backends.
- Requires more upfront design, and more coding effort.
This option is not exclusive with option 1: we may rely on a generic key service to interate on the KMS plugin API without affecting core SOPS. Once the API is stable enough, and providers exist for multiple backends (including core ones), we can merge it into SOPS.
I did not invest time in pursuing that option. Maybe PluginRPC would be a good fit, but it leaves installing the executable up to the user.
Next Steps
I'd appreciate feedback from maintainers on pursuing option 1. I can work on a draft PR if this direction sounds reasonable.
Activity
felixfontein commentedon Dec 13, 2025
From a user point of view, Option 2 is easier to use, and also to set-up. Especially if you need to use multiple different encryption backends at once. But I haven't spent that much time thinking about it so far, so this is just a first reaction :)
CC @getsops/maintainers any opinions?
felixfontein commentedon Dec 13, 2025
PluginRPC sounds (on a first glance) similar to what I was thinking about when I thought about plugins before. I'm not sure whether that specific project is a good idea though, it doesn't seem to be very actively developed, doesn't seem to have a big community, and might require a CLA (pluginrpc/pluginrpc#1 (comment) seems to indicate it, I didn't found something elsewhere).
It might also be a good idea to look closer at what age is doing - it also supports plugins, and its maintainer has a lot of experience with Go and security, so what they use can't be a too bad choice.
kuzaxak commentedon Dec 22, 2025
@felixfontein Maybe worth to consider the Helm way with wasm: wazero or the same as Helm extism runtime?
Proposal from Helm is here
UPD: Extism is using Wazero, sorry for confusion.
kuzaxak commentedon Dec 23, 2025
Not possible as. unfortunately, wasm runtime don't have crypto and network access.
Maybe the Hashicorp gRPC to the local approach would be a good start?
Age is using subprocess and passing data via stdin\out
gokselk commentedon Dec 24, 2025
I've worked on plugin systems before and they're a hassle to get right.
Here's my take on this. Age uses subprocess + stdin/stdout which seems like the simplest path. They use a custom multi-line text format called stanzas (same format as their encrypted files), but for SOPS plain JSON should work:
Operation is inferred from the request (
plaintext= encrypt,ciphertext= decrypt). The--sops-plugin=v1flag prevents accidental execution and gives room for protocol changes later. Plugins handle their own credentials via env vars or config files.Errors return
{"error": "message"}.KMS calls are network bound anyway so subprocess overhead shouldn't matter.
Just a rough draft, happy to hear thoughts.
felixfontein commentedon Dec 24, 2025
I think an RPC interface similar to what age uses makes more sense, as it allows to reuse connections for example if multiple identities are used with the same KMS. I guess both JSON or Protobuf are fine; Protobuf has the advantage that we already use it for communication with keyservices, while JSON is simpler and would allow to implement plugins without having to use Protobuf.
I think the most important thing is that the protocol is well-documented (the age plugin protocol is not really well documented, or at least I couldn't find any documentation on it - I had to read the code to understand how it works).
gokselk commentedon Dec 24, 2025
Looking at the existing backends, the protocol seems pretty minimal, so JSON would probably be enough. But I'm fine with either approach.
Good point about connection reuse. Keeping the plugin process alive with newline delimited JSON over stdin/stdout would handle that nicely IMO.
ndrpnt commentedon Dec 29, 2025
I'm also in favor of a simple communication protocol via stdin/stdout (and maybe forward flags and/or environment variables). I believe spinning up a gRPC server would make plugin lifecycle management more complex.
I would prefer JSON over protobuf, to enable writing simple adhoc plugins. For example shell scripts that wrap a CLI. Protobuf forces plugin authors to install the toolchain and have some know-how just to generate stubs. Sure SOPS could distribute a plugin SDK/library (like Terraform does), but that seems overkill for a few RPCs.
Plugin discovery can be done by searching the PATH for executables named
sops-*(orsops-kms-*if we want to differentiate plugin types), similar to whatkubectldoes. I think it is reasonable to leave plugin installation up to the user.Thinking more about it, a plugin system still requires adding a
GenericKeytype to the key service API, right?That change being rather limited in scope, I'd love to see it land soon as to: integrate SOPS with new encryption backends, iterate on the plugin API out of tree, and gather feedback on the key service API with real usecases at hand.
What about adding an
ExperimentalGenericKeyV1type with (obviously) no backward compatibility guarantee?[Thinking out loud] We may want to invoke the same plugin with different configurations.
We could do that by forwarding
--generic-kms-<kms_id>-*flags andSOPS_GENERIC_KMS_<KMS_ID>_*environment variables to plugin subprocesses after stripping the prefix.For example, to run the
sops-awsplugin with different AWS profiles depending on the key, one could write:And then run:
ndrpnt commentedon Dec 31, 2025
Correct me if I'm wrong, multiple identities mean multiple requests to the keyservice, which would make keeping a plugin running awkward.
felixfontein commentedon Feb 26, 2026
I recently had to think of this thread when I was thinking about stores and store plugins (similar to encryption plugins). The data structure that store plugins need to handle are potentially better handled as Protobuf data than JSON, especially since JSON is known to cause a lot of problems for certain data types (numbers: precision loss and being able to distinguish between integers and floats) and doesn't support other data types like timestamps or dates.
Obviously one can work around this (use objects instead of simple values and store all kind of data in strings insead of JSON native data types), but it's more annoying in JSON than Protobuf.
reneleonhardt commentedon Feb 27, 2026
For human-readable configuration, YAML 1.2 seems to be best option currently (decimals instead of float precision loss, ISO timestamps, more secure, less ambiguous, explicit typing if needed, no recursive entity expansion).
felixfontein commentedon Feb 28, 2026
@reneleonhardt I'm not sure how that relates to a format for inter-process communication that's written and read by machines?
devx commentedon Mar 27, 2026
I spent some time and working towards an ADR for the plugin as disscused in this thread I do have few questions and would love some guidance.
top-level arrays" format, or should plugins be stored only in
key_groupsgoing forward and use the top-level form only for backward-compatibility when
reading old data?
also duplicates schema and serialization logic for a brand-new key type.
key_reftruly opaque, or will SOPS standardize common fields?friendlier dedicated flags.
this abstraction layer.
they can also hide plugin-side bugs or interact badly with non-idempotent
backends.
.sops.yamlinstance_idmandatory for all plugin-backed keys?that must remain stable over time.
instance_idvalidation?stable plugin instance identity and environment prefix generation.
instance_idand derive a safe envprefix separately, for example by normalization plus hashing.
ExperimentalGenericKeyV1orPluginKeyin keyservice.as experimental, local-only, or fully supported.
worst case, too revealing. It may need truncation and redaction rules.
ndrpnt commentedon May 30, 2026
Some related issues that, I think, would be covered by a plugin system:
I hope to have time to work on that this summer
Dexmachi commentedon Jun 29, 2026
I've been working on an interface for this for a while
I don't have that much experience, but I tried to do a general enough solution, it can be found in #2210
I'd love to get comments on this, as this would open up a lot of opportunities for SOPS
deblasis commentedon Aug 28, 2026
TL;DR: An implementation exists: out-of-process plugins, working branch + spec + reference plugin which is the OCI-KMS from my PR #1226
I've followed this thread (and #2210) for a while, then I moved onto other things but yesterday I was reminded about this so I put something together.
Obviously I used my judgement as a veteran (old) software engineer to steer a couple of LLMs in a loop. Happy to provide details if interested.
I hope this is received the right way. It seems that the discussion has been going in circles on design questions that are hard to settle in the abstract, I went and built a complete implementation on a branch, to turn the questions into ones with evidence attached. Not opening a PR yet, this post is asking for a steer first.
What's built (branch plugin-system on my fork, ~53 commits over main, zero new core dependencies):
That comment is what convinced me this direction had maintainer support, and the spec is written so a plugin is ballpark 80 lines in any language (the appendix contains a complete minimal Python plugin).
Full spec: https://github.com/deblasis/sops/blob/plugin-system/docs/plugins/spec.md#the-sops-plugin1-protocol-specification.
Branch: https://github.com/deblasis/sops/tree/plugin-system.
Reference plugin: https://github.com/deblasis/sops-plugin-ocikms
The questions I'd love a maintainer steer on (these are the forks where community members have gone different ways, and I'll happily re-scope to match):
Happy to turn any of this into a stack of piecemeal reviewable cute PRs 😄, or fold the useful parts into whatever shape the project prefers. Credit where due: @devx 's ADR questions and @ndrpnt 's related-issue list (#2170, #2157) shaped the scope, and #2210's instance work informed the config discussion.
Dexmachi commentedon Aug 28, 2026
@deblasis I love this implementation of yours!
Honestly, I've been a bit bummed that the RFC (#2210) hasn't seen much upstream discussion lately since I've been looking at this closely, but seeing that someone else took the torch and built something this robust is amazing. I'm a relatively newer software engineer compared to you, but I'd love to chime in on a few topics:
Regarding the implementation points:
I do have a quick architectural question regarding DevEx and the Handshake:
While handshakes and version negotiation make the protocol much more robust and safer against regressions, I'm curious about how you see this impacting the DevEx for community members creating new (and perhaps simple) plugins, I ask this specifically because I built my RFC with DevEx in mind, so that plugins could be created more easily
Could you share a bit more on how the handshake is implemented under the hood? I'd love to get a better understanding of how you balanced that extra protocol strictness with keeping the barrier to entry low for plugin creators. (Both to gather more knowledge as a SWE and to see how it operates in your spec)
Making a quick read through your branch, it is quite impressive what you've done, mine honestly looks like a POC in comparison! I'd love for this to be the selected process, if it gets merged
really really happy to see this moving forward, and I'd be glad to try and contribute with yours, or to receive contributions on mine!
ndrpnt commentedon Sep 1, 2026
Hey @Dexmachi, @deblasis, thanks for helping move this forward. I empathize with the urge to have a working implementation.
I'd be happy if the maintainers want to move forward with one of the proposed implementation. Speaking for myself, I have a hard time engaging with your comments/PRs, sorry. I'm not saying it's slop, but maybe lacking empathy?
BTW, note that if you really need this, it is already possible—albeit hacky—to integrate stock SOPS with external encryption backends. You can find some examples (OVH, Scaleway, and a simple PluginRPC-based system) in the repository linked in the issue.
deblasis commentedon Sep 2, 2026
Thanks @Dexmachi, and genuinely, your RFC was one of the inputs I worked from, so "shaped this" is literal. And for what it's worth, the gap between us is is just a few more rounds of iteration. Also, I leveraged your work, you had to come up with something from scratch so... Nicely done!
deblasis commentedon Sep 2, 2026
Thanks @ndrpnt. I hear that the comments/PRs have been hard to engage with. That's useful to know, and I’ll keep the discussion here on the design tradeoffs.
I would obviously rework this as "small piecemeal cute reviewable PRs", not shove it like this for review. This is a POC and a conversation opener/resumer.
I support any decision the maintainers make. I am a guest in someone else's house.
Happy to reshape the prototype to match whatever direction they pick (in-tree hook vs out-of-tree plugin, protocol, key type, etc.).
The existing stock-SOPS + external backend examples are good to have documented either way.
rkthtrifork commentedon Nov 25, 2026
I have created a PoC for a plugin design in this PR #2358