Added pledge(2) and unveil(2) system calls to improve security on OpenBSD. #13

Merged
solderpunk merged 5 commits from kvothe/molly-brown:master into master 2023-02-08 17:54:30 +00:00
Contributor

Hi solderpunk!

I added some security features to the OpenBSD implementation of molly-brown. There's a new generic security.go file that provides the enableSecurityRestrictions() function, which is a no-op for other operating systems. When compiled on OpenBSD, security_openbsd.go is instead compiled, which restricts system calls with the pledge(2) system call and restricts filesystem access with the unveil(2) system call.

I've tested these cases:

  • plain gemini server, no CGI configured. Any attempt to start a process and the molly brown server is aborted by the OS.
  • CGI gemini server. CGI path globs are unveiled as executable and molly brown is able to start those processes. Processes that haven't been whitelisted aren't executable by molly brown.
  • SCGI gemini server. The unix sockets specified in the config file are unveiled as read/write and molly brown is able to communicate with those processes.

(S)CGI processes that molly brown speaks with aren't restricted in the same manner and should restrict themselves prior to handling user input, but that's out of the scope of these changes.

Hope you dig!

Hi solderpunk! I added some security features to the OpenBSD implementation of molly-brown. There's a new generic security.go file that provides the enableSecurityRestrictions() function, which is a no-op for other operating systems. When compiled on OpenBSD, security_openbsd.go is instead compiled, which restricts system calls with the [pledge(2)](https://man.openbsd.org/pledge.2) system call and restricts filesystem access with the [unveil(2)](https://man.openbsd.org/unveil.2) system call. I've tested these cases: * plain gemini server, no CGI configured. Any attempt to start a process and the molly brown server is aborted by the OS. * CGI gemini server. CGI path globs are unveiled as executable and molly brown is able to start those processes. Processes that haven't been whitelisted aren't executable by molly brown. * SCGI gemini server. The unix sockets specified in the config file are unveiled as read/write and molly brown is able to communicate with those processes. (S)CGI processes that molly brown speaks with aren't restricted in the same manner and should restrict themselves prior to handling user input, but that's out of the scope of these changes. Hope you dig!
solderpunk merged commit b16a8584a6 into master 2023-02-08 17:54:30 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: solderpunk/molly-brown#13
No description provided.