{"id":13628668,"url":"https://github.com/lsds/sgx-lkl","last_synced_at":"2026-03-09T17:11:06.286Z","repository":{"id":45143180,"uuid":"113332442","full_name":"lsds/sgx-lkl","owner":"lsds","description":"SGX-LKL Library OS for running Linux applications inside of Intel SGX enclaves","archived":false,"fork":false,"pushed_at":"2022-12-25T09:16:28.000Z","size":38351,"stargazers_count":259,"open_issues_count":174,"forks_count":91,"subscribers_count":25,"default_branch":"oe_port","last_synced_at":"2025-05-20T05:05:04.119Z","etag":null,"topics":["enclave","java","javascipt","jvm","linux","sgx","trusted-execution"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lsds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-06T15:22:02.000Z","updated_at":"2025-05-17T08:07:40.000Z","dependencies_parsed_at":"2023-01-30T21:46:11.291Z","dependency_job_id":null,"html_url":"https://github.com/lsds/sgx-lkl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lsds/sgx-lkl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsds%2Fsgx-lkl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsds%2Fsgx-lkl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsds%2Fsgx-lkl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsds%2Fsgx-lkl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsds","download_url":"https://codeload.github.com/lsds/sgx-lkl/tar.gz/refs/heads/oe_port","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsds%2Fsgx-lkl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30303952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enclave","java","javascipt","jvm","linux","sgx","trusted-execution"],"created_at":"2024-08-01T22:00:55.305Z","updated_at":"2026-03-09T17:11:06.239Z","avatar_url":"https://github.com/lsds.png","language":"C","funding_links":[],"categories":["C","Runtime Framework","LibOS"],"sub_categories":["Library OSes and SDKs"],"readme":"SGX-LKL-OE (Open Enclave Edition)\n=================================\n\n*WARNING:* This branch contains an experimental port of SGX-LKL to use Open Enclave as an enclave abstraction layer.\nThis is an ongoing research project.\nVarious features are under development and there are several known bugs.\n\n[![Build Status](https://dev.azure.com/sgx-lkl/sgx-lkl/_apis/build/status/sgx-lkl?branchName=oe_port)](https://dev.azure.com/sgx-lkl/sgx-lkl/_build/latest?definitionId=1\u0026branchName=oe_port)\n\nThe SGX-LKL project is designed to run existing unmodified Linux binaries inside of Intel SGX enclaves. The goal of the project is to provide the necessary system support for complex applications (e.g., TensorFlow, PyTorch, and OpenVINO) and programming language runtimes (e.g., Python, the DotNet CLR and the JVM). SGX-LKL can run these applications in SGX enclaves without modifications or reliance on the untrusted host OS.\nKnown incompatibilities are documented in [Incompatibilities.md](docs/Incompatibilities.md).\n\nThe SGX-LKL project includes several components:\n\n - A launcher and host interface modelled after a lightweight VM interface.\n   This is documented in [HostInterface.md](docs/HostInterface.md).\n - A port of Linux to run in this environment, using the Linux Kernel Library (LKL) (https://github.com/lkl/linux).\n - A port of the musl standard C library to run on top of this version of Linux.\n\nFor frequently asked questions, please see the [FAQ](docs/FAQ.md).\n\nSGX-LKL uses the Linux Kernel Library (LKL) (https://github.com/lkl/linux)\nto provide a mature POSIX implementation within an enclave. A modified version \nof the musl standard C library (https://www.musl-libc.org) is available to \napplications inside the enclave.\n\nSGX-LKL supports in-enclave user-level threading, signal handling, and file\nand network I/O. System calls are handled within the enclave by LKL, and the \nhost is used only for access to I/O resources.\n\nSGX-LKL can be run in hardware mode, when it requires an Intel SGX compatible\nCPU, and also in software simulation mode, when it runs on any Intel CPU\nwithout hardware security guarantees. \n\nA. Installing SGX-LKL-OE\n------------------------\n\nSGX-LKL-OE is distributed as Debian package.\nThis package is alpha quality and not meant for production.\n\nThe SGX-LKL-OE package contains the runtime, tools, and all its dependencies\nand can be run on any Linux distribution.\n\nTo use development releases (updated on every commit to `master`), run:\n```sh\necho \"deb [trusted=yes] https://clcpackages.blob.core.windows.net/apt-dev/1fa5fb889b8efa6ea07354c3b54903f7 ./\" | sudo tee /etc/apt/sources.list.d/azure-clc.list\n```\n\nTo use stable releases (manually published), run:\n```sh\necho \"deb [trusted=yes] https://clcpackages.blob.core.windows.net/apt/1fa5fb889b8efa6ea07354c3b54903f7 ./\" | sudo tee /etc/apt/sources.list.d/azure-clc.list\n```\n\nNow, install with:\n```sh\nsudo apt update\n# or: sgx-lkl-nonrelease (-release variant will follow)\nsudo apt install sgx-lkl-debug\n```\n\nTo make the SGX-LKL commands available from any directory, add an entry to \nthe `PATH` environment variable:\n```\nPATH=\"$PATH:/opt/sgx-lkl/bin\"\n```\n\nFinally, setup the host environment by running:\n```\nsgx-lkl-setup\n```\n\nSGX-LKL works most performant with a Linux kernel that has support for userspace FSGSBASE instructions. Otherwise, support for thread local storage (TLS) must use emulated instructions, which reduces performance.\nSGX-LKL outputs a message on start-up if the currently running Linux kernel does not support FSGSBASE instructions.\n\nFSGSBASE support is not part of the mainline Linux kernel yet.\nAzure VMs run on Linux kernels [with FSGSBASE support](https://bugs.launchpad.net/ubuntu/+source/linux-azure/+bug/1877425) based on a proposed Linux kernel patch.\nTo apply the latest patch version to non-Azure systems you may follow the instructions [here](tools/ubuntu-patched-kernel-fsgsbase).\n\nB. Building SGX-LKL-OE from source\n----------------------------------\n\nSGX-LKL has been tested on Ubuntu Linux 18.04 and with a gcc compiler\nversion of 7.4 or above. Older compiler versions may lead to compilation\nand/or linking errors.\n\n1. Install the SGX-LKL build dependencies:\n```\nsudo apt-get install make gcc g++ bc python xutils-dev bison flex libgcrypt20-dev libjson-c-dev automake autopoint autoconf pkgconf libtool libcurl4-openssl-dev libprotobuf-dev libprotobuf-c-dev protobuf-compiler protobuf-c-compiler libssl-dev\n```\n\n2. Clone the SGX-LKL git repository:\n```\ngit clone --branch oe_port --recursive https://github.com/lsds/sgx-lkl.git\ncd sgx-lkl\n```\n\n3. Install the Open Enclave build dependencies:\n```\ncd openenclave\nsudo scripts/ansible/install-ansible.sh\nsudo ansible-playbook scripts/ansible/oe-contributors-setup.yml\n```\n\nNote that the above also installs the Intel SGX driver on the host.\n\nIf running on an Azure Confidential Computing (ACC) VM, which offers SGX support,\nthe last line above should be replaced by:\n```\nsudo ansible-playbook scripts/ansible/oe-contributors-acc-setup-no-driver.yml\n```\n\n4. Build SGX-LKL in the source tree:\n\n#### DEBUG build (with debug functionality, no compiler optimisations)\n\nTo build SGX-LKL with debug symbols and without compiler optimisations, run the following \ncommand in the SGX-LKL source tree\n```\nmake DEBUG=true\n```\nNote that, on the first invocation, this initialises all git submodules, \nincluding a clone of the LKL library, which downloads several GBs of data.\n\nYou will then find the build files under `build/`.\n\n#### NON-RELEASE build (no debug symbols, with compiler optimisations)\n\nTo build SGX-LKL with compiler optimisations and without debug symbols, run:\n```\nmake\n```\n\n#### RELEASE build _(not yet supported by SGX-LKL-OE)_\n\nSGX-LKL has a RELEASE build, which make the resulting enclave library secure by\nremoving any insecure debug funcationlity and enforcing security features such\nas attestestation. \n\nTo build SGX-LKL in release mode, run:\n```\n    make RELEASE=true\n```\n\n5. To install SGX-LKL on the host system, use the following command:\n```\nsudo -E make install\n```\n\nSGX-LKL is installed under `/opt/sgx-lkl` by default. To change the install prefix, \nuse `PREFIX`, e.g.:\n```\nmake install PREFIX=\"${PWD}/install\"\n```\n\nTo uninstall SGX-LKL, run\n```\nsudo make uninstall\n```\n\nThis removes SGX-LKL specific artefacts from the installation directory as\nwell as cached artefacts of `sgx-lkl-disk` (stored in `~/.cache/sgxlkl`).\n\n6. To make the SGX-LKL commands available from any directory, add an entry to \nthe `PATH` environment variable:\n```\nPATH=\"$PATH:/opt/sgx-lkl/bin\"\n```\n\n7. Finally, setup the host environment by running:\n```\nsgx-lkl-setup\n```\n\nThis has to be done after each reboot. It configures the host networking to \nforward packets from SGX-LKL instances.\n\nC. Running applications with SGX-LKL\n------------------------------------\n\nTo run applications with SGX-LKL, they must be provided as part of a \nLinux disk image. Since SGX-LKL is built using the musl libc library, \napplications must have been dynamically linked against musl. Currently, \napplications linked against glibc are not supported by SGX-LKL. The \nsimplest way to run applications with SGX-LKL is to use prebuilt binaries \nfor Alpine Linux, which uses musl libc as its default C standard library.\n\n### 1. Running existing sample applications\n\nThe SGX-LKL source tree contains sample applications under 'samples/'. Most \nsample applications can be run in hardware SGX mode by going to the \ncorresponding directory and execute the following command:\n```\nmake run-hw\n```\n\nTo run an application in software mode without SGX support, execute:\n```\nmake run-sw\n```\n\n### 2. Creating SGX-LKL disk images with sgx-lkl-disk\n\nWhile it is possible to create disk images manually, SGX-LKL comes with \na helper tool `sgx-lkl-disk`. It can be used to create, check, mount, and \nunmount SGX-LKL disk images.\n\nTo see all options, run:\n```\nsgx-lkl-disk --help\n```\n\nThe tool has been tested on Ubuntu 18.04. `sgx-lkl-disk` will need superuser \nrights for some operations, e.g. temporarily mounting/unmounting disk images.\n\n#### Creating Alpine-based disk images\n\nTo create a disk image, use the `create` action, which expects the disk image \nsize to be specified via `--size=\u003cSIZE\u003e` and the disk\nimage file name. It also requies the the source of the image.\n\nTo build an image with one or more applications available in the\nAlpine package repository, use the `--alpine=\u003cpkgs\u003e` flag. The following example\ncreates an image with Redis installed:\n```\nsgx-lkl-disk create --size=50M --alpine=\"redis\" sgxlkl-disk.img\n```\n\nRedis can then be run as follows:\n```\nSGXLKL_TAP=sgxlkl_tap0 sgx-lkl-run-oe --hw-debug ./sgxlkl-disk.img /usr/bin/redis-server --bind 10.0.1.1\n```\n\nTo create and run a disk image with Memcached, execute:\n```\nsgx-lkl-disk create --size=50M --alpine=\"memcached\" sgxlkl-disk.img\nSGXLKL_TAP=sgxlkl_tap0 sgx-lkl-run-oe --hw-debug ./sgxlkl-disk.img /usr/bin/memcached --listen=10.0.1.1 -u root --extended=no_drop_privileges -vv\n```\n\nIf you need to add extra data to the disk image, the parameter `--copy=\u003cpath\u003e` can \nbe used to copy files from the host to the disk image. The following example creates a disk \nimage with the Alpine Python package together with a custom Python application:\n```\n# When --copy points to a directory, the contents of the directory are copied\n# to the root of the file system.\ntree my-python-root\n\u003e my-python-root\n\u003e ├── app\n\u003e │   ├── myapp.py\n\u003e │   └── util.py\n\nsgx-lkl-disk create --size=100M --alpine=\"python\" --copy=./my-python-root sgxlkl-disk.img\n# Run with\nsgx-lkl-run-oe --hw-debug ./sgxlkl-disk.img /usr/bin/python /app/myapp.py\n```\n\n#### Creating Docker-based disk images\n\nThe `sgx-lkl-disk` tool can also build disk images from Dockerfiles with the `--docker`\nflag, e.g. when an application needs to be compiled manually. Note that SGX-LKL \napplications still need to be linked against musl libc, so a good starting \npoint is an Alpine Docker base image.\n\nTo build an SGX-LKL disk image from a Dockerfile, run:\n```\nsgx-lkl-disk create --size=100M --docker=MyDockerfile sgxlkl-disk.img\n```\n\n#### Creating plain disk images\n\nIf all that is needed is a plain disk image based on files existing on the\nhost, the `--copy` flag can be used on its own:\n```\nsgx-lkl-disk create --size=50M --copy=./my-root sgxlkl-disk.img\n```\n\n#### Disk encryption\n\nSGX-LKL supports disk encryption via the *dm-crypt* subsystem in the Linux\nkernel. Typically encryption for a disk can be setup via the `cryptsetup` tool.\nThe `sgx-lkl-disk` tool provides an `--encrypt` option to simplify this \nprocess. To create an encrypted disk image with default options run:\n```\nsgx-lkl-disk create --size=50M --encrypt --key-file --alpine=\"\" sgxlkl-disk.img.enc\n# Run with\nSGXLKL_HD_KEY=./sgxlkl-disk.img.enc.key sgx-lkl-run-oe --hw-debug ./sgxlkl-disk.img.enc /bin/echo \"Hello World\"\n```\n\nIn this example, `sgx-lkl-disk` automatically generates a 512-byte key file,\nuses \"AES-XTS Plain 64\" as a cipher/mode and \"SHA256\" for hashing. The cipher\nand hash algorithm is stored as metadata in a LUKS header on disk.\nThe tool provides a number of options to customise this (see\n`sgx-lkl-disk --help` for more information).\n\n#### Disk integrity protection\n\nTo provide disk/data integrity, SGX-LKL supports both *dm-verity* (read-only) \nand *dm-integrity* (read/write). These can be combined with disk\nencryption (*dm-integrity* can currently only be used together with `--encrypt`).\n\nTo create a read-only encrypted disk image with integrity\nprotection via *dm-verity*, run:\n```\nsgx-lkl-disk create --size=50M --encrypt --key-file --verity --alpine=\"\" sgxlkl-disk.img.enc.vrt\n# Run with\nSGXLKL_HD_VERITY=./sgxlkl-disk.img.enc.vrt.roothash SGXLKL_HD_KEY=./sgxlkl-disk.img.enc.vrt.key sgx-lkl-run-oe ./sgxlkl-disk.img.enc.vrt /bin/echo \"Hello World\"\n```\n\nTo create an encrypted and integrity-protected disk that uses HMAC-SHA256 for\nauthenticated encryption and supports both reads and writes, run:\n```\n# --integrity requires a host kernel version 4.12 or greater and cryptsetup version 2.0.0 or greater\nsgx-lkl-disk create --size=50M --encrypt --key-file --integrity --alpine=\"\" sgxlkl-disk.img.enc.int\n# Run with\nSGXLKL_HD_KEY=./sgxlkl-disk.img.enc.int.key sgx-lkl-run-oe ./sgxlkl-disk.img.enc.int /bin/echo \"Hello World\"\n```\n\n`sgx-lkl-disk` relies on `cryptsetup` for setting up encryption and integrity\nprotection. For more information on cryptsetup and \ndm-crypt/dm-verity/dm-integrity, see\nhttps://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt.\n\n### 3. Running applications from the Alpine Linux repository\n\nAlpine Linux uses musl as its standard C library. SGX-LKL supports a large\nnumber of unmodified binaries available through the Alpine Linux repository.\nFor an example on how to create the corresponding disk image and how to run the\napplication, `samples/miniroot` can be used as a template. \n\nBuild the disk image by running: \n```\nmake\n```\n\nThis creates an Alpine mini root disk image that can be passed to `sgx-lkl-run-oe`.\n`buildenv.sh` can be modified to specify APKs that should be part of the disk\nimage. After creating the disk image, applications can be run on top of SGX-LKL\nusing `sgx-lkl-run-oe`. Using Redis as an example (the APK `redis` is listed in\nthe example `buildenv.sh` file in `samples/miniroot`), `redis-server` can be\nlaunched as follows:\n```\nSGXLKL_TAP=sgxlkl_tap0 sgx-lkl-run-oe --hw-debug ./sgxlkl-miniroot-fs.img /usr/bin/redis-server --bind 10.0.1.1\n```\n\nThe readme file in `samples/miniroot` contains more detailed information on how to\nbuild custom disk images manually.\n\n### 4. OpenJDK Java Virtual Machine (JVM)\n\nA simple Java HelloWorld example application is available in\n`samples/jvm/helloworld-java`. Building the example requires `curl` and a Java 8\ncompiler on the host system. On Ubuntu, install these by running:\n```\nsudo apt-get install curl openjdk-8-jdk\n```\n\nTo build the disk image, run:\n```\ncd samples/jvm/helloworld-java\nmake\n```\n\nThis compiles the HelloWorld Java example, create a disk image with an\nAlpine mini root environment, add a JVM, and add the `HelloWorld.class` file.\n\nTo run the HelloWorld java program on top of SGX-LKL inside an enclave, run\"\n```\nsgx-lkl-java ./sgxlkl-java-fs.img HelloWorld\n```\n\nThe command `sgx-lkl-java` is a simple wrapper around `sgx-lkl-run-oe`, which \nsets some common JVM arguments in order to reduce its memory footprint. It \ncan be found in the `tools/` directory. For more complex applications, SGX-LKL \nor JVM arguments may have to be adjusted, e.g. to increase the size of the \nJVM heap/metaspace/code cache, or to enable networking support by providing \na TAP/TUN interface via `SGXLKL_TAP`.\n\nIf the application runs successfully, you should see an output like this:\n\n```\nOpenJDK 64-Bit Server VM warning: Can't detect initial thread stack location - find_vma failed\nHello world!\n```\n\nThe warning is caused by the fact that the JVM is trying to receive\ninformation about the process's virtual memory regions from `/proc/self/maps`.\nWhile SGX-LKL generally supports the `/proc` file system in-enclave,\n`/proc/self/maps` is currently not populated by SGX-LKL. This does not affect\nthe functionality of the JVM.\n\n### 5. Cross-compiling applications for SGX-LKL\n\nFor applications with a complex build process and/or a larger set of\ndependencies, it is easiest to use the unmodified binaries from the Alpine Linux\nrepository as described in the previous section. However, it is also possible\nto cross-compile applications on non-musl based Linux distributions (e.g.\nUbuntu) and create a minimal disk image that only contains the application and\nits dependencies. An example of how to cross-compile a C application and create\nthe corresponding disk image can be found in `samples/helloworld`. To build the\ndisk image and execute the application with SGX-LKL run:\n```\nmake sgxlkl-disk.img\nsgx-lkl-run-oe --hw-debug sgxlkl-disk.img /app/helloworld\n```\n\nRun the following command in `samples/miniroot` to see a number of other\napplications you should be able to execute. Keep in mind that SGX-LKL currently \ndoes not support the `fork()` system call, so multi-process applications will not work.\n\n```\nsgx-lkl-run-oe --hw-debug ./sgxlkl-miniroot-fs.img /bin/ls /usr/bin\n```\n\nE. Configuring SGX-LKL-OE parameters\n------------------------------------\n\n### 1. Enclave size\n\n_To be added_\n\n### 2. Enclave signing\n\n_To be added_\n\n### 3. Other configuration options\n\nSGX-LKL-OE has a number of other configuration options e.g. for configuring the\nin-enclave scheduling, network configuration, or debugging/tracing. To see all\noptions, run:\n```\nsgx-lkl-run-oe --help\n```\n\nNote that for the debugging options to have an effect, SGX-LKL must be built\nwith `DEBUG=true`.\n\nF. Remote attestation\n---------------------\n\n_To be added_\n\nG. Debugging SGX-LKL-OE and applications\n-----------------------------------------\n\nSee the [Debugging](docs/Debugging.md) page for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsds%2Fsgx-lkl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsds%2Fsgx-lkl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsds%2Fsgx-lkl/lists"}