|
| 1 | +Salmiac |
| 2 | +====== |
| 3 | + |
| 4 | + |
| 5 | +A confidential VM running unmodified container images in AWS [Nitro Enclaves](https://aws.amazon.com/ec2/nitro/). |
| 6 | +Salmiac makes it possible to run an application in isolated compute environments to protect and securely process highly sensitive data. |
| 7 | + |
| 8 | +By default bare Nitro Enclaves doesn't provide any networking capability outside of the enclave environment as well |
| 9 | +as no persistent storage, meaning that all your data is lost when container image finishes its execution. |
| 10 | + |
| 11 | +Salmiac enhances Nitro Enclaves by enabling networking for external communication and providing encrypted persistent storage. |
| 12 | + |
| 13 | +Useful links |
| 14 | +------------ |
| 15 | + |
| 16 | +* :wrench: [Nitro-cli](https://github.com/aws/aws-nitro-enclaves-cli) a tool Salmiac is built on. |
| 17 | +* :book: [The Security Design of the AWS Nitro System](https://docs.aws.amazon.com/whitepapers/latest/security-design-of-aws-nitro-system/security-design-of-aws-nitro-system.html), official Nitro Enclaves whitepaper. |
| 18 | +* :film_projector: [Presentation](https://archive.fosdem.org/2023/schedule/event/cc_aws/) of Salmiac internals. |
| 19 | + |
| 20 | +Quick Start Guide |
| 21 | +-------------- |
| 22 | +This guide allows you to build salmiac from source and convert your docker application into a one that can run in a nitro enclave. |
| 23 | + |
| 24 | +1. Set up your Ubuntu based build system: |
| 25 | + - Install Rust: |
| 26 | + Follow [this](https://www.rust-lang.org/tools/install) guide. |
| 27 | + - Install Docker: |
| 28 | + Follow [this](https://docs.docker.com/engine/install/) guide to install version 24.0.x |
| 29 | + OR |
| 30 | + ```bash |
| 31 | + apt-get install docker-ce=5:24.0.1-1~ubuntu.20.04~focal docker-ce-cli=5:24.0.1-1~ubuntu.20.04~focal containerd.io |
| 32 | + ``` |
| 33 | + - Install tools needed to build the linux kernel: |
| 34 | + Follow [this](https://kernelnewbies.org/KernelBuild) guide. |
| 35 | + - Install additional dependencies: |
| 36 | + ```bash |
| 37 | + apt-get install pkg-config libclang-dev cmake libpcap-dev |
| 38 | + ``` |
| 39 | + |
| 40 | +2. Set up your Nitro-enabled AWS EC2 instance: |
| 41 | + - Install docker on your EC2: |
| 42 | + Follow [this](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html) guide. |
| 43 | + - Install nitro-cli on your EC2: |
| 44 | + Follow [this](https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-cli-install.html) guide. |
| 45 | + |
| 46 | + |
| 47 | +3. Build requisite docker images needed to run container converter |
| 48 | + ```bash |
| 49 | + # Run from the root of the repository |
| 50 | + # build enclave-base image |
| 51 | + cd salmiac/docker/enclave-base |
| 52 | + docker build -t enclave-base . |
| 53 | + |
| 54 | + # build parent-base image |
| 55 | + cd ../parent-base |
| 56 | + docker build -t parent-base . |
| 57 | + ``` |
| 58 | + |
| 59 | +4. Build the enclave kernel. This step takes a long time and needs to be done only once. The artifacts produced by this step need not be cleaned up unless the kernel config is updated. |
| 60 | + ```bash |
| 61 | + cd amzn-linux-nbd |
| 62 | + ./build-enclave-kernel.sh build |
| 63 | + ``` |
| 64 | + |
| 65 | +5. Build the converter image. To produce a debug build of the converter, ensure the release flag is removed from the step below. |
| 66 | + ```bash |
| 67 | + # Run from the root of the repository |
| 68 | + cd salmiac |
| 69 | + # To produce a debug build of the converter, ensure the release flag is removed from the step below. |
| 70 | + ./build-converter.sh --release |
| 71 | +
|
| 72 | + cd docker |
| 73 | + # If a debug build of the converter was produced, use debug as an argument to the below script |
| 74 | + ./build-conv-container.sh release |
| 75 | + ``` |
| 76 | + |
| 77 | +6. Create a simple conversion request json file (say /tmp/req.json) |
| 78 | + More details about each field of the conversion request can be found in /salmiac/api-model/src/converter.rs |
| 79 | + ```javascript |
| 80 | + { |
| 81 | + "input_image": { |
| 82 | + "name": "hello-world", |
| 83 | + }, |
| 84 | + "output_image": { |
| 85 | + "name": "hello-world-nitro", |
| 86 | + }, |
| 87 | + "converter_options": { |
| 88 | + "push_converted_image": false, |
| 89 | + "enable_overlay_filesystem_persistence": false |
| 90 | + }, |
| 91 | + "nitro_enclaves_options": { |
| 92 | + "cpu_count": 2, |
| 93 | + "mem_size": "4096M" |
| 94 | + } |
| 95 | + } |
| 96 | + ``` |
| 97 | + |
| 98 | +7. Make your application Nitro VM-capable by running container converter with the file from previous step. |
| 99 | + The converter by default pulls the input image and pushes the output image to remote repositories. These images are then cleaned up from the local docker cache. In our example, the output image push is disabled in the request json and to preserve the images in the docker cache, 'PRESERVE_IMAGES' environment variable is specified. |
| 100 | + ```bash |
| 101 | + docker run --rm --name converter --user 0 --privileged -v /var/run/docker.sock:/var/run/docker.sock -e PRESERVE_IMAGES=input,result -v /tmp/req-files:/app converter --request-file /app/req.json |
| 102 | + ``` |
| 103 | + |
| 104 | +8. Copy converted image into your EC2 instance and run the image. |
| 105 | + Note the use of the environment variable which disables the use of default certificates, which allows you to skip access to Fortanix CCM. Read more about environment variables used in salmiac here - /salmiac/ENV_VARS.md |
| 106 | + ```bash |
| 107 | + # Copy your converted image from step #7 into your EC2 isntance |
| 108 | + # ... |
| 109 | + # Run copied image inside EC2 |
| 110 | + docker run -it --rm --privileged -v /run/nitro_enclaves:/run/nitro_enclaves -e ENCLAVEOS_DISABLE_DEFAULT_CERTIFICATE=true hello-world-nitro |
| 111 | + ``` |
| 112 | + |
1 | 113 | # Contributing
|
2 | 114 |
|
3 | 115 | We gratefully accept bug reports and contributions from the community.
|
@@ -32,4 +144,4 @@ this project or the open source license(s) involved.
|
32 | 144 |
|
33 | 145 | # License
|
34 | 146 |
|
35 |
| -This project is primarily distributed under the terms of the Mozilla Public License (MPL) 2.0, see [LICENSE](./LICENSE) for details. |
| 147 | +This project is primarily distributed under the terms of the Mozilla Public License (MPL) 2.0, see [LICENSE](./LICENSE) for details. |
0 commit comments