<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>GNUcode.me</title><id>https://gnucode.me/feeds/tags/OpenBSD security correctness.xml</id><subtitle>Tag: OpenBSD security correctness</subtitle><updated>2024-05-01T13:21:27Z</updated><link href="https://gnucode.me/feeds/tags/OpenBSD security correctness.xml" rel="self" /><link href="https://gnucode.me" /><entry><title>OpenBSD's Philosophy</title><id>https://gnucode.me/openbsds-philosophy.html</id><author><name>Joshua Branson</name><email>jbranso@dismail.de</email></author><updated>2024-04-17T18:00:00Z</updated><link href="https://gnucode.me/openbsds-philosophy.html" rel="alternate" /><content type="html">&lt;p&gt;I have talked about OpenBSD before in this blog, and I recently
watched a talk by OpenBSD's leader Theo de Raadt about &lt;code&gt;pledge ()&lt;/code&gt; and
&lt;code&gt;arc4random()&lt;/code&gt;. He described OpenBSD's design philosophy so well, that
I wanted to write it down.  You should definitely take some time to
hear Theo speak.  He's entertaining, and his talks are super awesome!&lt;/p&gt;&lt;p&gt;So a long time ago (early 90s ?), a cracker (1) broke into Theo's
OpenBSD's syslog.  This got Theo to examine OpenBSD's source code to
fix any lingering bugs, and he found a lot.  He realized that trying
to constantly examine source code to prevent bugs is a never ending
process.  He wanted to ensure code quality got better over time.  He
envision an operating system that that enforced code correctness like
the below ASCII art shows.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;__________________________
| Poorly written programs |
| crash on OpenBSD.       |
| ----------------------  |
| | Correctly written  |  |
| | programs run well  |  |
| | on OpenBSD.        |  |
| ----------------------  |
---------------------------&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;He wondered if he could create features to slightly narrow the things
that applications could do.  When poorly written programs run on
OpenBSD, they crash in deterministic ways, but correct programs work
just fine.  Theo also made sure that &amp;quot;mitigations&amp;quot;, or checks to ensure
a program's correctness, &lt;em&gt;cannot&lt;/em&gt; be turned off on OpenBSD.  If a user
or a project manager has a problem with an application not working on
OpenBSD due to a toggleable security feature, then the user or project
manager will just turn off the feature.  So to ensure that programs
abide by the mitigations, OpenBSD enforces their security policies.&lt;/p&gt;&lt;p&gt;OpenBSD also makes it easy to use their security features.  If they
introduce a policy that is manatory, they try to make the API easy to
use.  If you create a security policy that is hard for the programmer
to use, then the security policy won't be used.&lt;/p&gt;&lt;p&gt;When OpenBSD creates a new mitigation, their application porters port
3rd party software packages to OpenBSD.  Typically these changes find
their way into the upstream packages.  What's awesome is that usually
other operating systems start to use OpenBSD mitigations on their
systems 5 years after OpenBSD introduced them.  Windows, Mac, and
Linux applications all benefit from the strict standards that OpenBSD
creates. Theo's talks gave two examples for this: &lt;code&gt;pledge ()&lt;/code&gt; and
&lt;code&gt;arc4random ()&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Here's a question for you.  How do you get random data?  Well you read
&lt;code&gt;/dev/random&lt;/code&gt; of course.  Simple.  Easy.  Done.  That used to be how
things were handled.  Apparently reading from &lt;code&gt;/dev/random&lt;/code&gt; has some
limitations that Theo mentioned.  Can you read from &lt;code&gt;/dev/random&lt;/code&gt;
inside the kernel?  Inside a library?  In your libc?  Reading from
&lt;code&gt;/dev/random&lt;/code&gt; is not perfect.  Theo wanted to make something better.&lt;/p&gt;&lt;p&gt;OpenBSD created &lt;code&gt;arc4random ()&lt;/code&gt; as a better source of entropy.  It is
a C function that almost any application can call (even the kernel),
most of the time.  This lets many applications, libraries, etc. easily
use random numbers.  What's surprizing to me is that many operating
systems use &lt;code&gt;arc4random ()&lt;/code&gt; or a function like it, so that more
applictions can easily request random data.  This function (or one
like it) exists on your Android phone, iPhone, iMac, and sort of on
Linux thanks to OpenBSD.&lt;/p&gt;&lt;p&gt;What's &lt;code&gt;pledge ()&lt;/code&gt; ?  Oh ho, let me tell you!  Let's take a look at a
typical program.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-C&quot;&gt;int main () {

  initialize_stuff();
  
  for (;;) {
    ;; let's run the program
  }

}&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Most programs have an initialization phase followed by a loop, in
which the application runs.  The OpenBSD team realized that the
initialize phase uses most of the system calls.  After the initialize
phase, the program typically needs less system calls.  OpenBSD's
&lt;code&gt;pledge ()&lt;/code&gt; was created in response to this pattern present in most
programs.&lt;/p&gt;&lt;p&gt;&lt;code&gt;pledge ()&lt;/code&gt; is a security call, by which an application tells the
kernel, &amp;quot;I pledge to only do these things and no other.&amp;quot;  For example,
&amp;quot;I pledge to only output text&amp;quot;.  Or &amp;quot;I pledge to only access the
internet and output text.&amp;quot;  If the application tries to do something
that it has pledged not to do, then OpenBSD kills the application.&lt;/p&gt;&lt;p&gt;A really interesting blog post that talks about this is at
&lt;a href=&quot;https://justine.lol/pledge/&quot;&gt;justine's blog&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;After watching two of Theo's talks, I am fairly convinced that his
design goals are slowly working to make all POSIX operating systems
more correct and secure.  I used to dual boot Guix System and OpenBSD,
but unfortunately my spare SSD busted.  So for now I am only using
Guix System.  I personally prefer to use Guix System for my linode
server (that powers this blog), because Guix makes it easy to manage
servers.&lt;/p&gt;&lt;p&gt;I wish that the Guix developers could one day create Guix OpenBSD
System, but I have been told that Guix System assumes your libc is
&lt;code&gt;glibc&lt;/code&gt; and that OpenBSD cannot currently make isolated build
environments as well as Linux can.  Also fun fact OpenBSD is not
currently working on reproducible builds.  :)&lt;/p&gt;&lt;p&gt;My two only minor complaints with OpenBSD currently are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I wish OpenBSD supported Wayland. This may happen in 6 months to a
year.  Fingers crossed.&lt;/li&gt;&lt;li&gt;A better filesystem: OpenBSD's FFS (fast file system) works, but it
is possible to lose data in a crash.  Filesystems are &lt;em&gt;really&lt;/em&gt; hard
to get right.  Kent Overstreet has been working on bcachefs for
almost a decade now, and it might soon become one of Linux's best
filesystems (my opinion), so I don't blame OpenBSD for not trying to
create a new next generational filesystem.  Anybody want to spend 10
years of their life creating an awesome filesystem that will
probably only work well on OpenBSD?  One might be able to port
HammerFS to OpenBSD, and a basic read-only port does exist.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you want to try OpenBSD, give it a shot!  It works really well on
most lenovo laptops and most desktop machines.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Nerdy computer people like me use the word &amp;quot;hacker&amp;quot; to mean someone
who builds computer programs, and a &amp;quot;cracker&amp;quot; is someone who breaks
into computer systems.&lt;/li&gt;&lt;/ol&gt;</content></entry></feed>