Skip to content

Conversation

@tylerfanelli
Copy link
Contributor

@tylerfanelli tylerfanelli commented Sep 30, 2025

This PR updates the attestation kernel module and proxy with two main modifications:

  • Updating the kernel module and proxy to use AES-GCM as the standard encryption mechanism protecting secrets received into the SVSM kernel once successfully attested.
  • Updating the proxy to use standard KBS 0.4.0 as used by the Trustee server.

The kbs-test server was also updated to emulate KBS 0.4.0 and thus can be used to test this series.

cc/ @stefano-garzarella @nicstange @berrange

Try for yourself

Start kbs-test

$ git clone https://github.com/tylerfanelli/kbs-test.git && cd kbs-test
$ git checkout main
$ cargo build
$ export SVSM=/path/to/svsm
$ MEASUREMENT="$(${SVSM}/bin/igvmmeasure --check-kvm ${SVSM}/bin/coconut-qemu.igvm measure -b)"
$ cargo run -- -m $MEASUREMENT

Start the attestation proxy

$ git clone https://github.com/tylerfanelli/svsm.git && cd svsm
$ git checkout attest-update
$ make aproxy
$ bin/aproxy --protocol kbs --url http://0.0.0.0:8080 --unix /tmp/svsm-proxy.sock --force

Run SVSM with attestation

$ FW_FILE=/path/to/OVMF.fd make FEATURES=attest 
$ ./scripts/launch_guest.sh --qemu /path/to/qemu-system-x86_64 --image /path/to/qcow2-file.qcow2 --aproxy /tmp/svsm-proxy.sock

@stefano-garzarella
Copy link
Member

This PR updates the attestation kernel module and proxy with two main modifications:

* Updating the kernel module and proxy to use AES-GCM as the standard encryption mechanism protecting secrets received into the SVSM kernel once successfully attested.

* Updating the proxy to use standard KBS 0.4.0 as used by the Trustee server.

@tylerfanelli I took a quick look, and I also see some changes to the protocol used between SVSM and the proxy.
Can you explain better why they are necessary?
Are they generic enough to support any attestation protocol, or Trustee-specific?

We haven't made any stable releases yet, so it's fine, but we need to deal with this in the future.
(e.g. increasing the version in NegotiationRequest)

I think now is the time to add documentation/specifications for the protocol and finalize a version (if this is the final version).

@nicstange
Copy link
Collaborator

I think now is the time to add documentation/specifications for the protocol and finalize a version (if this is the final version).

As a disclaimer, I haven't looked into the details of this PR yet, but just to avoid unnecessary work I'm writing it now: one thing which we very likely need from the protocol and which wasn't implemented the time I last checked is some sort of authentication for the received key material. Otherwise an adversary would be able to impersonate the KBS and make the SVSM to protect its persisted state with a secret he controls. Using authenticated encryption for the key material is definitely a step in that direction, but not sufficient. I think a full solution would be outside the scope of this PR though, and would personally leave the protocol finalization for some later PR.

@tylerfanelli
Copy link
Contributor Author

tylerfanelli commented Sep 30, 2025

As a disclaimer, I haven't looked into the details of this PR yet, but just to avoid unnecessary work I'm writing it now: one thing which we very likely need from the protocol and which wasn't implemented the time I last checked is some sort of authentication for the received key material. Otherwise an adversary would be able to impersonate the KBS and make the SVSM to protect its persisted state with a secret he controls.

See the final commit (specifically this), which adds authentication to the received decryption key. This type of key is now required by SVSM.

Using authenticated encryption for the key material is definitely a step in that direction, but not sufficient. I think a full solution would be outside the scope of this PR though, and would personally leave the protocol finalization for some later PR.

With regards to this comment:

Otherwise an adversary would be able to impersonate the KBS and make the SVSM to protect its persisted state with a secret he controls.

The disk/filesystem should be encrypted before the VM is run, and should be done so on a trusted machine. That way, if there's any impersonation/tampering involved, it simply won't be able to unlock the disk without the correct key. Only the correct KBS would have access to the key.

A bad actor could impersonate the KBS and give the wrong key, but that is simply a DoS, not a breach of any data.

@tylerfanelli tylerfanelli changed the title attestation: Update kernel module and proxy for AES-GCM, other small changes attestation: Update kernel module and proxy for AES-KW, other small changes Oct 2, 2025
@tylerfanelli
Copy link
Contributor Author

