New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe firewall fallback defaults #3269

Closed
3hhh opened this Issue Nov 1, 2017 · 20 comments

Comments

@3hhh

3hhh commented Nov 1, 2017

Qubes OS version:

4.0rc2

Affected TemplateVMs:

Debian-8, i.e. I only tested without nftables support

Steps to reproduce the behavior:

systemctl stop qubes-firewall on sys-firewall or any proxy VM
Forgetting to start it, a crash or some other issue might also work.

Expected behavior:

Upstream VMs cannot access the Internet (safe fallback).

Actual behavior:

Upstream VMs can access whatever they want on the Internet (unsafe fallback).

General notes:

I had a look at the iptables rules to identify the one causing this behavior, but didn't notice any obvious one. I then tested with traffic and noticed that the counters for this rule increased:
-A INPUT -i lo -j ACCEPT
Maybe it is applied due to the Masquerading?

Starting the qubes-firewall makes everything go back to normal.

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Nov 4, 2017

This may lead to VPN or Tor leaks unless the leaks are prevented further downstream or the user code does some leak prevention in the proxy VM itself.

@adrelanos fyi

3hhh commented Nov 4, 2017

This may lead to VPN or Tor leaks unless the leaks are prevented further downstream or the user code does some leak prevention in the proxy VM itself.

@adrelanos fyi

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 17, 2017

Member

One may decide to not use qubes-firewall service at all - for example this is the case for Whonix Gateway. This means that not starting qubes-firewall should not lead to unusable network (in downstream VMs). But when started, indeed it should have safe fallback for cases like crash.

Member

marmarek commented Nov 17, 2017

One may decide to not use qubes-firewall service at all - for example this is the case for Whonix Gateway. This means that not starting qubes-firewall should not lead to unusable network (in downstream VMs). But when started, indeed it should have safe fallback for cases like crash.

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Nov 18, 2017

One may decide to not use qubes-firewall service at all - for example this is the case for Whonix Gateway. This means that not starting qubes-firewall should not lead to unusable network (in downstream VMs).

(I guess you meant upstream.)

No, the default should lead to unusable network as well from my point of view.
I'd recommend supporting a straightforward opt-in switch for e.g. qvm-prefs that basically enables passthrough for the default firewall settings. Or a special command for qubes-firewall to shut it down in a way that enables passthrough for everything.
Why? It's less prone to misconfigurations, easy to spot (no network) and fix. A few user questions will pop up here and there, but that'll be it. The other default option is more prone to misconfigurations and hard to spot.

Anyway the default firewall rules don't look like this behavior was intended; at least it's far from obvious.

But when started, indeed it should have safe fallback for cases like crash.

That for sure.

3hhh commented Nov 18, 2017

One may decide to not use qubes-firewall service at all - for example this is the case for Whonix Gateway. This means that not starting qubes-firewall should not lead to unusable network (in downstream VMs).

(I guess you meant upstream.)

No, the default should lead to unusable network as well from my point of view.
I'd recommend supporting a straightforward opt-in switch for e.g. qvm-prefs that basically enables passthrough for the default firewall settings. Or a special command for qubes-firewall to shut it down in a way that enables passthrough for everything.
Why? It's less prone to misconfigurations, easy to spot (no network) and fix. A few user questions will pop up here and there, but that'll be it. The other default option is more prone to misconfigurations and hard to spot.

Anyway the default firewall rules don't look like this behavior was intended; at least it's far from obvious.

But when started, indeed it should have safe fallback for cases like crash.

That for sure.

@unman

This comment has been minimized.

Show comment
Hide comment
@unman

unman Nov 18, 2017

Member

(I guess you meant upstream.)

No, the VMs are downstream of the firewall - if it means anything in this context, you have the direction of travel reversed.

I dont think there's need for a special switch here, because I dont see what it adds. ProxyVM configured with default DENY on FORWARD chain, and a FAILUREACTION on firewall service configured to flush the FORWARD chain, (reinstate DENY policy), and then attempt service restart.

imo not starting qubes-firewall should lead to unusable network unless some other service is configured to provide firewall/proxy service, which means that the proxy defaults should be as above.

Member

unman commented Nov 18, 2017

(I guess you meant upstream.)

No, the VMs are downstream of the firewall - if it means anything in this context, you have the direction of travel reversed.

