Tutorial: Performant and Secure Applications on the Internet Computer
2022, March 1 @ ASPLOS, Lausanne, Switzerland
In May 2021 the Internet Computer, a web-speed smart contract and app platform, went live. After less than 6 months, the internet computer hosts more than 12'000 smart contract apps and serves more than 100’000 users, providing a plethora of services, ranging from social media and chat applications to DeFi and NFTs. Thanks to its architecture and support for new service and business models, the internet computer has the potential to change how we develop, host and use apps.
In this tutorial we host sessions on developing apps that offer enhanced security on this decentralized platform, how such smart contracts are executed securely in a sandboxed environmentand how trust can be increased further with reproducible builds.
Trustless Web Applications on the Internet Computer (14:00 - 15:00 GMT+1)
Speaker: Kyle PeacockSummary: This tutorial will show how the DFINITY Foundation’s research can be practically applied to power a fully decentralized application development stack, colloquially known as Web 3.0. Come learn how you can write an app thats offers enhanced security on a decentralized and trustless network, while maintaining performant reads and writes for users
This demonstration will cover:
- Serving web content on a Certified Asset smart contract
- Anonymous authentication without usernames or passwords, using Internet Identity
- Access control strategies for anonymous users
Bio: Kyle has taken on the role of team lead for the SDK team, within a year of joining DFINITY as a frontend engineer. Kyle takes pride in his ability to break down complex topics and to explain them in an intuitive and conversational manner. His passion is for user-centered application design, particularly when it comes to accessibility.
Smart contract sandboxing (15:00 - 17:00 GMT+1, with a coffee break at 16:00-16:30)
Speaker: Helge BahmannSummary: Smart contract code execution is confined by the WebAssembly runtime. The constraints of the runtime are enforced by a) limiting access through the system API and b) correctness of the JIT-compiled native code derived from the WebAssembly code. The full implementation correctness cannot necessarily be fully assumed due to the complexity of the components. Additionally, even with a perfectly correctly operating JIT compiler, the generated native code executes in the context of its host process. This makes it indistinguishable from all other code executing in the same process to the CPU. As a consequence, the CPU fundamentally cannot be stopped from performing speculative access to any memory reachable to the host process. This can be abused by completely legitimate WebAssembly code to trigger such speculative access. Timing measurements against code execution paths may then reveal secrets.
The tutorial will cover the following topics:
- IC and WebAssembly How the IC executes canisters and Wasm, how it manages state, memory access tracking and cycles accounting.
- WebAssembly security model: A detailed look at the Wasm security model and how access restrictions are enforced on the natively compiled code. Conditions for maintaining the security model are discussed, as are some breaches that allow bypassing it.
- Side channel attacks and threat model: How side channel attacks can be mounted through Wasm code and what data could be accessed, conditions for a successful attack. The IC needs to protect against malicious Wasm code, this will discuss what an attacker could (want to) accomplish and how to counter these threads.
- Process separation: Changing an existing in-process execution design to allow out-of-process execution is a major software engineering feat, and hence encountered in many projects. This will look at issues encountered, how to design for sandboxing & strategies for transition and how to organize IPC, how safe sharing of bulk data via shared memory can be accomplished and possible pitfalls that may violate trust assumptions.
- Enforcing process isolation: How to ensure that the different processes cannot interfere with each other. This discusses different techniques available for sandboxing processes, from system call filtering to mandatory access control.
- Hardening: To defeat real-world attacks it helps to make an attacker's life difficult with various mechanisms: Enforcing W^X and design implications of separate compilation, controlled process lifecycles and denial of communication channels.
- Performance considerations: Sandboxing may affect performance but this can be minimized through careful design. Design constraints in optimizing for performance will be discussed, how to bring performance to parity with in-process execution or even surpass it.
Bio: Helge is a researcher at DFINITY foundation and focuses on operating systems and system security measures. Other interests include compilers, functional intermediate representations, CPU architectures and formal methods in software construction. He holds a PhD in computer science and has previously worked at Secunet and Google. In the past 20 years he has been working on and off on various parts of the Linux OS environment.
Reproducible Builds or “What Code is this Smart Contract Running?” (17:00 - 18:00 GMT+1)
Speaker: Ognjen MaricSummary: Computer programs are usually written in a high-level language, but then compiled to a lower-level language in order to be executed. Software auditors generally look at the high-level source code. This leaves a gap: there is generally no guarantee that the deployed (compiled) artifact is really the result of compiling the audited source code, and thus no guarantee that the audit results apply to the deployed artifact. Reproducible builds fill this gap: they allow any third party with access to the source code to verify that a provided artifact really results from compiling the source. Reproducible builds are especially important in the context of decentralized finance, where users transfer the control of their digital assets to a smart contract, and have to trust that the smart contract will operate according to the claims made by its authors and auditors.
In this tutorial, we will examine the landscape of reproducible build tools for the official supported languages on the Internet Computer: Motoko, Rust, and Javascript. We will also cover other, more general tools useful for reproducible builds, such as Docker and Nix.
This tutorial will also have a hands-on part: we will see how to use these tools in practice to write a canister that can be built reproducibly. To follow along, you will need a Linux or Mac machine, as the Canister SDK is currently only supported on these platforms. Furthermore, we will make extensive use of the following tools:
- The canister SDK itself, which you can obtain as follows
sh -ci "$(curl -fsSL https://smartcontracts.org/install.sh)"
- npm
- Docker. On Mac, an easy way to install Docker is using colima.
Bio: Ognjen is a researcher at DFINITY foundation, focusing on formal methods and security. His other areas of interest include distributed systems and programming languages. He holds a PhD in formal methods from ETH Zurich, and has previously worked at Digital Asset, designing, verifying and implementing security protocols.