tylerfanelli commented Oct 2, 2025

@tylerfanelli I took a quick look, and I also see some changes to the protocol used between SVSM and the proxy. Can you explain better why they are necessary?

The changes are as follows:

  • Represent each byte field as a Vec<u8> instead of base64-encoded Strings. This relieves the kernel module from needing to worry about base64 {de}serialization which should instead be up to the proxy backend.
  • Split the challenge nonce from the usual NegotiationParams. In KBS (and likely other protocols with nonce challenges), the respective nonce needs to be sent alongside the attestation evidence for validation. This allows the kernel module to identify and cache the nonce so it is able to send it alongside the evidence at a later point.
  • Standardize around ECDH-ES+A256KW for secret decryption. We previously agreed that the attestation module would only support EC keys, and this is an established algorithm for fetching secrets that includes authentication.
  • Add an option to write attestation artifacts (such as EAR tokens) back to SVSM upon successful attestation.

Are they generic enough to support any attestation protocol, or Trustee-specific?

They are generic.

I think now is the time to add documentation/specifications for the protocol and finalize a version (if this is the final version).

I think this is much closer to the final version, with only one change remaining. I can add some documentation to this PR.

@tylerfanelli tylerfanelli changed the title attestation: Update kernel module and proxy for AES-KW, other small changes attestation: Update kernel module and proxy for AES-GCM, other small changes Oct 2, 2025
@tylerfanelli tylerfanelli force-pushed the attest-update branch 5 times, most recently from 2cab639 to 083213a Compare October 4, 2025 05:32
@tylerfanelli tylerfanelli marked this pull request as draft October 4, 2025 05:51
@tylerfanelli tylerfanelli force-pushed the attest-update branch 3 times, most recently from fd806cd to bff36de Compare October 6, 2025 04:07
@tylerfanelli tylerfanelli marked this pull request as ready for review October 6, 2025 04:10
@tylerfanelli
Copy link
Contributor Author

@stefano-garzarella To test, you can use the branch found in coconut-svsm/kbs-test#6.

@tylerfanelli tylerfanelli force-pushed the attest-update branch 2 times, most recently from 6de1666 to 2a0c494 Compare October 6, 2025 23:15
@stefano-garzarella
Copy link
Member

@stefano-garzarella To test, you can use the branch found in coconut-svsm/kbs-test#6.

@tylerfanelli thanks! BTW, can you post a changelog when you update the PR? It will help reviewers to understand the difference between versions.

@luigix25
Copy link
Collaborator

luigix25 commented Oct 7, 2025

I tested this PR running:

make aproxy
bin/aproxy --protocol kbs --url http://0.0.0.0:8080 --unix /tmp/svsm-proxy-luigi.sock --force

for kbs

cargo build
export SVSM=/path/to/svsm
MEASUREMENT="$(${SVSM}/bin/igvmmeasure --check-kvm ${SVSM}/bin/coconut-qemu.igvm measure -b)"
cargo run -- -m $MEASUREMENT

and svsm:

FW_FILE=/path/to/OVMF.fd make FEATURES=attest 
./scripts/launch_guest.sh --qemu /home/lleonard/qemu/build/qemu-system-x86_64 --image /home/lleonard/repo/snp-svsm-vtpm/images/fedora-luks.qcow2 --aproxy /tmp/svsm-proxy-luigi.sock

Everything run smoothly. Please check this is the correct way of running it, if so what about adding it in the PR description?

Copy link
Collaborator

@luigix25 luigix25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aproxy/scr/main.rs:

/// Supported servers include:
/// kbs-test: https://github.com/tylerfanelli/kbs-test (for testing).
#[clap(long = "protocol")]
backend: backend::Protocol,

IIUC kbs-test has been replaced by kbs, also the repo url is now different.

@tylerfanelli tylerfanelli force-pushed the attest-update branch 3 times, most recently from 6cdefbd to 24c1593 Compare October 8, 2025 05:24
@tylerfanelli
Copy link
Contributor Author

aproxy/scr/main.rs:

/// Supported servers include:
/// kbs-test: https://github.com/tylerfanelli/kbs-test (for testing).
#[clap(long = "protocol")]
backend: backend::Protocol,

IIUC kbs-test has been replaced by kbs, also the repo url is now different.

Thanks. I've opted to just remove that comment altogether, as I feel an explanation of supported protocols/servers belongs in the documentation instead.

@tylerfanelli
Copy link
Contributor Author

