qubes-mirage-firewall/README.md

113 lines
6.0 KiB
Markdown
Raw Normal View History

2015-12-30 09:52:24 +00:00
# qubes-mirage-firewall
2016-01-01 15:21:28 +00:00
A unikernel that can run as a QubesOS ProxyVM, replacing `sys-firewall`.
2015-12-30 09:52:24 +00:00
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.
2015-12-30 09:52:24 +00:00
2016-01-02 08:34:39 +00:00
See [A Unikernel Firewall for QubesOS][] for more details.
2017-01-09 16:45:16 +00:00
## Build (with Docker)
Clone this Git repository and run the `build-with-docker.sh` script:
sudo yum install docker
sudo systemctl start docker
git clone https://github.com/talex5/qubes-mirage-firewall.git
cd qubes-mirage-firewall
sudo ./build-with-docker.sh
2017-01-09 16:45:16 +00:00
This took about 10 minutes on my laptop (it will be much quicker if you run it again).
## Build (without Docker)
2016-01-01 15:21:28 +00:00
1. Install build tools:
2015-12-30 09:52:24 +00:00
2017-01-09 16:45:16 +00:00
sudo yum install git gcc m4 0install patch ncurses-devel tar bzip2 unzip make which findutils xen-devel
2016-01-01 15:21:28 +00:00
mkdir ~/bin
0install add opam http://tools.ocaml.org/opam.xml
2017-03-02 14:52:55 +00:00
opam init --comp=4.04.0
2016-01-01 15:21:28 +00:00
eval `opam config env`
2. Install mirage, pinning a few unreleased features we need:
opam pin add -y mirage-nat 'https://github.com/talex5/mirage-nat.git#lru'
2016-01-01 15:21:28 +00:00
opam install mirage
3. Build mirage-firewall:
git clone https://github.com/talex5/qubes-mirage-firewall.git
cd qubes-mirage-firewall
2017-03-18 11:29:55 +00:00
mirage configure -t xen
2016-01-01 15:21:28 +00:00
make
2017-01-09 16:45:16 +00:00
## Deploy
2016-01-01 15:21:28 +00:00
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.
2015-12-30 09:52:24 +00:00
2017-03-18 11:29:55 +00:00
$ test-mirage qubes_firewall.xen mirage-firewall
2015-12-30 09:52:24 +00:00
Waiting for 'Ready'... OK
2017-03-18 11:29:55 +00:00
Uploading 'qubes_firewall.xen' (5901080 bytes) to "mirage-firewall"
2015-12-30 09:52:24 +00:00
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.
gnttab_stubs.c: initialised mini-os gntmap
2017-03-18 11:29:55 +00:00
2017-03-18 11:32:37 -00:00: INF [qubes.rexec] waiting for client...
2017-03-18 11:32:37 -00:00: INF [qubes.gui] waiting for client...
2017-03-18 11:32:37 -00:00: INF [qubes.db] connecting to server...
2017-03-18 11:32:37 -00:00: INF [qubes.db] connected
2017-03-18 11:32:37 -00:00: INF [qubes.rexec] client connected, using protocol version 2
2017-03-18 11:32:37 -00:00: 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(pc105)\"\t};\n};"
2017-03-18 11:32:37 -00:00: INF [qubes.gui] client connected (screen size: 6720x2160)
2017-03-18 11:32:37 -00:00: INF [unikernel] Qubes agents connected in 0.095 s (CPU time used since boot: 0.008 s)
2017-03-18 11:32:37 -00:00: INF [net-xen:frontend] connect 0
2017-03-18 11:32:37 -00:00: INF [memory_pressure] Writing meminfo: free 6584 / 17504 kB (37.61 %)
Note: cannot write Xen 'control' directory
2017-03-18 11:32:37 -00:00: INF [net-xen:frontend] create: id=0 domid=1
2017-03-18 11:32:37 -00:00: INF [net-xen:frontend] sg:true gso_tcpv4:true rx_copy:true rx_flip:false smart_poll:false
2017-03-18 11:32:37 -00:00: INF [net-xen:frontend] MAC: 00:16:3e:5e:6c:11
2017-03-18 11:32:37 -00:00: WRN [command] << Unknown command "QUBESRPC qubes.SetMonitorLayout dom0"
2017-03-18 11:32:38 -00:00: INF [ethif] Connected Ethernet interface 00:16:3e:5e:6c:11
2017-03-18 11:32:38 -00:00: INF [arpv4] Connected arpv4 device on 00:16:3e:5e:6c:11
2017-03-18 11:32:38 -00:00: INF [dao] Watching backend/vif
2017-03-18 11:32:38 -00:00: INF [qubes.db] got update: "/qubes-netvm-domid" = "1"
2015-12-30 09:52:24 +00:00
# LICENSE
2017-03-18 11:29:55 +00:00
Copyright (c) 2017, Thomas Leonard
2015-12-30 09:52:24 +00:00
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
[test-mirage]: https://github.com/talex5/qubes-test-mirage
[mirage-qubes]: https://github.com/talex5/mirage-qubes
2016-01-02 08:34:39 +00:00
[A Unikernel Firewall for QubesOS]: http://roscidus.com/blog/blog/2016/01/01/a-unikernel-firewall-for-qubesos/