Remote Resources
Remote resources allow Cocos to securely download and execute algorithms and datasets packaged as OCI (Open Container Initiative) images directly from container registries. This mechanism integrates with the Confidential Containers (CoCo) ecosystem to ensure that resources remain encrypted until they are safely inside a Trusted Execution Environment (TEE).
Architecture Overview
The remote resource handling in Cocos leverages several standard components:
- Skopeo: Used to download and manage OCI images.
- ocicrypt: Provides the encryption/decryption layer for OCI images.
- CoCo Key Provider: A gRPC service that acts as a bridge between
ocicryptand the Attestation Agent. - Attestation Agent: Generates TEE evidence (attestation) required to fetch decryption keys.
- Key Broker Service (KBS): Stores decryption keys and only releases them upon successful verification of TEE evidence.
Workflow
The following diagram illustrates the lifecycle of a remote resource computation, including per-resource KBS resolution and secure execution.
- Encryption: Algorithms and datasets are packaged as OCI images and encrypted using
skopeoandocicrypt. The encryption keys are stored in a KBS. - Manifest: A computation manifest is sent to the Cocos Agent, specifying the URIs of the encrypted OCI images and their corresponding KBS resource paths/URLs.
- Download: The Agent invokes
skopeoto download the encrypted layers. - Decryption:
skopeo(viaocicrypt) requests the decryption key from thecoco-keyprovider, which fetches it from the specified KBS. - Attestation: The
coco-keyproviderworks with theattestation-agentto provide evidence to the KBS for key release. - Execution: Once decrypted, the algorithm and datasets are extracted and executed within the secure enclave.
Computation Manifest Format
To use remote resources, the computation manifest must specify the source type as oci-image and include the encryption details.
{
"computation_id": "example-computation",
"algorithm": {
"type": "oci-image",
"uri": "docker://registry.example.com/encrypted-algo:latest",
"encrypted": true,
"kbs_resource_path": "default/key/algo-key"
},
"datasets": [
{
"type": "oci-image",
"uri": "docker://registry.example.com/encrypted-dataset:latest",
"encrypted": true,
"kbs_resource_path": "default/key/dataset-key"
}
],
"kbs_url": "http://kbs.example.com:8080"
}Creating Encrypted Resources
1. Package and Encrypt an Algorithm
First, build your algorithm as a Docker image and push it to a registry. Then, use skopeo with a CoCo-compatible key provider to encrypt it.
# Encrypt an OCI image
skopeo copy \
--encryption-key "provider:attestation-agent:keypath=/path/to/local.key::keyid=kbs:///default/key/algo-key::algorithm=A256GCM" \
docker://registry.example.com/plain-algo:latest \
docker://registry.example.com/encrypted-algo:latest2. Store the Key in KBS
Ensure the decryption key used during encryption is stored in your KBS at the specified path (default/key/algo-key).
Running a Computation
When starting a computation through a CVMS (Computation Management Server), you must provide the remote resource URIs and KBS configuration.
Using cvms-test
If you are using the cvms-test server for testing, you can specify remote resources using the following flags:
./build/cvms-test \
-kbs-url http://<KBS_IP>:8080 \
-algo-type python \
-algo-source-url docker://<REGISTRY_IP>:5000/encrypted-algo:v1.0 \
-algo-kbs-path default/key/algo-key \
-dataset-source-urls docker://<REGISTRY_IP>:5000/encrypted-dataset:v1.0 \
-dataset-kbs-paths default/key/dataset-keyBenefits of Remote Resources
- Standards-Based: Leverages OCI and CoCo standards for container security.
- Enhanced Security: Resources are never decrypted outside of the TEE.
- Scalability: Works seamlessly with any OCI-compliant registry (GitHub Container Registry, Docker Hub, private registries).
- Interoperability: Compatible with the broader Confidential Containers ecosystem.