Skip to content

Commit 57fe0cd

Browse files
authored
Merge branch 'master' into ns/SALM-564
2 parents 269b3dd + 916d16c commit 57fe0cd

File tree

13 files changed

+3342
-731
lines changed

13 files changed

+3342
-731
lines changed

.github/workflows/build-solution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
- name: Build Rust code
8989
run: |
90-
./build-solution.sh
90+
./build-converter.sh
9191
9292
- name: Run Rust unit tests
9393
env:

README.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,115 @@
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+
1113
# Contributing
2114

3115
We gratefully accept bug reports and contributions from the community.
@@ -32,4 +144,4 @@ this project or the open source license(s) involved.
32144

33145
# License
34146

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.
File renamed without changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
clonelinux() {
6+
7+
# Clone the amazon linux kernel repository and checkout
8+
# the branch which is used for nitro enclaves
9+
# You can find out the kernel version used by nitro-enclaves
10+
# by running uname -a in a converted app. In this case, we
11+
# use version 4.14.246
12+
# For more details about supported nitro enclave kernel
13+
# versions, refer to the aws-nitro-enclaves-cli github repository.
14+
15+
if [ -d "linux" ]; then
16+
cd linux
17+
git fetch
18+
else
19+
git clone https://github.com/amazonlinux/linux.git
20+
cd linux
21+
fi
22+
23+
git checkout microvm-kernel-4.14.246-198.474.amzn2
24+
25+
}
26+
27+
buildkernel() {
28+
29+
# Copy the enclave kernel config file into the kernel repository
30+
# The original file is available here:
31+
# https://github.com/aws/aws-nitro-enclaves-cli/blob/main/blobs/x86_64/bzImage.config
32+
# The config file available in this directory has been updated to
33+
# support salmiac features.
34+
cp ../bzImage.config .config
35+
36+
# Build the enclave kernel
37+
make prepare
38+
make modules_prepare
39+
make modules -j
40+
make -j
41+
make bzImage
42+
43+
# Once build is complete, we would need a copy of the bzImage file
44+
cp ./arch/x86/boot/bzImage ../
45+
cp .config ../bzImage.config
46+
47+
cd ../
48+
}
49+
50+
cleankernel() {
51+
if [ -d "linux" ]; then
52+
rm -rf linux
53+
fi
54+
}
55+
56+
if [ $1 == "build" ]; then
57+
clonelinux;
58+
buildkernel;
59+
elif [ $1 == "clean" ]; then
60+
cleankernel;
61+
else
62+
echo "Provide input arguments - build or clean"
63+
fi
64+

0 commit comments

Comments
 (0)