-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Runtime secret release via split attester/kbs-client #1237
Conversation
cc @iaguis (i'm not able to add you as a reviewer, maybe you need to part of the coco github org?) |
How are you measuring the skr-api sidecar? |
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Intuitively I would say: it's measured as part of the application workload (subject to policy, etc). In this deployment model the kbs-client (skr-api) is logically (and practically) part of the application in the TEE, provided for convenience. A user could just include |
ff3a63e
to
d1e79cd
Compare
Iterated on the original proposal a bit. Instead of mounting a UDS we can create an abstract socket in the pod namespace and have socat proxy it. |
Initially, the skr-api build failed with the following error: $ PODVM_DISTRO=ubuntu make image && cd -
...
...
Compiling serde_urlencoded v0.7.1
Compiling axum-core v0.3.4
error: failed to run custom build command for `tdx-attest-sys v0.1.0 (https://github.com/intel/SGXDataCenterAttestationPrimitives?tag=DCAP_
1.16#71557c7d)`
Caused by:
process didn't exit successfully: `/home/surajaz/code/work/cloud-api-adaptor/skr-api/target/release/build/tdx-attest-sys-cb7f5d9821985a53
/build-script-build` (exit status: 101)
--- stdout
cargo:rustc-link-lib=tdx_attest
cargo:rerun-if-changed=bindings.h
--- stderr
bindings.h:32:10: fatal error: 'tdx_attest.h' file not found
bindings.h:32:10: fatal error: 'tdx_attest.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /home/surajaz/.cargo/git/checkouts/sgxdatacenterattestationprimitives-d6934a
418e6beae0/71557c7/QuoteGeneration/quote_wrapper/tdx-attest-sys/build.rs:79:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
make[1]: *** [Makefile:3: build] Error 101
make[1]: Leaving directory '/home/surajaz/code/work/cloud-api-adaptor/skr-api'
make: *** [../../podvm/Makefile.inc:113: /home/surajaz/code/work/cloud-api-adaptor/podvm/files/usr/local/bin/attester] Error 2 So installed the following package: sudo apt install -y libtdx-attest-dev Problems with kata if anybody else is trying, I had the latest CCv0 from kata repo at commit: 61cbae6c39f62be1be5e5a05e11dff06d6e68630 and it seems broken so had to modify code to get it working. diff --git src/agent/src/signal.rs src/agent/src/signal.rs
index d67000b80..401ded953 100644
--- src/agent/src/signal.rs
+++ src/agent/src/signal.rs
@@ -57,7 +57,7 @@ async fn handle_sigchild(logger: Logger, sandbox: Arc<Mutex<Sandbox>>) -> Result
continue;
}
- let mut p = process.unwrap();
+ let p = process.unwrap();
let ret: i32 = match wait_status {
WaitStatus::Exited(_, c) => c,
diff --git src/libs/kata-types/src/annotations/mod.rs src/libs/kata-types/src/annotations/mod.rs
index f094ddd70..89da372de 100644
--- src/libs/kata-types/src/annotations/mod.rs
+++ src/libs/kata-types/src/annotations/mod.rs
@@ -474,8 +474,8 @@ impl Annotation {
let u32_err = io::Error::new(io::ErrorKind::InvalidData, "parse u32 error".to_string());
let u64_err = io::Error::new(io::ErrorKind::InvalidData, "parse u64 error".to_string());
let i32_err = io::Error::new(io::ErrorKind::InvalidData, "parse i32 error".to_string());
- let mut hv = config.hypervisor.get_mut(hypervisor_name).unwrap();
- let mut ag = config.agent.get_mut(agent_name).unwrap();
+ let hv = config.hypervisor.get_mut(hypervisor_name).unwrap();
+ let ag = config.agent.get_mut(agent_name).unwrap();
for (key, value) in &self.annotations {
if hv.security_info.is_annotation_enabled(key) {
match key.as_str() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to successfully do the SKR. This is a great work @mkulke Now it is matter of figuring out where does all the pieces fit.
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
This partially reverts commit 32ffc71. Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Co-authored-by: Suraj Deshmukh <surajd.service@gmail.com> Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
The pending changes in the foundation of coco/guest-components have been merged, so we don't require forks any more. I also added a CommunityGallery Image, built some container images and added a section w/ steps to follow for testing this in the description above. |
@mkulke is this ready for review ? |
updated the prebuilt image in the instructions to
|
The above scenario (key retrieval at runtime and being able to retrieve them from a k8s deployed KBS) should now be covered by the Confidential Data Hub Architecture that has been merged to kata CCv0 and guest-components. It roughly follows the following sketch: There is a key difference to the proposed skr-api architecture: The cc_kbc model mandates that unprivileged pod workloads should not be able to retrieve TEE evidence (in fact they still are able to do via api-server-rest's Since KBS supports passport mode now, a pod can now request a token from Alternatively a pod can request a secret resource directly via the api-server-rest's Once the remaining issues have been addresses we can close this PR: |
Ok, the remaining patches have been merged, we should be good now. To use runtime key retrieval w/ cc_kbc, you need to:
Get passport token$ k exec -it deploy/busybox-caa -- wget -qO- http://127.0.0.1:8006/aa/token\?token_type\=kbs | jq .
{
"token": "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJldmFsdWF0aW9uLXJlcG9ydCI6IntcImFsbG93XCI6dHJ1ZX0iLCJleHAiOjE2OTY1MDA2OTcsImlzcyI6IkNvQ28tQXR0ZXN0YXRpb24tU2VydmljZSIsImp3ayI6eyJhbGciOiJSUzM4NCIsImUiOiJBUUFCIiwia3R5IjoiUlNBIiwibiI6InNrak1vNXA2WDdnWVFGcUZTZWc1cTRaMVZLaDl0VTBGeUJxNWRsU2tOVFNBR3g2RkRWaTlpZjRMdmpRdHVGSTJ2VjNCT2Etdnc5emNkblFpdk9JbVRQaXY3dEdhdVdfcFlxX3k2U2VRb3VGbW5YS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72WlwuDq\n0I8fAUs59VPjmp3pgcZ3WQKBgE2lzsA0iMorKyPaQlhA1F1PVGxx047sI+i9MBL6\n9wDmAuHGfn73fem6cYWzlbYWo0cXTaMCSwAX0WqlhnGv5PfMwkGx10q4zqarmbTE\nIlkHeCoBrZ1QF6rp516OKigripdR4zyoGx4MZmMonftpexhmBDSHeHalKPMLODIe\nj9SJAoGBAM5/6/xX/suVpTLu5UCIIRJqQthtSHhWaAD40AXDorRUD8bD756t4vHk\nUlx6rBWMM/ZR8fU14kXYGM0c6Khar12rJK3EcAYMSe1/m3JpjmdHhunjAEvr/Kmx\nu/hbNlbYraHR3OciwAuqGBVCd1YNlrl99gJjkVIRSTkshk0RQfB5\n-----END RSA PRIVATE KEY-----\n"
} Get secret resourcek exec -it deploy/busybox-caa -- wget -qO- http://127.0.0.1:8006/cdh/resource/default/key/one
ohai |
Secret release at Runtime
This is a PoC implementation of a design for secure key release (SKR) during runtime. It's mainly to gather further feedback and refine further. The current state attempts to address the requirements we identified in discussions and the learnings we made from the shortcomings of earlier iterations:
podns
network namespace and workload should not have flat access to the podvm's resources like IMDS, since a podvm aims to be an opaque implementation detail of the runtime class.Description
AA is split in 2 processes
attester
andskr-api
are two aspects that are both served by Attestation Agent (AA) at the moment. AA retrieves evidence from the podvm's infrastructure and facilitates the key release using the RCAR protocol with KBS deployment.To serve the above concerns, we are able to split those aspects into an "attester" part, retrieving evidence from the TEE platform and a "kbs-client" part that is able to perform the SKR exchange with a KBS and the "attester". The kbs-client process doesn't need access to infrastructure resources and can be deployed as a simple sidecar. The attester is deployed as a system daemon on the podvm in the host network ns.
The
skr-api
process is an implementation of such a "kbs-client". It exposes an http endpoint (localhost:50080/getresource/x/y/z
). It leverages aKbsProtocolWrapper
ofGuestComponents/kbs_protocol
to handle the interactions with a KBS and retrieves the TEE evidence from theattester
process via Unix Domain Socket RPC.UDS
mount injectionnamespace bridgingIn a K8S, mounting a resource into a pod implies mounting resources from the K8S node.
We need to mount resources (a socket from theattester
process) from the podvm into containers, however. I'm not sure whether we are able to express this intent in k8s somehow.We cannot rely on a direct mount to work, but we are able to proxy the UDS to an [abstract socket] (https://man7.org/linux/man-pages/man7/unix.7.html) that is available in the
podns
namespace.The
skr-api
container is able to access the namespaced abstract socket, we could do similar things with a tcp network port, but blocking a network port this is probably the less intrusive option.So, pragmatically, a mount to/run/confidential-containers/attester.sock
is injected in every container, similar to how we inject thepodns
network namespace. That seems crude, but maybe it can be considered as a documented property of akata-remote
runtime class to have that mount in every container?Testing it
The branch is based on the 0.7 release of Cloud Api Adaptor. The changes only affect the podvm. The podvm image can be built using the usual way. A local build will require tdx attestation headers (
libtdx-attest-dev
on debian or similar packages elsewhere), since the attester module bundles all TEE platforms at the moment.The
skr-api
container image can be built via docker in./skr-api
. The container can be added to a pod without requiring any special privileges.It will expose an endpoint:
http://localhost:50080/$name/$type/$tag
to the sibling containers in the pod.Azure pre-built images
There are pre-built artifacts available that can be used in an existing CAA deployment (tested with v0.7):
Podvm
/CommunityGalleries/cococommunity-42d8482d-92cd-415b-b332-7648bd978eff/Images/peerpod-podvm_skr-api-draft/versions/0.7.5
You can configure an existing deployment by editing the peer pod configmap (
AZURE_IMAGE_ID: ...
) and restarting the daemonsets. note: all existing peerpods should be removed prior to this, to make sure infra resources will be cleaned up properly.kbs
A sample kbs image, that has a secret
/one/two/key
provisioned.skr-api
A kbs client container image:
ghcr.io/mkulke/skr-api:d11a655
Test
We assume kbs is available in the k8s cluster via
http://kbs:8080
and deploy a pod with an skr-api sidecar using a CAA runtime class:We wait until the
nginx-caa
peerpod is provisioned correctly:We request a secret via skr-api:
We can check the logs for kbs and skr-api to comprehend the attestation flow: