BPF Filter Limitations - Prevent Sweeping Attacks #5
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Having a BPF filter on the pcap highly reduces overhead / load of hypd, however it makes you more susceptible to sweep attacks (i.e. where an adversary continuous just keeps trying random ports). An adversary may get the first port correct as part of a random port scan. They may continue randomly scanning until they get the second port correct, if a packet doesn't match the BPF filter, then it's not getting sent to handlePacket() and won't reset the knock sequence.
Odds are the adversary will hit on another port that's part of a different sequence or different iteration of the current sequence and that will reset the progress, however this is still definitely a weakness that should be corrected.
First impelement hypd configuration files
Then we can eliminate the tight port list on the BPF filter completely and capture all UDP datagrams in handlePacket(). We can make it a configurable options to disableExtendedSweepProtection and if set to true then it reverts to the current behavior. It may be desireable to disableExtendedSweepProtection in some use cases if you want minimal compute resource overhead for hypd.
Need to get some benchmarks with wide open filter compared to constraining to just the ports required for the authentic knock sequence.
I can only test this on a 1Gbps line at the moment
Also, in the call to pcap.OpenLive, perhaps we don't need promiscuous mode, and we don't need 1600 bytes to be read since all we care about is the UDP header - 8 bytes, but we don't know what the IP header length is necessary, or the L2 header length.
Ethernet dest MAC = 6 bytes
Ethernet src MAC = 6 bytes
Ethertype = 2 bytes
IPv4 = 40 bytes
UDP = 8 bytes
Total = 60 bytes... anything over this can be dropped because it's not a knock
There could be be other header types on different kinds of networks, but they will be unsupported at this time. Only Ethernet with IPv4.
sweep attacks are effectively mitigated in
0ad3e2b0d4
Since implementing eBPF, all packets can be sent to handleKnock and so the sequence progress can be invalidated on the first wrong knock attempt.