A network service needs to be resilient against malicious input from the internet. Specially programs written in C are prone to memory corruption bugs which are the basis for remote code execution attacks. Memory-safe languages solve this problem for application code running in userspace. The TCP/IP network stack however runs in the operating system kernel, which is written in C and vulnerable to memory corruption. Therefore, this work explored moving the TCP/IP stack into the memory-safe userspace process while providing a compatible API. The process should share an IP with the kernel and integrate with the kernel's loopback interface. This solution keeps the benefits of a full-featured OS and does not impose different IPs per process or changes in the application logic. I analyzed the requirements for deploying memory-safe TCP/IP services along with the kernel network stack. The existing switching solutions for userspace network stacks do not meet these requirements because they do not handle untrusted packets in a memory-safe language and expose the kernel network stack to untrusted packets. I present a memory-safe L4 software switch that connects multiple userspace network stacks and the host kernel network stack. The switch allows the kernel and userspace network stacks to share an IP address. It also firewalls the host kernel network stack while supporting outgoing connections for updates. To make memory-safe userspace networking easily usable I developed a socket library for Rust. Its in-app TCP/IP stack provides the same socket API types as the standard library and is based on smoltcp. The combination of a memory-safe userspace switch and userspace TCP/IP stack expands the memory-safety of existing Rust web services to the TCP/IP layer with low porting efforts.
네트워크 서비스는 악성 입력에 대해 내구성을 가져야 하는데, 티시피/아이피는 씨로 구현되어 있고 오에스 커널에서 실행되어 메모리 손상 버그에 취약하다. 따라서 본 연구는 호환 가능한 에이피아이를 제공하면서 티시피/아이피 스택을 메모리-안전한 사용자 프로세스로 이동시키는 방법을 소개한다. 기존 방식들은 패킷을 메모리-안전 언어로 처리하지 않아 커널 네트워크 스택이 취약성을 가지므로, 사용자공간 네트워크 스택과 커널 네트워크 스택을 연결하여 아이피 주소를 공유하는 메모리-안전 레이어4 소프트웨어 스위치를 제시하며 이를 통해 방화벽으로 커널 네트워크 스택을 보호한다. 또한 메모리-안전한 사용자공간 네트워킹을 위해 스몰티시피를 기반으로 러스트용 소켓 라이브러리를 개발했으며 표준 라이브러리와 같은 타입의 소켓 에이피아이를 제공한다. 이러한 메모리-안전 사용자공간 스위치와 사용자공간 티시피/아이피 스택을 결합하여 적은 노력으로 기존 러스트 웹 서비스의 메모리안전성을 티시피/아이피 계층으로 확장시킬 수 있다.