# From OpenBSD to Linux: How Pledge Can Enhance Linux Security

Imagine you've downloaded a new binary from the internet, such as the `ls` command. While it's a harmless application, its malicious counterparts could be designed to compromise your system. Binary files are notoriously difficult to trust, and running them on your system without proper security measures can lead to devastating consequences like hijacking your sensitive files, clipboard information, or interfering with existing processes.

Is it reasonable to expect an application like `ls` to require a network connection simply to list the files in the current working directory? Probably not. That's where Pledge comes into play – a tool that restricts system calls a program can make, allowing you to run applications within defined security parameters. As a native feature of OpenBSD systems, Pledge may not be officially supported on Linux yet, but we'll explore how to utilize it on your Linux systems using the remarkable work done by Justine Tunney.

Justine is the core developer behind Cosmopolitan Libc, which bridges compilation for 7 different platforms (Linux, Mac, Windows, FreeBSD, OpenBSD, NetBSD, and BIOS) at once. With this innovative tool, she successfully ported OpenBSD Pledge to Linux. You can explore her blog to learn more about the Actually Portable Executable (APE) concept – a single binary that can run on 7 different platforms.

### Introducing Pledge

Pledge follows the Least Privilege model, which prevents programs from misusing system resources and limits the damage caused by malicious applications. This security approach is intuitive and easy to use, making it an attractive alternative to Linux's seccomp and apparmor.

With Pledge on your Linux system, you can provide more granular control over what processes can do within environments, adding an extra layer of defense against potential threats.

### Installing and Configuring Pledge

To start using pledge, follow these steps:

1. **Download the pledge binary**: Head to [http://justine.lol/pledge/pledge-1.8.com](http://justine.lol/pledge/pledge-1.8.com) and download the `pledge-1.8.com` file. Rename it to `pledge.com`. 2. **Make it executable**: Run the command `chmod +x pledge.com` to make the binary executable. 3. **Add pledge to your system path**: Move the `pledge.com` file to the standard `/usr/local/bin/` location and assign permissions (promises) to it using the `-p` flag.

### Promises: The Key to Granular Security

When you run an application with Pledge, you can specify promises using the `-p` flag. These promises define the system calls a program can make, allowing you to control its behavior within defined security parameters.

For example, let's take the `curl` tool, which requires DNS and URL parsing system calls. By specifying promises, we can see if these are acceptable or not. You can explore the list of supported promises in Justine's blog for more information.

### Example Use Case: Securing Curl with Pledge

Let's test whether curl can talk to HTTPS-enabled websites using Pledge: ```bash curl -p "dns,dns resolved,netloc" https://example.com ``` In this example, we specify promises `dns`, `dns resolved`, and `netloc` to allow the program to perform DNS lookups, resolve the domain, and access the network location. You can adjust these promises according to your specific requirements.

By utilizing Pledge on your Linux system, you can enjoy a more secure environment with granular control over what processes can do within defined security parameters. This is especially useful for applications that require precise permission management, such as web development or CI/CD pipelines.