From: Phil Sutter <phil@nwl.cc>
To: Jan Engelhardt <jengelh@inai.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [iptables PATCH 9/9] extensions: DNAT: Support service names in all spots
Date: Thu, 31 Mar 2022 12:04:12 +0200 [thread overview]
Message-ID: <YkV8nIURQHbWNJ4W@orbyte.nwl.cc> (raw)
In-Reply-To: <935op3q3-s38p-674r-1n2n-8spr98o7s37@vanv.qr>
On Thu, Mar 31, 2022 at 02:19:51AM +0200, Jan Engelhardt wrote:
> On Wednesday 2022-03-30 22:57, Phil Sutter wrote:
> >> >+-p tcp -j DNAT --to-destination 1.1.1.1:echo-ftp-data/ssh;-p tcp -j DNAT --to-destination 1.1.1.1:7-20/22;OK
> >>
> >> This looks dangerous. It is why I originally never allowed service names in
> >> port ranges that use dash as the range character.
> >
> >Guess if someone is able to manipulate /etc/services, any service names
> >are problematic, not just in ranges.
>
> Well, pretty much anyone has a shot at manipulating this file. File a
> port registration with IANA, and when your distro updates the file,
> eventually there is a chance of messing up firewall configs,
> worldwide.
>
> Other than that, thanks to nsswitch, the service list can also be in
> LDAP or so, and then all that's needed is a disgruntled LDAP admin
> who dislikes the firewall admin.
>
> >Another potential problem I didn't have in mind though is that 'a-b'
> >could mean [a; b] or [a-b] assuming that all three exist. But I haven't
> >found a valid example in my /etc/services, yet. :)
>
> I found 25 at once!
>
> 914c :: 914c-g :: g-talk
> ads :: ads-s :: s-openmail
> bctp :: bctp-server :: server-find
> cis :: cis-secure :: secure-mqtt
> connect :: connect-server :: server-find
> docker :: docker-s :: s-openmail
> documentum :: documentum-s :: s-openmail
> domain :: domain-s :: s-openmail
> dtp :: dtp-net :: net-device
> genie :: genie-lm :: lm-mon
> linktest :: linktest-s :: s-openmail
> mailbox :: mailbox-lm :: lm-mon
> mbap :: mbap-s :: s-openmail
> ns :: ns-server :: server-find
> plato :: plato-lm :: lm-mon
> rmonitor :: rmonitor-secure :: secure-mqtt
> sentinel :: sentinel-lm :: lm-mon
> sitewatch :: sitewatch-s :: s-openmail
> spss :: spss-lm :: lm-mon
> sql :: sql-net :: net-device
> tacacs :: tacacs-ds :: ds-slp
> tl1 :: tl1-lv :: lv-auth
> trim :: trim-ice :: ice-router
> wnn6 :: wnn6-ds :: ds-slp
> wsdapi :: wsdapi-s :: s-openmail
Your /etc/services seems to be much larger than mine, many of those
don't exist in my case.
> To be read as: "wsdapi-s-openmail" is ambiguous, because
> it allows for two interpretations (and all four port names are in
> /etc/services):
>
> [wsdapi]-[s-openmail]
> [wsdapi-s]-[openmail]
OK. My code preferred the latter, checking if the former is possible is
a poor workaround. The only difference it makes is rules get rejected
instead of changing behaviour silently.
> >> The "solution" would be to use : as the range character, but that would require
> >> a new --dport option for reasons of command-line compatibility.
> >
> >Well, we could allow both (a-b with numeric a and b only) and use it in
> >output only if non-numeric was requested.
>
> Given I'm seeing "914c" in the IANA list (leading digits always stand
> out from the crowd, e.g. you don't normally see them in UNIX
> usernames either), I won't hold my breath that no one would try to
> register "914-915".
That's an interesting point: "914c" is not usable in iptables. The code
tries strtoul which succeeds for "914", "c" is then rejected as illegal
remainder. To fix that, we had to consult getservbyname() first which is
a performance hit. Guess the whole "support users with bad number
memory" game is best effort, only.
I'll submit a v2 without the experimental "names in ranges" patch in a
minute.
Thanks, Phil
prev parent reply other threads:[~2022-03-31 10:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 15:58 [iptables PATCH 0/9] extensions: Merge *_DNAT and *_REDIRECT Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 1/9] man: DNAT: Describe shifted port range feature Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 2/9] Revert "libipt_[SD]NAT: avoid false error about multiple destinations specified" Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 3/9] extensions: ipt_DNAT: Merge v1 and v2 parsers Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 4/9] extensions: ipt_DNAT: Merge v1/v2 print/save code Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 5/9] extensions: ipt_DNAT: Combine xlate functions also Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 6/9] extensions: DNAT: Rename from libipt to libxt Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 7/9] extensions: Merge IPv4 and IPv6 DNAT targets Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 8/9] extensions: Merge REDIRECT into DNAT Phil Sutter
2022-03-30 15:58 ` [iptables PATCH 9/9] extensions: DNAT: Support service names in all spots Phil Sutter
2022-03-30 18:38 ` Jan Engelhardt
2022-03-30 20:57 ` Phil Sutter
2022-03-31 0:19 ` Jan Engelhardt
2022-03-31 10:04 ` Phil Sutter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YkV8nIURQHbWNJ4W@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=jengelh@inai.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).