Bug 266477 - PF does not obey ICMP rate limits
Summary: PF does not obey ICMP rate limits
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-pf (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-18 07:27 UTC by Daniel O'Connor
Modified: 2022-10-14 09:25 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel O'Connor 2022-09-18 07:27:49 UTC
PF emits ICMP messages for blocked connections (when return is set) but it does not call the rate limit code (badport_bandlim) and hence will send them at an unlimited rate. IMO this is a POLA violation.

Furthermore the IPv6 stack does not appear to call it either, badport_bandilm has BANDLIM_ICMP6_UNREACH but it does not appear to be used.

I think it would make more sense to move the rate limiting code into icmp_error/icmp6_error and perhaps also add some per-ICMP type stats exposed as sysctls.
Comment 1 Daniel O'Connor 2022-09-18 07:48:05 UTC
Also, there is net.inet6.icmp6.errppslimit however it does not appear to be connected to anything..
Comment 2 Kristof Provost freebsd_committer freebsd_triage 2022-10-07 14:30:06 UTC
Proposed patch:
https://reviews.freebsd.org/D36903
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-10-14 09:25:32 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a974702e274cbed52ae9ad9ecef8501e267b822d

commit a974702e274cbed52ae9ad9ecef8501e267b822d
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-10-07 14:22:57 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-10-14 08:36:16 +0000

    pf: apply the network stack's ICMP rate limiting to ICMP errors sent by pf

    PR:             266477
    Event:          Aberdeen Hackathon 2022
    Differential Revision:  https://reviews.freebsd.org/D36903

 sys/netinet/icmp6.h  |  1 +
 sys/netinet6/icmp6.c |  3 +--
 sys/netpfil/pf/pf.c  | 26 ++++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)