I dont think there's need for a special switch here, because I dont see what it adds. ProxyVM configured with default DENY on FORWARD chain, and a FAILUREACTION on firewall service configured to flush the FORWARD chain, (reinstate DENY policy), and then attempt service restart.

imo not starting qubes-firewall should lead to unusable network unless some other service is configured to provide firewall/proxy service, which means that the proxy defaults should be as above.

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 19, 2017

Member

imo not starting qubes-firewall should lead to unusable network

qubes-firewall service is not data leak prevention mechanism. It is merely a guard against user errors. For network-related leaks prevention, use appropriate tool, like Whonix Gateway, or VPN scripts. Therefore the default (without qubes-firewall service running) should be usable network. If you want otherwise, there are mechanisms to achieve it. Simply adding appropriate rule in FORWARD chain, one time during boot, will do. qubes-firewall service in Qubes 4.0 will not touch your custom rules, it will only make changes in QBS-FORWARD chain (or qubes-firewall table in case of nftables). You can even remove/alter reference to it, to use it some other way.

But even if we'd like to have this behavior changed, it is much too late for 4.0. Such change have great potential to breaking various configurations (there are many: including different distributions, Whonix, VPN scripts etc). And debugging network-related problems, especially on Qubes (multiple VMs involved) is not a fun for many users.

What we can do now, as said earlier, is adjust qubes-firewall to block by default when the service is running (or crashed, but not intentionally stopped). And ensure it is started early enough - before enabling IP forwarding.

Member

marmarek commented Nov 19, 2017

imo not starting qubes-firewall should lead to unusable network

qubes-firewall service is not data leak prevention mechanism. It is merely a guard against user errors. For network-related leaks prevention, use appropriate tool, like Whonix Gateway, or VPN scripts. Therefore the default (without qubes-firewall service running) should be usable network. If you want otherwise, there are mechanisms to achieve it. Simply adding appropriate rule in FORWARD chain, one time during boot, will do. qubes-firewall service in Qubes 4.0 will not touch your custom rules, it will only make changes in QBS-FORWARD chain (or qubes-firewall table in case of nftables). You can even remove/alter reference to it, to use it some other way.

But even if we'd like to have this behavior changed, it is much too late for 4.0. Such change have great potential to breaking various configurations (there are many: including different distributions, Whonix, VPN scripts etc). And debugging network-related problems, especially on Qubes (multiple VMs involved) is not a fun for many users.

What we can do now, as said earlier, is adjust qubes-firewall to block by default when the service is running (or crashed, but not intentionally stopped). And ensure it is started early enough - before enabling IP forwarding.

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Nov 19, 2017

No, the VMs are downstream of the firewall - if it means anything in this context, you have the direction of travel reversed.

Ok maybe that's something whonix specific (didn't use it so far).
For me upstream = direction of source VM, downstream = going to the Internet.

Just noticed that the root cause probably lies with the following forward chain rule
1 84 ACCEPT all -- vif+ * 0.0.0.0/0 0.0.0.0/0

This is somewhat irritating as the entire FORWARD chain looks as follows:

iptables -L -vn
[...]
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  452  266K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
  415 28236 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           
    1    84 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
[...]

So there is a default drop rule on the FORWARD chain, but traffic doesn't ever hit it (I tested with a VPN VM on a debian-8 template, so no nftables interference there - just iptables). The first packet goes to the aforementioned ACCEPT rule and then it hits the RELATED,ESTABLISHED rule.

QBS-FORWARD is empty when the qubes-firewall is stopped and has a default drop rule in the end otherwise.

By the way: Stopping and starting the firewall can lead to then disallowed traffic going through anyway as on-going traffic hits the RELATED,ESTABLISHED allow rule then.

I guess there may also be some leaks during VM shutdown.

Thus I understand that you don't want to provide leak prevention, but I'd suggest to make it at least somewhat more easy to achieve wherever possible.

What we can do now, as said earlier, is adjust qubes-firewall to block by default when the service is running (or crashed, but not intentionally stopped). And ensure it is started early enough - before enabling IP forwarding.

I guess that would be hard: It'll mean that you'll have to try to differentiate between unintended crash and intended shutdown (is e.g. a process SIGTERM an intended shutdown? what about SIGKILL?) and then you'll have to implement the ACCEPT ALL rule only for the intended shutdown. It'll have to be there if the service was not started at all as well though. So yes, the only reasonable option is before IP forwarding.

