Skip to content
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

Unable to read encrypted files after a kernel upgrade. #1504

Closed
kvinwang opened this issue Aug 22, 2023 · 4 comments
Closed

Unable to read encrypted files after a kernel upgrade. #1504

kvinwang opened this issue Aug 22, 2023 · 4 comments

Comments

@kvinwang
Copy link

Description of the problem

Gramine encrypted files cannot be opened after a kernel upgrade.

I originally posted this issue as a discussion thread #1503. However, after digging further, I believe it is worth opening an issue here.

Steps to reproduce

  1. Install Rust toolchain
  2. git clone https://github.com/kvinwang/gramine-encrypted-files-demo && cd gramine-encrypted-files-demo
  3. make SGX=1
  4. ./run.sh
    It would show the following logs:
    Pasted Graphic 2
  5. reboot the system and load another version of kernel
  6. ./run.sh again
    It now show the same egetkey result but failed to read the encrypted files as below:
    Pasted Graphic 4

Expected results

Encrypted files should be read successfully.

Actual results

Permission Denied

Gramine commit hash

ede508c

@kvinwang
Copy link
Author

kvinwang commented Aug 22, 2023

The reason might be the cpu_svn changed between the two version of kernel.
If so, is it possible that gramine record the cpu_svn of a encrypted file and use it to get the unsealing key while decrypt the file?

@kailun-qin
Copy link
Contributor

@kvinwang Thanks for the report! Pls see my comments below.

The reason might be the cpu_svn changed between the two version of kernel.

I saw in the corresponding discussion - "Some of the machine have a linux kernel update during the reboot, some haven't.", so this seems to happen for reboots even w/o kernel updates. Then why would CPUSVN change if it's a plain/normal reboot (w/o kernel update)? Can we first make sure that it's the change of the CPUSVN that caused your reported issue.

In your reproduction test, the printed SGX sealing keys were directly from EGETKEY (w/ CPUSVN hardcoded), instead would you pls show the keys that Gramine actually used for encrypted fs by reading them from /dev/attestation/keys/_sgx_mrenclave and /dev/attestation/keys/_sgx_mrsigner?

If so, is it possible that gramine record the cpu_svn of a encrypted file and use it to get the unsealing key while decrypt the file?

Yes, this is doable where we could extend metadata_plain_t w/ CPUSVN (and ISVSVN probably)

typedef struct _metadata_plain {
uint64_t file_id;
uint8_t major_version;
uint8_t minor_version;
pf_keyid_t metadata_key_id;
pf_mac_t metadata_gmac; /* GCM mac */
} metadata_plain_t;
and restore them in key_request for getting SGX sealing keys.

@dimakuv
Copy link
Contributor

dimakuv commented Aug 22, 2023

This is a duplicate of #855. Please see there, we have lots of discussions in that thread.

So, I think we have three users (user bases) that hit this problem of CPUSVN. I will raise this issue in one of the Gramine meetings, and I'll probably write a PoC, so that we at least have something concrete to discuss.

@kvinwang
Copy link
Author

kvinwang commented Sep 1, 2023

Can we first make sure that it's the change of the CPUSVN that caused your reported issue.

We finally comfirmed that all our cases was due to intel-microcode update which further changed the CPUSVN.

As this issue is duplicate of #855, let closing this one and continue there.

@kvinwang kvinwang closed this as completed Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants