<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
That's the interesting part.  I control the firewall on both sides and neither one explicitly allows new connections inbound over UDP/500 or UDP/4500 which was the initial source of the mystery.  HOWEVER, as part of a standard firewalld iptables ruleset, anything
 conntrack sees as an ESTABLISHED connection is permitted inbound.  In the case of TCP traffic, the 3 way handshake needs to pass to get traffic into the ESTABLISHED club, but for UDP all it needs to see is symmetrical traffic and that's the best it can do
 in the absence of an ALG.  <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So when the firewall sees AA.AA.AA.AA (UDP/500) -> BB.BB.BB.BB (UDP/500) AND BB.BB.BB.BB (UDP/500) -> AA.AA.AA.AA (UDP/500) (looks like a reply, but actually isn't) even though they're separate session setup packets they're also indistinguishable from a "properly
 established" ongoing UDP connection, so conntrack sees this and allows the traffic under the category ESTABLISHED.  It's technically a security hole in the firewall, but it also can only happen in very particular situations like this one AND you need to control
 both sides of the conversation, so I'm not losing a lot of sleep over it.  <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I think I'll eventually need to explicitly allow the traffic inbound when I turn on remote access / road warrior connections because THEN I won't have both sides trying each other and fooling the firewall into thinking it's a real conversation before it actually
 is.  But it was interesting to see this.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Scott<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Swan <swan-bounces@lists.libreswan.org> on behalf of Nick Howitt <nick@howitts.co.uk><br>
<b>Sent:</b> September 20, 2020 4:08 AM<br>
<b>To:</b> swan@lists.libreswan.org <swan@lists.libreswan.org><br>
<b>Subject:</b> Re: [Swan] LibreSWAN and iptables</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">It depends on your configs. If both side have auto=start then both sides
<br>
will try to initiate the connection. The far side will fail because your <br>
firewall is closed, but if their firewall is open, you can initiate the <br>
connection.<br>
<br>
Nick<br>
<br>
On 20/09/2020 02:59, Scott A. Wozny wrote:<br>
> Figured it out.  Sorry to have been a bother.  Considering how UDP is <br>
> connectionless and that SPORT and DPORT on both the ISAKMP and the <br>
> IPSEC-NAT-T packets are the same, obviously any stateful firewall <br>
> without an ALG for the protocol would see a packet in each direction and <br>
> that would count as closely to an established connection as conntrack <br>
> would ever be able to figure out, which is why this functions without an <br>
> explicit firewall rule.<br>
> <br>
> Obviously the very first packet passed would never get though, but <br>
> ISAKMP and IPSec being peer protocols would have it baked in that <br>
> somebody would always be up first and waiting for the other so those <br>
> first dropped packets would be inherently accommodated for in any <br>
> grown-up implementation, right? ðŸ™‚<br>
> <br>
> ------------------------------------------------------------------------<br>
> *From:* Swan <swan-bounces@lists.libreswan.org> on behalf of Scott A. <br>
> Wozny <sawozny@hotmail.com><br>
> *Sent:* September 19, 2020 8:04 PM<br>
> *To:* Paul Wouters <paul@nohats.ca><br>
> *Cc:* swan@lists.libreswan.org <swan@lists.libreswan.org><br>
> *Subject:* Re: [Swan] LibreSWAN and iptables<br>
> So, I've been futzing around with my configuration and since I can't use <br>
> ipsec-interface (kernel 3.10) I've been writing FORWARD chain rules for <br>
> my traffic to pass through.  That seems to be working about how I <br>
> expected, but I just realized I wrote no rules to permit UDP/500 and <br>
> UDP/4500 on the interface I've bound ipsec to, yet tunnels come up fine <br>
> and traffic passes through.  I've checked all 5 netfilter tables for a <br>
> rule to allow inbound UDP/500 and UDP/4500 but haven't been able to find <br>
> one.<br>
> <br>
> I doubt it's magic, but I was wondering if you could explain how that <br>
> traffic is getting in?  I was preparing to write explicit rules to <br>
> permit it, but if that's not necessary I'd like to be able to check the <br>
> status of whatever it is that IS allowing it.<br>
> <br>
> Thanks,<br>
> <br>
> Scott<br>
> <br>
> ------------------------------------------------------------------------<br>
> *From:* Swan <swan-bounces@lists.libreswan.org> on behalf of Scott A. <br>
> Wozny <sawozny@hotmail.com><br>
> *Sent:* September 15, 2020 6:19 PM<br>
> *To:* Paul Wouters <paul@nohats.ca><br>
> *Cc:* swan@lists.libreswan.org <swan@lists.libreswan.org><br>
> *Subject:* Re: [Swan] LibreSWAN and iptables<br>
> That's interesting.  I'll have to load my iptables policy up with log <br>
> lines against a default ACCEPT policy to see the practical effect of <br>
> this in the writing of my rules.<br>
> <br>
> Thanks,<br>
> <br>
> Scott<br>
> <br>
> ------------------------------------------------------------------------<br>
> *From:* Paul Wouters <paul@nohats.ca><br>
> *Sent:* September 15, 2020 6:11 PM<br>
> *To:* Scott A. Wozny <sawozny@hotmail.com><br>
> *Cc:* Wewegama, Kavinda <Kavinda.Wewegama@forcepoint.com>; <br>
> swan@lists.libreswan.org <swan@lists.libreswan.org><br>
> *Subject:* Re: [Swan] LibreSWAN and iptables<br>
> On Tue, 15 Sep 2020, Scott A. Wozny wrote:<br>
> <br>
>> I had seen that diagram before.  I found the one I mentioned easier to work with, but that was before<br>
>> I understood the purpose of the xfrm boxes.  ðŸ™‚  So I see now that all the IPSec stuff is happening<br>
>> not as a normal process, but as a special use case that will, after encoding or decoding send the<br>
>> packets back through the PREROUTING / INPUT or OUT / POSTROUTING chanes for further examination<br>
>> which, I think, was the piece that was throwing me.  As I dug into xfrm, I found the first 30 minutes<br>
>> of this presentation immensely helpful.  <a href="https://www.youtube.com/watch?v=7oldcYljp4U">
https://www.youtube.com/watch?v=7oldcYljp4U</a><br>
> <br>
> I'm glad that was useful to you :)<br>
> <br>
> Note that with XFRM interface support everything changes again. If you<br>
> set ipsec-interface=yes in a conn section, then you get an xfrmi device<br>
> called ipsec1. You can then apply all the FORWARD/INPUT/OUTPUT/POST/PRE<br>
> rules on that. The encrypted packets (post-encrypt and pre-decrypt) will<br>
> appear on the physical interface. The decrypted packets (pre-encrypt and<br>
> post-decrypt) will than appear on the ipsec1 virtual interface.<br>
> <br>
> The XFRMi interfaces are a redesign from the VTI interfaces, and in<br>
> general work much better although there are still a few use cases<br>
> better handled with VTI unfortunately.<br>
> <br>
> Paul<br>
> <br>
> _______________________________________________<br>
> Swan mailing list<br>
> Swan@lists.libreswan.org<br>
> <a href="https://lists.libreswan.org/mailman/listinfo/swan">https://lists.libreswan.org/mailman/listinfo/swan</a><br>
> <br>
<br>
_______________________________________________<br>
Swan mailing list<br>
Swan@lists.libreswan.org<br>
<a href="https://lists.libreswan.org/mailman/listinfo/swan">https://lists.libreswan.org/mailman/listinfo/swan</a><br>
</div>
</span></font></div>
</div>
</body>
</html>