3hhh commented Nov 19, 2017

No, the VMs are downstream of the firewall - if it means anything in this context, you have the direction of travel reversed.

Ok maybe that's something whonix specific (didn't use it so far).
For me upstream = direction of source VM, downstream = going to the Internet.

Just noticed that the root cause probably lies with the following forward chain rule
1 84 ACCEPT all -- vif+ * 0.0.0.0/0 0.0.0.0/0

This is somewhat irritating as the entire FORWARD chain looks as follows:

iptables -L -vn
[...]
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  452  266K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
  415 28236 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           
    1    84 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
[...]

So there is a default drop rule on the FORWARD chain, but traffic doesn't ever hit it (I tested with a VPN VM on a debian-8 template, so no nftables interference there - just iptables). The first packet goes to the aforementioned ACCEPT rule and then it hits the RELATED,ESTABLISHED rule.

QBS-FORWARD is empty when the qubes-firewall is stopped and has a default drop rule in the end otherwise.

By the way: Stopping and starting the firewall can lead to then disallowed traffic going through anyway as on-going traffic hits the RELATED,ESTABLISHED allow rule then.

I guess there may also be some leaks during VM shutdown.

Thus I understand that you don't want to provide leak prevention, but I'd suggest to make it at least somewhat more easy to achieve wherever possible.

What we can do now, as said earlier, is adjust qubes-firewall to block by default when the service is running (or crashed, but not intentionally stopped). And ensure it is started early enough - before enabling IP forwarding.

I guess that would be hard: It'll mean that you'll have to try to differentiate between unintended crash and intended shutdown (is e.g. a process SIGTERM an intended shutdown? what about SIGKILL?) and then you'll have to implement the ACCEPT ALL rule only for the intended shutdown. It'll have to be there if the service was not started at all as well though. So yes, the only reasonable option is before IP forwarding.

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 19, 2017

Member

So there is a default drop rule on the FORWARD chain, but traffic doesn't ever hit it (I tested with a VPN VM on a debian-8 template, so no nftables interference there - just iptables). The first packet goes to the aforementioned ACCEPT rule and then it hits the RELATED,ESTABLISHED rule.

Yes, generally default firewall (without qubes-firewall involved) is to allow connections coming from connected VMs and deny new connections coming the other way.

Thus I understand that you don't want to provide leak prevention, but I'd suggest to make it at least somewhat more easy to achieve wherever possible.

See for example VPN documentation. All it takes is to insert your rules before default ones:

#    Block forwarding of connections through upstream network device
#    (in case the vpn tunnel breaks):
iptables -I FORWARD -o eth0 -j DROP
iptables -I FORWARD -i eth0 -j DROP
Member

marmarek commented Nov 19, 2017

So there is a default drop rule on the FORWARD chain, but traffic doesn't ever hit it (I tested with a VPN VM on a debian-8 template, so no nftables interference there - just iptables). The first packet goes to the aforementioned ACCEPT rule and then it hits the RELATED,ESTABLISHED rule.

Yes, generally default firewall (without qubes-firewall involved) is to allow connections coming from connected VMs and deny new connections coming the other way.

Thus I understand that you don't want to provide leak prevention, but I'd suggest to make it at least somewhat more easy to achieve wherever possible.

See for example VPN documentation. All it takes is to insert your rules before default ones:

#    Block forwarding of connections through upstream network device
#    (in case the vpn tunnel breaks):
iptables -I FORWARD -o eth0 -j DROP
iptables -I FORWARD -i eth0 -j DROP

marmarek added a commit to marmarek/qubes-core-agent-linux that referenced this issue Nov 20, 2017

network: have safe fallback in case of qubes-firewall crash/error
When qubes-firewall service is started, modify firewall to have "DROP"
policy, so if something goes wrong, no data got leaked.
But keep default action "ACCEPT" in case of legitimate service stop, or
not starting it at all - because one may choose to not use this service
at all.
Achieve this by adding "DROP" rule at the end of QBS-FIREWALL chain and
keep it there while qubes-firewall service is running.

Fixes QubesOS/qubes-issues#3269

marmarek added a commit to marmarek/qubes-core-agent-linux that referenced this issue Nov 20, 2017