tylerfanelli commented Oct 8, 2025

Everything run smoothly. Please check this is the correct way of running it, if so what about adding it in the PR description?

@luigix25 LGTM. I've added instructions to the PR description.

@stefano-garzarella stefano-garzarella added the in-review PR is under active review and not yet approved label Nov 12, 2025
@stefano-garzarella stefano-garzarella self-assigned this Nov 13, 2025
Copy link
Member

@stefano-garzarella stefano-garzarella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tylerfanelli great, LGTM, I just left a minor comment in the documentation that differs from the cover letter of this PR, indeed following it, I'm able to test this correctly.

@stefano-garzarella
Copy link
Member

@tylerfanelli not for this PR, but I think will be nice to add kbs-test here as submodule or put in the documentation the commit to use (or a tag/branch) to avoid issues like #869 and maybe to support #773

Also, can we merge coconut-svsm/kbs-test#6 ?

@stefano-garzarella stefano-garzarella added the wait-for-update PR is waiting to be updated to address review comments label Nov 20, 2025
@tylerfanelli
Copy link
Contributor Author

@tylerfanelli not for this PR, but I think will be nice to add kbs-test here as submodule or put in the documentation the commit to use (or a tag/branch) to avoid issues like #869 and maybe to support #773

Sure, I can add another PR to do so.

Also, can we merge coconut-svsm/kbs-test#6 ?

Yes, that can be merged alongside this PR.

@stefano-garzarella stefano-garzarella added ready-to-merge PR is ready for merging into main branch and removed wait-for-update PR is waiting to be updated to address review comments in-review PR is under active review and not yet approved labels Nov 21, 2025
Instead of decoding data from base64 in the SVSM kernel, move this
responsibility to the attestation backend. This offers more flexibility
for attestation {de}serialization.

Signed-off-by: Tyler Fanelli <[email protected]>
The challenge is present in each negotiation phase and may need to be
presented/used later on. Dedicate a struct member to specifically hold
the challenge.

Indicate a new NegotiationResponse param indicating to hash the
challenge within the attestation evidence.

Signed-off-by: Tyler Fanelli <[email protected]>
The attestation challenge used in the attestation evidence may need to
be verified with the attestation server. Include it in the attestation
request for inclusion in a server's appraisal of the evidence.

Signed-off-by: Tyler Fanelli <[email protected]>
Standardize around ECDH-ES+256KW for receiving secrets from an
attestation server. Modify libaproxy to support the fields needed for
AES-GCM decryption of secrets.

Also, since Trustee now uses ECDH-ES+256KW by default, update the kbs
aproxy module to match what is expected by Trustee. Thus, this module is
no longer a `kbs-test` module but explicitly follows the KBS protocol as
expected by Trustee.

Tested on a standard Trustee build with default resource backend.

Signed-off-by: Tyler Fanelli <[email protected]>
Based off the underlying TEE architecture, evidence will be retrieved
and submitted differently. Define a standard per-TEE architecture
evidence format that SVSM will follow to send evidence to the proxy.

Signed-off-by: Tyler Fanelli <[email protected]>
Attestation servers may return a token artifact containing the claims
they've attested for the client. This may of use later to an SVSM client
in order to verify attestation. Return this token to SVSM if it is
available.

Signed-off-by: Tyler Fanelli <[email protected]>
Instead of representing the attestation API as a string, enforce the
data model that is expected from semver versioning. The API version is
now represented as a tuple:

(u32, u32, u32)

Corresponding to the respective semver identifier:

(MAJOR, MINOR, PATCH).

Signed-off-by: Tyler Fanelli <[email protected]>
Transparently {de}serialize each byte array parameter to/from base64 to
allow for compression of binary data.

Signed-off-by: Tyler Fanelli <[email protected]>
Document the attestation protocol between SVSM and the proxy to
illustrate the purpose of each step in the process.

Signed-off-by: Tyler Fanelli <[email protected]>
@tylerfanelli
Copy link
Contributor Author

@stefano-garzarella there was a conflict in Cargo.lock. I rebased and resolved the conflict. Can you re-approve?

@joergroedel joergroedel added the release-feature Changes include a feature that SHOULD be included in the next release. label Nov 25, 2025
@stefano-garzarella stefano-garzarella merged commit 750239d into coconut-svsm:main Nov 25, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge PR is ready for merging into main branch release-feature Changes include a feature that SHOULD be included in the next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants