A Mirage firewall VM for QubesOS
Go to file
Thomas Leonard cd917bab7f Fix travis
2016-02-23 11:48:13 +00:00
_tags Move NAT code to router and add DNS redirects 2015-12-30 19:34:04 +00:00
.gitignore Initial import 2015-12-30 11:07:17 +00:00
.merlin Initial import 2015-12-30 11:07:17 +00:00
.travis.yml Fix travis 2016-02-23 11:48:13 +00:00
cleanup.ml Initial import 2015-12-30 11:07:17 +00:00
cleanup.mli Initial import 2015-12-30 11:07:17 +00:00
client_eth.ml Update to new Logs API 2016-01-08 11:40:11 +00:00
client_eth.mli Rationalised firewall rules syntax 2016-01-01 11:32:57 +00:00
client_net.ml Keep track of transmit queue lengths 2016-01-17 11:42:40 +00:00
client_net.mli Moved client networking to its own module 2015-12-30 13:52:56 +00:00
command.ml Update to new Logs API 2016-01-08 11:40:11 +00:00
config.ml Use mirage-logs library for log reporter 2016-01-11 16:40:26 +00:00
dao.ml Log packet details when dropping 2015-12-31 09:56:58 +00:00
dao.mli Minor cleanups 2015-12-30 14:32:59 +00:00
firewall.ml Reduce logging verbosity 2016-02-10 08:34:17 +00:00
firewall.mli Move NAT code to router and add DNS redirects 2015-12-30 19:34:04 +00:00
frameQ.ml Keep track of transmit queue lengths 2016-01-17 11:42:40 +00:00
frameQ.mli Keep track of transmit queue lengths 2016-01-17 11:42:40 +00:00
Makefile.user Add 'make tar' build target 2016-01-01 15:49:06 +00:00
memory_pressure.ml Update to new Logs API 2016-01-08 11:40:11 +00:00
memory_pressure.mli Report current memory use to XenStore 2016-01-02 16:14:02 +00:00
packet.ml Rationalised firewall rules syntax 2016-01-01 11:32:57 +00:00
README.md Remove mirage-logs pin 2016-02-19 09:47:44 +00:00
router.ml Try to avoid running out of memory on NAT reset 2016-01-31 21:03:35 +00:00
router.mli Reset NAT table if memory gets low 2016-01-02 15:50:05 +00:00
rules.ml Rationalised firewall rules syntax 2016-01-01 11:32:57 +00:00
unikernel.ml Survive death of GUId connection 2016-01-17 13:19:40 +00:00
uplink.ml Keep track of transmit queue lengths 2016-01-17 11:42:40 +00:00
uplink.mli Moved uplink code to its own module 2015-12-30 14:22:46 +00:00
utils.ml Removed unused function 2016-01-02 15:27:25 +00:00

qubes-mirage-firewall

A unikernel that can run as a QubesOS ProxyVM, replacing sys-firewall. It uses the mirage-qubes library to implement the Qubes protocols.

Note: This firewall ignores the rules set in the Qubes GUI. See rules.ml for the actual policy.

See A Unikernel Firewall for QubesOS for more details.

To build (tested by creating a fresh Fedora 23 AppVM in Qubes):

  1. Install build tools:

     sudo yum install git gcc m4 0install patch
     mkdir ~/bin
     0install add opam http://tools.ocaml.org/opam.xml
     opam init --comp=4.02.3
     eval `opam config env`
    
  2. Install mirage, pinning a few unreleased features we need:

     opam pin add -y mirage-xen 'https://github.com/talex5/mirage-platform.git#mm'
     opam pin add -y tcpip https://github.com/mirage/mirage-tcpip.git
     opam pin add -y mirage-nat 'https://github.com/talex5/mirage-nat.git#simplify-checksum'
     opam install mirage
    
  3. Build mirage-firewall:

     git clone https://github.com/talex5/qubes-mirage-firewall.git
     cd qubes-mirage-firewall
     mirage configure --xen
     make
    