network: order qubes-firewall service before enabling IP forwarding
Start qubes-firewall (which will add "DROP by default" rule) before
enabling IP forwarding, to not leave a time slot where some connection
could go around configured firewall.

QubesOS/qubes-issues#3269
@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb8u1 has been pushed to the r4.0 testing repository for the Debian jessie template.
To test this update, first enable the testing repository in /etc/apt/sources.list.d/qubes-*.list by uncommenting the line containing jessie-testing, then use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb8u1 has been pushed to the r4.0 testing repository for the Debian jessie template.
To test this update, first enable the testing repository in /etc/apt/sources.list.d/qubes-*.list by uncommenting the line containing jessie-testing, then use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package core-agent-linux has been pushed to the r4.0 testing repository for the CentOS centos7 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

Automated announcement from builder-github

The package core-agent-linux has been pushed to the r4.0 testing repository for the CentOS centos7 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Nov 21, 2017

Closed

core-agent-linux v4.0.13 (r4.0) #308

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb9u1 has been pushed to the r4.0 testing repository for the Debian stretch template.
To test this update, first enable the testing repository in /etc/apt/sources.list.d/qubes-*.list by uncommenting the line containing stretch-testing, then use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb9u1 has been pushed to the r4.0 testing repository for the Debian stretch template.
To test this update, first enable the testing repository in /etc/apt/sources.list.d/qubes-*.list by uncommenting the line containing stretch-testing, then use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc24 has been pushed to the r4.0 testing repository for the Fedora fc24 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc24 has been pushed to the r4.0 testing repository for the Fedora fc24 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc25 has been pushed to the r4.0 testing repository for the Fedora fc25 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc25 has been pushed to the r4.0 testing repository for the Fedora fc25 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Nov 21, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc26 has been pushed to the r4.0 testing repository for the Fedora fc26 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc26 has been pushed to the r4.0 testing repository for the Fedora fc26 template.
To test this update, please install it with the following command:

sudo yum update --enablerepo=qubes-vm-r4.0-current-testing

Changes included in this update

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Nov 25, 2017

Some bash code to fix the defaults for reference:

#installForwardDropDefaultRule 
#will install a FORWARD default drop rule which is not installed by Qubes in proxy VMs by default (cf. qubes-issue #3269)
#as of 4.0rc2 the FORWARD chain in a debian-8 proxy VM looks as follows (WARNING: Fedora uses nftables and may be different!!!!):
#Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
# pkts bytes target     prot opt in     out     source               destination         
#11781 9086K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
#   93  5196 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           
#    0     0 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0  
#This effectively allows all traffic to eth0 or tun0 by rule #4.
#Thus the below changes this situation to:
#Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
# pkts bytes target     prot opt in     out     source               destination         
#11781 9086K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
#   93  5196 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            <--- NEW
#    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           (might get removed, but is included in the above anyway)
#    0     0 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0  
function installForwardDropDefaultRule {
#this will produce:
# if no match is found --> an empty set of rules
# if the rule was already installed --> a set of rules where it is still installed & which doesn't have duplicates
# if the rules was not installed --> a set of rules where the rule is installed
#IMPORTANT: for any changes, test the aforementioned conditions with text files!!!
#:a --> label, N: include next line in pattern space, $!b except for the last line branch to label a --> read the whole text into pattern space
local insRules=""
insRules="$(iptables-save | sed -r -n ':a;N;$!ba;s/-A FORWARD -j QBS-FORWARD\n(-A FORWARD -j DROP|-A FORWARD -i vif\+ -o vif\+ -j DROP)/-A FORWARD -j QBS-FORWARD\n-A FORWARD -j DROP/p')"
[ $? -ne 0 ] || [ -z "$insRules" ] && errorOut "Failed to install the default drop iptables FORWARD rule! Maybe the Qubes rules changed?! Please investigate asap!"

echo "$insRules" | iptables-restore
#as of 4.0rc2 Qubes doesn't seem to touch the iptables rules anymore after VM start
}

Just make sure to replace errorOut with your favorite error reporting function.

This doesn't just focus on eth0 as in the (imo mediocre) VPN doc, but also applies to e.g. tun0.

3hhh commented Nov 25, 2017

Some bash code to fix the defaults for reference:

