-
Notifications
You must be signed in to change notification settings - Fork 62
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
Network hardening using sysctl #856
base: main
Are you sure you want to change the base?
Conversation
https://linux-audit.com/linux-security-guide-for-hardening-ipv6/ | ||
''; | ||
type = lib.types.bool; | ||
default = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be default to true? We have now almost 50% ipv6 deployment world-wide: https://www.google.com/intl/en/ipv6/statistics.html#tab=ipv6-adoption
So one cannot say that ipv6 is not used. Especially in VPN it has the advantage that hosts never have to be renumbered again as they are too many collisions between private ipv4 addresses spaces i.e. when merging company networks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I set default to false
. In Ghaf by default IPv6 is disabled.
https://github.com/tiiuae/ghaf/blob/main/modules/microvm/virtualization/microvm/common/vm-networking.nix#L24C23-L24C24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we enable IPv6 we should include hardening settings as well. I agree we should support IPv6, but enabling it indiscriminately in all VMs and interfaces may not be the best strategy with our current setup, and afaik enabling it for specific interfaces is still possible with these settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have included some IPv6 configs in the updated PR which falls in some of current categories. There are more recommendations for IPv6 hardening, I will include them later after discussion.
default = true; | ||
}; | ||
|
||
enable-rp-filter = lib.mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't linux has enabled this by default anyway? If someone ever disable this, they are most likely doing so intentionally i.e. they want to do BGP routing. Having this option just makes things more complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not enabled by default in Linux. Since it is recommended to enable rp_filter in many Linux security audits, so I thought to include it. Now it defaults to false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this flag is not used? Also, NixOS seems to set it to 2 (loose mode), whereas this option sets it to 1 (strict mode). Not entirely sure about the implications within Ghaf, especially internal network, can you elaborate if strict mode makes sense as a default or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I studied around this. As far as what I understood, loose mode(default) is fine for VMs which are communicating through internal network. Strict mode should be beneficial in net-vm specially if some one tries to spoof an VM address. In strict mode these packets will be dropped while in loose mode these may be accepted as there is always a valid route for these.
default = true; | ||
}; | ||
|
||
disable-ping-request = lib.mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks ipv6. It's also a problem for debugging cases where the MTU is too high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also defaults to false
now.
7f10c3c
to
aba64ea
Compare
aba64ea
to
5ee28d4
Compare
5ee28d4
to
a70f0fe
Compare
a70f0fe
to
13dac01
Compare
{ | ||
## Options to enable IP security | ||
options.ghaf.security.sysctl.network = { | ||
disable-all = lib.mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not the typical enable
flag that defaults to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Done.
13dac01
to
8cd2099
Compare
... | ||
}: | ||
let | ||
cfg = config.ghaf.security.sysctl.network; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can add
inherit (lib) mkOption mkForce mkDefault mkIf types;
For better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
8cd2099
to
a09ae92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with prejudice.
Signed-off-by: Ganga Ram <[email protected]>
a09ae92
to
7f1ff93
Compare
Description of changes
sysctl configuration for network hardening.
Uses configuration recommended in different security audits.
Configuration and it's recommendation is available in this document:
Recommended sysctl settings
Sysctl network setting audit report available:
https://github.com/gangaram-tii/ghaf-debug-tools/blob/main/report/hardened_network_audit_report.md
Network Performance impact:
https://github.com/gangaram-tii/ghaf-debug-tools/blob/main/report/perf-iperf3.png
Note:
ghaf+
label is with sysctl hardened network settings.Checklist for things done
x86_64
aarch64
riscv64
make-checks
and it passesnixos-rebuild ... switch
Instructions for Testing