Skip to content

Commit

Permalink
feat: disposable mirage firewall
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-grande committed Jan 12, 2024
1 parent e2f44fb commit 5805bd7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 13 deletions.
11 changes: 6 additions & 5 deletions salt/sys-mirage-firewall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Mirage Firewall in Qubes OS.

## Description

Creates a Mirage Firewall qube named "sys-mirage-firewall". It is an OCaml
program compiled to run as an operating system kernel, in this case, a
Creates a Mirage Firewall qube named "disp-sys-mirage-firewall". It is an
OCaml program compiled to run as an operating system kernel, in this case, a
MirageOS unikernel replacement for the default firewall (sys-firewall). It
pulls in just the code it needs as libraries.

Expand Down Expand Up @@ -42,19 +42,20 @@ qubesctl state.apply sys-mirage-firewall.create

## Usage

As a started, set qubes `netvm` to `sys-mirage-firewall`:
As a started, set qubes `netvm` to `disp-sys-mirage-firewall`:
```sh
qvm-prefs --set QUBE netvm sys-mirage-firewall
qvm-prefs --set QUBE netvm disp-sys-mirage-firewall
```

To test the firewall, apply rules with `qvm-firewall`.

For monitoring, inspect the Unikernel console:
```sh
sudo xl console sys-mirage-firewall
sudo xl console disp-sys-mirage-firewall
```
Exit the console with `Ctrl-]`.

## Credits

- [Unman](https://github.com/unman/shaker/tree/main/mirage)
- [Thien Tran](https://privsec.dev/posts/qubes/firewalling-with-mirageos-on-qubes-os/)
58 changes: 50 additions & 8 deletions salt/sys-mirage-firewall/create.sls
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{#
SPDX-FileCopyrightText: 2022 Thien Tran <contact@tommytran.io>
SPDX-FileCopyrightText: 2023 unman <unman@thirdeyesecurity.org>
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>

SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: MIT
#}

{%- from "qvm/template.jinja" import load -%}
Expand Down Expand Up @@ -46,24 +47,65 @@ the chain (sys-net).
- makedirs: True
{% load_yaml as defaults -%}
name: sys-mirage-firewall
name: tpl-sys-mirage-firewall
force: True
require:
- file: sys-mirage-firewall-save-version
- file: sys-mirage-firewall-save-version
present:
- class: StandaloneVM
- label: orange
- class: TemplateVM
- label: black
prefs:
- virt_mode: pvh
- label: black
- memory: 64
- maxmem: 64
- vcpus: 1
- kernel: mirage-firewall
- kernelopts: ""
{%- endload %}
{{ load(defaults) }}
{% load_yaml as defaults -%}
name: dvm-sys-mirage-firewall
force: True
require:
- qvm: tpl-sys-mirage-firewall
present:
- template: tpl-sys-mirage-firewall
- label: orange
prefs:
- template: tpl-sys-mirage-firewall
- label: orange
- netvm: {{ netvm }}
- memory: 64
- maxmem: 64
- vcpus: 1
- provides-network: True
- template_for_dispvms: True
features:
- enable:
- service.qubes-firewall
- no-default-kernelopts
{%- endload %}
{{ load(defaults) }}
{% load_yaml as defaults -%}
name: disp-sys-mirage-firewall
force: True
require:
- qvm: tpl-sys-mirage-firewall
present:
- class: DispVM
- template: dvm-sys-mirage-firewall
- label: orange
prefs:
- template: dvm-sys-mirage-firewall
- label: orange
- netvm: {{ netvm }}
- memory: 64
- maxmem: 64
- vcpus: 1
- provides-network: True
- default_dispvm: ""
- kernel: mirage-firewall
- kernelopts: ''
features:
- enable:
- service.qubes-firewall
Expand Down

0 comments on commit 5805bd7

Please sign in to comment.