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

nested mounts #548

Closed
aep opened this issue Apr 26, 2022 · 6 comments
Closed

nested mounts #548

aep opened this issue Apr 26, 2022 · 6 comments

Comments

@aep
Copy link

aep commented Apr 26, 2022

nesting a protected file inside a tmpfs doesnt work.
writes to the nested protected file do not make it to the host.

fs.mounts = [
  { path = "/lib",              uri = "file:{{ gramine.runtimedir() }}" },
  { path = "{{ arch_libdir }}", uri = "file:{{ arch_libdir }}" },
  { path = "/usr/lib",          uri = "file:/usr/lib" },
  { path = "/app",              uri = "file:/app" },
  { path = "/app/wordpress",    uri = "file:/app/wordpress",  type="tmpfs"},
]

sgx.protected_files = [
  "file:/app/wordpress/wp-config.php",
]

background:

the tmpfs is needed here to preload php code into the enclave memory, since we are required to use gramines fs implementation. but the code expects the directory to be persisted, so i tried making individual file exceptions

@dimakuv
Copy link

dimakuv commented Apr 26, 2022

Yes, I think the complex combinations of fs.mounts and sgx.protected_files (like yours) do not work currently in Gramine.

However, we are close to finishing the rework of the whole FS subsystem: #371

After this rework, sgx.protected_files and sgx.trusted_files and sgx.allowed_files will become deprecated, and all FS hierarchy will be set up only through fs.mounts array. This will make nesting possible (the mounts will overlay each over), and your app will work as expected.

In fact, you can already try the latest Gramine with the encrypted FS mount. See also my reply here: #371 (comment)

@aep
Copy link
Author

aep commented Apr 26, 2022

wait are you saying this should already work?

fs.mounts = [
 { path = "/app/wordpress",    uri = "file:/app/wordpress",  type="tmpfs"},
 { path = "/app/wordpress/wp-config.php", uri = "file:/app/persisted/wp-config.php", type = "encrypted", key_name = "default" },
]

it doesnt for me

warning: Disallowing access to file '/app/persisted/wp-config.php'; file is not protected, trusted or allowed.

@dimakuv
Copy link

dimakuv commented Apr 26, 2022

Do you have the "default" key specified in your manifest? Like here:

fs.insecure__keys.default = "ffeeddccbbaa99887766554433221100"

Also, what is the Gramine version/commit you're running? (You can find it when you enable loader.log_level = "debug", it will be one of the first lines printed.)

This feature was merged in Gramine very recently, on 20. April.

@aep
Copy link
Author

aep commented Apr 26, 2022

yes key is specified, debug doesnt show more info

however, adding it to allowed confusingly makes it work

sgx.allowed_files = [
    "file:/app/persisted/wp-config.php"
] 

is this intentional? i was assuming allowed means unencrypted write, but it actually looks encrypted on the host

gramine is git from last week, let me make sure to pull todays head instead.

@dimakuv
Copy link

dimakuv commented Apr 26, 2022

gramine is git from last week, let me make sure to pull todays head instead.

Please do. There was a small bug exactly as you describe (adding the file to sgx.allowed_files allows to use the file in an encrypted way). We fixed it on 20. April, see this PR: #534

aep added a commit to enclaive/enclaive-docker-wordpress-sgx that referenced this issue Apr 26, 2022
@aep
Copy link
Author

aep commented Apr 26, 2022

going to close because the new feature does what we need. thanks!

@aep aep closed this as completed Apr 26, 2022
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

2 participants