-
Notifications
You must be signed in to change notification settings - Fork 206
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
RFC: trusted files redesign #578
Comments
This is necessary. People use it quite often. |
I see. Do you think people use it for writable files as well? |
Anyway, I'd suggest to add it as a mount parameter:
And, if we can afford it, this will treat unknown files as openable but still read-only. |
I do use them a lot, especially when people want to quickly evaluate an existing app with Gramine and they can't give us the whole environment. I usually suggest them to use a very permissive manifest, let them run the app successfully in their environment. Then we'll go through the runtime log and come up with a more restrictive manifest for production. Without the ability to read/write any file, the app will usually stop at the first violation, and after going back and forth several times, new beginners will fell Gramine is difficult to use, while it really isn't. |
Yes, I think this is reasonable. People can always just use |
With normal passthrough, we won't be able to see which file is accessed from the runtime log. Perhaps we can also add policy = "allow_all_but_log" to passthrough mounts as well, to log first (read or write) access to each file? |
That's a very good point. Ok, yes, maybe we should add this |
Just a note before I forget it again: after this redesign is done, and the documentation https://gramine.readthedocs.io/en/latest/manifest-syntax.html is updated, we must move the syntax descriptions from under SGX syntax to common syntax. For example, currently Encrypted Files (https://gramine.readthedocs.io/en/latest/manifest-syntax.html#encrypted-files) are kept under "SGX syntax" section. This is not correct anymore -- they are applicable to any PAL (backend), so they should be under "Common syntax" section. Same will be with Trusted Files after the redesign. |
NOTE: I will not be implementing this; this is me leaving notes/plans for possible next implementer.
Summary
Make trusted files configurable per mount, and move handling to LibOS, similar to what I did for protected files (#371).
In addition, trusted files will be renamed to hashed files.
This has the following benefits:
passthrough
,hashed
,encrypted
).Proposed changes
Old syntax:
New syntax:
sgx.trusted_files
is simply renamed tofs.hashed_files
(during the deprecation period, we respect both settings).gramine-manifest
computes the hashes when building*.manifest
(not only*.manifest.sgx
). After a deprecation period,*.manifest.sgx
will not be necessary!hashed
becomes a separate mount type (internally calledchroot_hashed
, same aschroot_encrypted
). All files under ahashed
mount have to be on thefs.hashed_files
list. If a host file is not on that list, or has a different hash, it's not visible on guest. (Alternatively, a different hash might produce-EACCES
).To allow accessing a file directly, mount it with
type = "passthrough"
. This replacessgx.allowed_files
.PAL still needs to load LibOS, which needs to be hashed. So instead of trusted files, we will supply a hash for it directly in manifest:
There is no
sgx.file_check_policy = "allow_all_but_log"
.The default mount type (
chroot
) is deprecated, and it works in a sort of "compatibility mode":Linux-SGX
, it respectssgx.trusted_files
andsgx.allowed_files
,passthrough
.The root mount is still
type = "chroot"
by default, but a warning is displayed, encouraging the user to setfs.root.type = "hashed"
.Implementation
I think the implementation can follow the encrypted files: there should be two layers, filesystem (handling inodes, handles etc.) and library (handling the actual logic of verifying trusted files).
FS layer:
chroot/hashed.c
).struct shim_hashed_file
object. On lookup, use the library (see below) to create this object and verify file hash.chroot
filesystem, but reading is done through the library (see below).Library:
shim_fs_hashed.c
) similar toshim_fs_encrypted.c
.Note that this is somewhat inefficient:
stat
), it has to read the whole file in order to know its size,However, AFAIK this matches the current implementation in PAL. We can add caching if it ever becomes an issue.
Implementation plan
Implement the
hashed
filesystem as a separate feature (that looks atfs.hashed_files
). Add support togramine-manifest
tool: note that it will compute the file hashes when building*.manifest
, NOT*.manifest.sgx
.Implement
loader.entrypoint_sha256
for loading LibOS by PAL.Remove trusted files from PAL, route
sgx.trusted_files
etc. to the new code. Add deprecation notices.Issues
The new design assumes
sgx.file_check_policy = "allow_all_but_log"
is not necessary. Is it?The target implementation is, IMO, simple, but the compatibility code (during deprecation period) will be more complicated, in order to match the current behavior.
The chunk hashes are SHA256 truncated to 128 bits, presumably to save space. Maybe we should just use 256-bit chunk hashes? (If the host can find a collision for the chunk hash function, it can replace the hashes after Gramine verifies the file)
The text was updated successfully, but these errors were encountered: