nftables set for ip6 in ip table
derbasti381 opened this issue · 8 comments
What happened?
I wanted to try crowdsec for my local firewall which is based on nftables. I installed crowdsec-firewall-bouncer-nftables 0.0.28 on Debian and adjusted the configuration to only create the ip sets.
When I restart the service, this is what happens:
# nft monitor
add set ip mangle crowdsec-blacklists { type ipv4_addr; flags timeout; }
add set ip mangle crowdsec6-blacklists { type ipv6_addr; flags timeout; }
What did you expect to happen?
I expected the rule to be inserted in ip6, because as it goes to ip, it can never even be used by any ip6 flow.
add set ip6 mangle crowdsec6-blacklists { type ipv6_addr; flags timeout; }
would be the correct one. Even if i create the Set in ip6 before, it still get's added to ip only.
How can we reproduce it (as minimally and precisely as possible)?
nftables:
ipv4:
enabled: true
set-only: true
table: mangle
chain: crowdsec
priority: -10
ipv6:
enabled: true
set-only: true
table: mangle
chain: crowdsec
priority: -10
#!/usr/sbin/nft -f
flush ruleset
add table ip mangle;
add table ip6 mangle;
add chain ip mangle crowdsec;
add chain ip6 mangle crowdsec;
Apply nftables, restart firewall-bouncer
Anything else we need to know?
It would also be suitable to add both sets to inet. Like this both protocols could access the sets.
Crowdsec version
OS version
Enabled collections and parsers
$ cscli hub list -o raw
# paste output here
Acquisition config
On Windows:
C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml
paste output here
Config show
$ cscli config show
# paste output here
Prometheus metrics
$ cscli metrics
# paste output here
Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.
@derbasti381: Thanks for opening an issue, it is currently awaiting triage.
In the meantime, you can:
- Check Crowdsec Documentation to see if your issue can be self resolved.
- You can also join our Discord.
- Check Releases to make sure your agent is on the latest version.
Details
I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.
Moving over to firewall repository as issue is not from CrowdSec Security Engine
Debugging
cs-firewall-bouncer/pkg/nftables/nftables_context.go
Lines 128 to 164 in af6e7e2
Issue happens in setonly function, we only interact with the conn (ipv4) chain rather than conn6 (ipv6)
Need to debug further as, technically we shouldn't even bother adding addr type v6 to ip chain as it has no value
edit edit: will spin up a vm to test shortly