Repository navigation
Description
The Workload API the way it is designed (and also implemented today) does not support service mesh deployments with node-level proxies such as Istio Ambient Mesh. The proxies in these deployments act on behalf of multiple workloads and would be the peers that connect to the SPIFFE Workload Endpoint. The way SPIFFE works today a proxy would only receive SVIDs representing itself but not for the workloads it acts on behalf of.
More generally, SPIFFE does not support the deployment of brokers that act on behalf of multiple workloads and sit in between the workload and the Workload API. Istio Ambient mode is one of these, but other scenarios exist too. (Kubernetes-based SPIFFE-helper, Egress API Gateways adding JWT-SVIDs to requests, etc.)
Existing work
The Delegated Identity API of SPIRE (only SPIRE, not SPIFFE) is a dedicated API that solves this. It looks similar to the Workload API but requires certain request parameters (PID or SPIRE selectors). It is also “multi-tenanted”, returning SVIDs for all workloads (the SPIRE agent is authorized for) on a single connection.
Proposed solution
sequenceDiagram
participant Workload
participant Broker as Broker (e.g. Proxy)
Workload-->>Broker: Connect
alt for each workload
Broker-->>SPIFFE Workload Endpoint:Connect
Broker->>SPIFFE Workload Endpoint:Attest via API
SPIFFE Workload Endpoint->>SPIFFE Workload Endpoint: Serve Workload API
Broker->>SPIFFE Workload Endpoint:Use Workload API
SPIFFE Workload Endpoint-->>Broker:SVID
Broker-->>Broker:Use SVID (upgrade connection, etc.)
end
Add wording to the SPIFFE standard to allow attestation on API-level. In broker deployments, attestation of workloads would be based on data the broker sends once connected, rather than kernel introspection. The SPIFFE implementation validates the provided data and, if successful, starts serving the Workload API on the existing connection. The Workload API remains in the context of a single workload and follows the SPIFFE standard. The broker would open dedicated connection and attest for each workload it represents.
For the service-mesh scenario above, where a proxy representing multiple workload on the same node (like Istio Ambient mode) and identifies them using PID, the attestation part could be as simple as
// ProcessIDAttestationAPI allows you to create an attestation connection. Once successful you can use the Workload API in context of the provided PID on the connection.
service ProcessIDAttestationAPI {
// AttestProcessID attests the channel by an ID of a process running on the same unix-based OS.
rpc AttestProcessID(AttestProcessIDRequest) returns (AttestationResult);
}
message AttestProcessIDRequest {
// pid is the ID of the process to attest.
int32 pid = 1;
}
message AttestationResult {
// spiffe_id represents all SPIFFE IDs the requested attestation context is authenticated for. It can be used as a hint in the Workload API.
repeated string spiffe_id = 1;
// expires_at is the time the attestation expires and re-attestation is required.
google.protobuf.Timestamp expires_at = 2;
}For consistency and interoperability reasons I advocate to store this API (proto) in the SPIFFE repository and allow implementations to optionally implement it.
I think this approach:
- Keeps attestation and Workload API separate concerns like it is today
- Clients continue to use the well-known Workload API and its streaming capabilities.
- Allows flexibility in the way the workload and the broker is identified/attested/authenticated. I'm thinking SPIRE plugins adding custom API-level attestation.
Alternative solutions
Another solution is to bring the Delegated Identity API of SPIRE (or something similar) into SPIFFE. It targets above use cases and compared to the solution above is “multi-tenanted”. This comes with some optimization, particularly on bundle sync. Custom attestation cannot be easily added (maybe a good thing?).
Discussion
- Do you know more use cases exist or are you aware of other solutions/existing work?
- Should SPIFFE cover these deployments or should it remain an implementation detail like it is today?
Activity
evan2645 commentedon Jan 9, 2025
Thank you for opening this @arndt-s 🙏
I feel strongly that this API or one like it needs to be codified by SPIFFE. It has been great to see SPIRE take some steps in this direction and blaze a trail, because we have learned a lot from that. Now is the appropriate time to fix some mistakes there and codify the interface in SPIFFE for true interop.
I have never thought about SPIFFE Helper fitting this pattern , but since you've mentioned it I think that is correct. CSI driver with file based delivery as well, as you mentioned in SIG-Spec call today. We're starting to build a nice list of concrete use cases we can use to validate the shape of the "attestation api" bit (istio ambient, cilium, spiffe-helper, csi-driver-spiffe).
From a high level, I like this two step separation that decouples the "attestation" piece from the actual serving of SVIDs. It will certainly simplify the maintenance of workload api over time. It will be interesting to explore other ways to achieve this decoupling and look at some pros/cons.
In terms of scoping, the projects/use cases I listed above all share a common attribute, which is that there is a node local component operating on behalf of workloads on the same node. In this case, it's desirable to reference the neighboring workload somehow such that the SPIFFE implementation can know the true workload identity and perform more accurate attestation etc. This is different than other use cases (which also need solutions) like egress gateways etc, where you have a ~remote caller that has some kind of pre-existing credential. Pursuant to my above comment about alternate mechanisms to decouple the "attestation" from the serving of SVIDs, perhaps there is a way to have a local flavor and a remote flavor, both ending up with workload api. My feeling is that we should keep this in mind but that the remote flavor should be left for another chunk of work once the local flavor is more or less figured out.
Lastly, as discussed on SIG-Spec call today, we need to address access control. Who is allowed to call this attest api?
kfox1111 commentedon Jan 9, 2025
There are actually two ways of using the spire specific delegation api currently. one where the software contacting the api does the attestation itself, and a second method where it still has the agent do so. I think its important to ensure both can be supported with the proposed api.
That may influence the permission bits around what can use which bits of the api?
evan2645 commentedon Jan 9, 2025
The one where the caller is doing attestation and providing selectors came first in SPIRE. The one where SPIRE Agent does the attestation came afterwards, and a key driver was exactly that - allowing SPIRE to continue doing the attestation. Otherwise, you get into a spot where you end up rebuilding portions of the attestation framework in the caller (because you need to synthesize the same selectors that were registered). You also lose the ability to leverage SPIRE plugin composability. To me, it makes a lot of sense to let SPIRE (or any other SPIFFE implementation) do what it's good at, including attestation.
At the same time, I can understand the need for something where this is offloaded from the agent, usually because it is not possible to leverage the PID-centric interface? The cases I've found thus far are typically cases in which either 1) the workload hasn't started yet, or 2) the workload is on a different node. I'm curious to hear more about the use cases you see for the "offloading attestation" functionality @kfox1111 .. do you see some beyond these?
kfox1111 commentedon Jan 9, 2025
I'm using the spire based workload attestation delegation for spire-ha-agent.
I think istio non ambient is doing its own attestation. Thats the main user of it I know of. If the istio non ambient support could work with the spire attested api, then we could do with just the one option I think?
arndt-s commentedon Jan 10, 2025
Thank you all for the input @evan2645 & @kfox1111.
I agree that it'll be crucial to allow implementors to include their concepts of attestation into the flow. However, I am not sure if the selectors flavor should become a part of SPIFFE as selectors are a SPIRE only concept. What do you think?
Yes, the "SPIFFE-batteries included" part of Istio does its own attestation. The istio agent (part of the sidecar) serves the SPIFFE Workload Endpoint and Envoy uses it in combination with SDS. But I believe that in the situation the Istio-agent detects an existing SPIFFE socket during startup (aka "SPIRE is deployed") it doesn't serve its own and Envoy uses the existing one. Here the attestation is performed by SPIRE (or any other SPIFFE-implementation) in the same way as if the workload would directly use it.
Good points. I'll be working on this.
kfox1111 commentedon Jan 10, 2025
We could look around and try and find out how many folks are using the selector based api, and if they could use the pid based one instead. Maybe there are fewer users of it then I think, and we could add the pid one first and add the selector one later, if needed, so long as we leave room in the api for it should we need it?
Oh, right, cause its a sidecar. Makes sense.
idimaster commentedon Jan 28, 2025
One of use case that looks connected is ability to call non K8s server-less (AWS, etc.) workload from K8s environment and vice versa. Overall Istio Ambient Mesh enables such option with identity aware proxy. Open question is SPIFFE will facilitate propagation of identity to proxy(broker) layer or will accept external identities?
PieterKas commentedon Jan 28, 2025
@idimaster can you elaborate a bit more on what you mean by "accept external identities"?
bleggett commentedon Jan 29, 2025
Istio non-ambient SPIRE integration still 100% relies on SPIRE attestations for workload cert grant, but we impose constraints on the SPIFFE ID used for not-very-good back compat reasons (it may only contain
trust-domain/ns/service-acct-namebecause without SPIRE, that is allistioditself is aware of/can attest, given the K8S-centric nature of it) - though work is being done to dig us out of that hole.The value of SPIRE for us, as @evan2645 mentioned, is in offloading attestations to something that supports a wide variety of attestations under a plugin framework, which we do not then have to implement ourselves.
istiodis a good "default" or "out of the box" attestor that can validate at the service account level, but we definitely have users that need more than that.We do not want to be in the business of writing our own bespoke attestation logic, except to the degree we have to
for a baseline "batteries included" experience, assuming a K8S environment.
We would love for a proper attestation delegation API to end up in the SPIFFE spec/API, as long as it doesn't implicity force the delegate to implement all attestations from scratch and be a SPOF for workload attestation. Whether that's the DelegateAPI via PID, or something like that - don't much care.
The "who attests" issue and why using the DelegateAPI via selectors is fundamentally a problem
I think a SPIFFE API that remains agnostic to whether the delegate does additional attestations or not would be ideal - any caller holding a PID for instance is privileged enough to do any local attestations they want before asking SPIRE to do so, without informing SPIRE they have done so, or SPIRE needing to assume that they have.
It's unavoidably true that SPIRE (and SPIFFE) cannot verify anything about those local attestations: their scope, validity, or how strong they are, and so effectively must ignore them -
Whereof one cannot speak, thereof one must be silent& etc.That's why the current selector-based DelegateAPI isn't really sufficient from a security perspective, and never can be, it offloads all attestation to the caller, and thus the caller is a SPOF for attestations -
spire-agentverifies nothing about the workload in that model.Suggested requirements
From my perspective, the minimal requirements are
spire-agentto attest $SOME_ARBITRARY_WORKLOAD it has out-of-band access to.spire-agentalready and has opened a securable channel to thespire-agent, to get the SVID of that arbitrary workload, ifspire-agentwas able to attest it, otherwise allow me to retry the attestation trigger for that workload until I give up, or it succeeds.The
DelegateAPIwith PID support fulfills the above as-is, but there are some other "nice to haves" it cannot currently solve for that it might be worth mentioning (but also might be scope creep, IDK - to be clear these are not things Istio will ever care about, but might be things SPIFFE/SPIRE need to think about in a general design)Specifically, container-level attestations:
I'm not 100% sure on this, but I think some of the SPIRE attestation plugins (k8s cosign, others I think, basically anything you can turn off with disable_container_selectors assume that the PID calling the WorkloadAPI is the container that should be attested - they don't really play nice with the DelegateAPI AFAIK (I might be wrong on this and would be happy to be proven wrong - but even if I am not wrong at most this is probably tweaking the container attestations a bit).
This may not be easily solvable in all contexts with a delegation API, in which case a decent compromise is probably a single API/protocol that can accept different types of workload identifiers (k8s pod OR k8s pod/container OR raw PID) and attest what it can, given the granularity of the identifier provided - and if the style of workload identifier provided can't support certain "levels" of attestation, maybe
spire-agentjust refuses to attest in that scenario. This is spitballing tho.arndt-s commentedon Feb 5, 2025
Sorry for not getting back here earlier. I spent some time trying to implement above idea but unfortunately, gRPC does not allow channel authentication using gRPC RPCs itself. The channel authentication happens before the HTTP2 Settings Frame. Calling an RPC would require HTTP2 to be established though and thus it's a kind of a chicken & egg problem.
However, I didn't want to get back to you empty handed:
Another idea that is floating around is the notion of file descriptor passing. Proxy-less sidecars have some handle for the workload, it can be a local peer address or a connection on a unix domain socket. So instead of the proxy to extract PID and other metadata from it a mechanism exists to transfer file descriptors to other processes. For instance: Sidecar-less proxy uses iptables to intercept & redirect traffic to a local proxy, on the proxy this incoming traffic comes along with a file descriptor (fd), fd is forwarded to SPIFFE which can then introspect it and derive "on-behalf-of" information from it. This is quite neat as SPIFFE implementation would get references for both processes (proxy & actual workload).
This solution offers some nice benefits:
There's still aspects that needs to be looked into:
kfox1111 commentedon Feb 5, 2025
Very interesting. :)
How far have you tested the idea? Think it will work for workload -> proxy validation via UDS, but I didn't think the kernel had a way to do it via TCP. Do you know of one?
keithmattix commentedon Feb 5, 2025
Agreed - the file descriptor passing will need to be done via UDS control message in an out-of-band fashion. Don't think it can happen for TCP
arndt-s commentedon Feb 5, 2025
I was stuck with that at first but it is possible to pass a file descriptor for a tcp connection too. When trying SO_PEERCRED on it it returns PID 0, which I use as an indicator to get the peername of it and check /proc/net/tcp. If there's a matching entry I can derive the process information from it.
The other option I tried is using
SCM_RIGHTS(passing pid, uid & gid reference directly) but it requires CAP_SYS_ADMIN ...@kfox1111 I have a working spire branch (only fetch jwt-svid, didn't touch tests, etc.) but it proofs that it indeed can work. Tested local & kubernetes, uds & tcp. See spire fork. Relevant code is in peertracker
kfox1111 commentedon Feb 5, 2025
Fascinating. I heard that only worked with unix sockets.... I wonder if it works with vsockets too.
There are plans to pull out peertracker code to here: https://github.com/spiffe/go-peertracker. Maybe an ideal time to do that and then start to add this, and vsock support to it too.
arndt-s commentedon Feb 7, 2025
Thank you for that link @kfox1111. While I look at it (won't have the time for it next week) do we think this can be a valid approach to solve sidecar-less proxy deployments?
I want to highlight that this approach only works on the same node and requires the workload to interact with the broker first (e.g. a tcp a uds connection). Without it there's no file descriptor to transfer to SPIFFE. This is the case at spiffe-helper for instance. Also, on-behalf-of across nodes is not possible (in Kubernetes this means both need to be daemon sets).
1 remaining item
kfox1111 commentedon Feb 10, 2025
Was chatting a bit about this socket fd passing idea...
This will end up with:
Workload A -> proxy 1 -> proxy 2 -> Workload B
I can see how proxy 1 could work to get a cert for workload A. But what about proxy 2 getting a cert for Workload B?
Is the dest part of the socket fd preserved too? Would proxy 2 know its getting a cert for workload B, not workload A?
bleggett commentedon Feb 10, 2025
@arndt-s
arndt-s commentedon Feb 11, 2025
@kfox1111 that's a very good question. So far I don't have an answer to that. Maybe someone in this chat has?
@bleggett if I understand your question correctly with the file descriptor of a network socket it's the process that initiated the connection in the first place (outgoing request). Theoretically, any file descriptor we can leverage to get process information of it will do. So far UDS works and I have a solution for tcp. Does Istio have file descriptors from the workload (incoming & outgoing requests) and if yes, what kind?
Regarding the clean up - I agree, I noticed that if SPIRE holds the fd, the original request is not getting (server) terminated, even if the proxy closes its fd. What I've added to prevent this behaviour is that SPIRE closes the passed fd once the connection between the broker and SPIRE closes. Not sure if that's enough though.
kfox1111 commentedon Feb 11, 2025
@arndt-s For the FD passing idea to work, I think we'd need a solution for the proxy 2 -> Workload B case too. otherwise, that would need the PID based api for proxy 2 and then maybe we simplify things by having proxy 1 also just do PID passing.
Is there an easy way that you could test out the dest tracking side of things with your prototype to see if it can track that side too?
bleggett commentedon Feb 11, 2025
Yeah - that's what I assumed, just checking.
How would a delegate (process B) be able to get the file descriptor of an outgoing socket created by a client app (process A)? This isn't trivial to do if you're just a proxy accepting these connections.
How expensive is that to do on every client connection? This has pretty big hotpath implications for connection handling.
In istio's case, we have a node proxy (separate process) that creates listening sockets. How can you derive a FD for a sending socket from a listening socket created by a different process? I don't think you can (it may be possible with netlink, but it would be an expensive check on the proxy connection handling hotpath).
Right - but the difficult part is the granularity and scope.
Yeah - this + the above (it's very hard/expensive/maybe impossible to get FDs of sending sockets unless you are the process creating those sending sockets) means relying on socket FDs explicitly isn't feasible IMO. It's extremely hard/impossible to get them unless the delegate and the process it's acting as a delegate for are one-and-the-same (which defeats the purpose of delegation) and even if you ignore that, it's pretty risky in terms of the potential failure domain.
joonas commentedon Feb 11, 2025
I'd like to share another use case from the wasmCloud project:
We have a Host process (think Kubelet, but for running WebAssembly/wasm) that embeds a WebAssembly runtime (wasmtime) for running WebAssembly components. In addition to running the components, the Host also provides a set of interfaces that the components can invoke for accessing things outside of the WebAssembly sandbox, things like:
One of the features we'd like to provide from the Host to the Components it's running is the ability to request a workload identity (in the form of an SVID), and the way we are planning to implement this was through having the Host use the Delegated Identity API on behalf of the components it's running.
What's slightly different in this use case is that the running wasm workloads are run as green threads in the wasm runtime embedded in the host, so from outside of the host process there is no other process to interact with, which ultimately means that the wasmCloud Host will be responsible for providing the workload appropriate selectors.
kfox1111 commentedon Feb 25, 2025
At this point, should we just go with the pid api, as we know that works, and explore the option of a fd based api in a separate issue?
arndt-s commentedon Feb 25, 2025
Based on @bleggett's comment I believe file descriptor passing only makes sense when the file descriptors are longer living and not short-lived like for TCP connections. It is possible but would potentially be an expensive operation and in the hot path.
Maybe it's now time to take a step back from file descriptor passing and look at the wider solution space. I am seeing interest from various directions to add support for this to SPIFFE so I think we should do this in general. Based on earlier comments and discussions in SIG-SPEC the problem can be broken down to how the workload is referenced and how that reference is passed into SPIFFE.
Naturally this leaves us with 2 main options, either we use the Workload API today and allow for reference passing or we design a dedicated API for this (similar to what SPIRE with Delegated Identity API has done). What do people here think is the right approach? Let's decide on this first and take it from there.
kfox1111 commentedon Feb 25, 2025
I'm not sure if this is what your asking, but having the api on its own socket has some advantages.
idimaster commentedon Feb 27, 2025
@PieterKas Overall support of sidecar-less service mesh deployment brings complex security question about workload identity propagation across heterogeneous environments. My question was mostly about what is current most preferable approach? Like:
a) credentials exchange so workload can pass attestation with proxy
b) identity federation "left" - workload identity SVID accepted by external workload and used for attestation
c) identity federation "right" - external workload identity (AWS, GCP, etc) translated into SVID and accepted by internal workload.
in my original question "accept external identity" was referred to option c) - ability to recognize and trust non SPIFFE identifiers.
arndt-s commentedon Mar 5, 2025
How do others feel here? @evan2645 @bleggett @PieterKas @joonas @idimaster ?
arndt-s commentedon Mar 12, 2025
As an action item coming out of the last SPIFFE sig-spec call here is a document with a proposal that leans more towards Delegated Identity API of SPIRE. Please take a look & leave comments: https://docs.google.com/document/d/16E3B66ECE18OiY-4jilL-kqGOVITrmOSeq3yJIE-OTE/edit?tab=t.0
kfox1111 commentedon Mar 13, 2025
I like it. Thanks! :)
shanmugara commentedon May 6, 2025
Are there any references on how to configure the SPIRE Delegated Identity API to work with Ambient mode? Thank you!