If you want to deploy manually, use make tar to create mirage-firewall.tar.bz2 and unpack this in dom0, inside /var/lib/qubes/vm-kernels/. e.g. (if dev is the AppVM where you built it):

    [tal@dom0 ~]$ cd /var/lib/qubes/vm-kernels/
    [tal@dom0 vm-kernels]$ qvm-run -p dev 'cat qubes-mirage-firewall/mirage-firewall.tar.bz2' | tar xjf -

The tarball contains vmlinuz, which is the unikernel itself, plus a couple of dummy files that Qubes requires.

For development, use the test-mirage scripts to deploy the unikernel (mir-qubes-firewall.xen) from your development AppVM. e.g.

$ test-mirage mir-firewall.xen mirage-firewall
Waiting for 'Ready'... OK
Uploading 'mir-qubes-firewall.xen' (4843304 bytes) to "mirage-firewall"
Waiting for 'Booting'... OK
--> Loading the VM (type = ProxyVM)...
--> Starting Qubes DB...
--> Setting Qubes DB info for the VM...
--> Updating firewall rules...
--> Starting the VM...
--> Starting the qrexec daemon...
Waiting for VM's qrexec agent.connected
--> Starting Qubes GUId...
Connecting to VM's GUI agent: .connected
--> Sending monitor layout...
--> Waiting for qubes-session...
Connecting to mirage-firewall console...
MirageOS booting...
Initialising timer interface
Initialising console ... done.
Netif: add resume hook
gnttab_stubs.c: initialised mini-os gntmap
2015-12-30 10:04.42: INF [qubes.rexec] waiting for client...
2015-12-30 10:04.42: INF [qubes.gui] waiting for client...
2015-12-30 10:04.42: INF [qubes.db] connecting to server...
2015-12-30 10:04.42: INF [qubes.db] connected
2015-12-30 10:04.42: INF [qubes.rexec] client connected, using protocol version 2
2015-12-30 10:04.42: INF [qubes.db] got update: "/qubes-keyboard" = "xkb_keymap {\n\txkb_keycodes  { include \"evdev+aliases(qwerty)\"\t};\n\txkb_types     { include \"complete\"\t};\n\txkb_compat    { include \"complete\"\t};\n\txkb_symbols   { include \"pc+gb+inet(evdev)\"\t};\n\txkb_geometry  { include \"pc(pc104)\"\t};\n};"
2015-12-30 10:04.42: INF [qubes.gui] client connected (screen size: 6720x2160)
2015-12-30 10:04.42: INF [unikernel] agents connected in 0.052 s (CPU time used since boot: 0.007 s)
Netif.connect 0
Netfront.create: id=0 domid=1
 sg:true gso_tcpv4:true rx_copy:true rx_flip:false smart_poll:false
MAC: 00:16:3e:5e:6c:0b
ARP: sending gratuitous from 10.137.1.13
2015-12-30 10:04.42: INF [application] Client (internal) network is 10.137.3.0/24
ARP: transmitting probe -> 10.137.1.1
2015-12-30 10:04.42: INF [net] Watching backend/vif
2015-12-30 10:04.42: INF [qubes.rexec] Execute "user:QUBESRPC qubes.SetMonitorLayout dom0\000"
2015-12-30 10:04.42: WRN [command] << Unknown command "QUBESRPC qubes.SetMonitorLayout dom0"
2015-12-30 10:04.42: INF [qubes.rexec] Execute "root:QUBESRPC qubes.WaitForSession none\000"
2015-12-30 10:04.42: WRN [command] << Unknown command "QUBESRPC qubes.WaitForSession none"
2015-12-30 10:04.42: INF [qubes.db] got update: "/qubes-netvm-domid" = "1"
ARP: retrying 10.137.1.1 (n=1)
ARP: transmitting probe -> 10.137.1.1
ARP: updating 10.137.1.1 -> fe:ff:ff:ff:ff:ff

LICENSE

Copyright (c) 2015, Thomas Leonard All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. gg