#installForwardDropDefaultRule 
#will install a FORWARD default drop rule which is not installed by Qubes in proxy VMs by default (cf. qubes-issue #3269)
#as of 4.0rc2 the FORWARD chain in a debian-8 proxy VM looks as follows (WARNING: Fedora uses nftables and may be different!!!!):
#Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
# pkts bytes target     prot opt in     out     source               destination         
#11781 9086K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
#   93  5196 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           
#    0     0 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0  
#This effectively allows all traffic to eth0 or tun0 by rule #4.
#Thus the below changes this situation to:
#Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
# pkts bytes target     prot opt in     out     source               destination         
#11781 9086K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
#   93  5196 QBS-FORWARD  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            <--- NEW
#    0     0 DROP       all  --  vif+   vif+    0.0.0.0/0            0.0.0.0/0           (might get removed, but is included in the above anyway)
#    0     0 ACCEPT     all  --  vif+   *       0.0.0.0/0            0.0.0.0/0           
#    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0  
function installForwardDropDefaultRule {
#this will produce:
# if no match is found --> an empty set of rules
# if the rule was already installed --> a set of rules where it is still installed & which doesn't have duplicates
# if the rules was not installed --> a set of rules where the rule is installed
#IMPORTANT: for any changes, test the aforementioned conditions with text files!!!
#:a --> label, N: include next line in pattern space, $!b except for the last line branch to label a --> read the whole text into pattern space
local insRules=""
insRules="$(iptables-save | sed -r -n ':a;N;$!ba;s/-A FORWARD -j QBS-FORWARD\n(-A FORWARD -j DROP|-A FORWARD -i vif\+ -o vif\+ -j DROP)/-A FORWARD -j QBS-FORWARD\n-A FORWARD -j DROP/p')"
[ $? -ne 0 ] || [ -z "$insRules" ] && errorOut "Failed to install the default drop iptables FORWARD rule! Maybe the Qubes rules changed?! Please investigate asap!"

echo "$insRules" | iptables-restore
#as of 4.0rc2 Qubes doesn't seem to touch the iptables rules anymore after VM start
}

Just make sure to replace errorOut with your favorite error reporting function.

This doesn't just focus on eth0 as in the (imo mediocre) VPN doc, but also applies to e.g. tun0.

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 11, 2017

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb8u1 has been pushed to the r4.0 stable repository for the Debian jessie template.
To install this update, please use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb8u1 has been pushed to the r4.0 stable repository for the Debian jessie template.
To install this update, please use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 11, 2017

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb9u1 has been pushed to the r4.0 stable repository for the Debian stretch template.
To install this update, please use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

Automated announcement from builder-github

The package qubes-core-agent_4.0.13-1+deb9u1 has been pushed to the r4.0 stable repository for the Debian stretch template.
To install this update, please use the standard update command:

sudo apt-get update && sudo apt-get dist-upgrade

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 11, 2017

Automated announcement from builder-github

The package core-agent-linux has been pushed to the r4.0 stable repository for the Fedora centos7 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

Automated announcement from builder-github

The package core-agent-linux has been pushed to the r4.0 stable repository for the Fedora centos7 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 12, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc24 has been pushed to the r4.0 stable repository for the Fedora fc24 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc24 has been pushed to the r4.0 stable repository for the Fedora fc24 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 12, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc25 has been pushed to the r4.0 stable repository for the Fedora fc25 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc25 has been pushed to the r4.0 stable repository for the Fedora fc25 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

@qubesos-bot

This comment has been minimized.

Show comment
Hide comment
@qubesos-bot

qubesos-bot Dec 12, 2017

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc26 has been pushed to the r4.0 stable repository for the Fedora fc26 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

Automated announcement from builder-github

The package python2-dnf-plugins-qubes-hooks-4.0.13-1.fc26 has been pushed to the r4.0 stable repository for the Fedora fc26 template.
To install this update, please use the standard update command:

sudo yum update

Changes included in this update

marmarek added a commit to marmarek/qubes-core-agent-linux that referenced this issue Dec 13, 2017

network: order qubes-firewall service before enabling IP forwarding
Start qubes-firewall (which will add "DROP by default" rule) before
enabling IP forwarding, to not leave a time slot where some connection
could go around configured firewall.

QubesOS/qubes-issues#3269

(cherry picked from commit 3fb258d)

@qubesos-bot qubesos-bot referenced this issue in QubesOS/updates-status Dec 13, 2017

Closed

core-agent-linux v3.2.21 (r3.2) #323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment