<div dir="ltr"><div>Hello<br><br></div>[As advised by Paul removed log attachments]<br><br>I have received a problem scenario from my company regarding IPSec VPN.<br><br>Important Points:<br>1) The problem involves Openswan 2.6.31 or Libreswan 3.12.<br>2) Problem is intermittent, does not have a specific interval for occurence.<br>3) This is a hub and spoke problem. Having hub and 3 spokes.<br>4) NAT is not involved. All the connections are through public IPs.<br>5) All connections involve PRESHARED KEYS ONLY.<br>6) This all is phase 1 - packet 5 or 6.<br><br><br>Problem:<br>Intermittently, out of the three spokes two spokes just restart ipsec daemon.<br><br>X [I am sending the specific logs, if you want any other information please do revert]<br><br>PAYLOAD_MALFORMED message is received quite sometimes.<br><br>This has already taken aproximately 2 months. Now, it is troubling.<br><br>X [I am attaching the [ipsec whack --debug-all] logs.<br>There are two logs for two ends. But ipsec whack logs are quite big so<br>I am sending information for specific session ID #180934 which shows<br>PAYLOAD_MALFORMED.]<br><br>If you can suggest something here it will be great.<br><br>Please see the config below:<br><br>config setup<br>    protostack = netkey<br>    klipsdebug = none<br>    plutodebug = none<br>    uniqueids = yes<br>    hidetos = no<br><br>conn XXX<br>    type = tunnel<br>    left = X-X-X-X-X<br>    right = Y-Y-Y-Y-Y<br>    leftnexthop = Z-Z-Z-Z-Z<br>    leftsubnet = <a href="http://10.50.3.0/24" target="_blank">10.50.3.0/24</a><br>    rightsubnet = <a href="http://10.50.1.0/24" target="_blank">10.50.1.0/24</a><br>    auto = start<br>    keyexchange = ike<br>    authby = secret<br>    auth = esp<br>    keyingtries = 0<br>    esp = AES128-SHA1<br>    pfs = yes<br>    rekey = yes<br>    leftid = X-X-X-X-X<br>    rightid = Y-Y-Y-Y-Y<br>    ike = 3DES-SHA-MODP1024<br>    ikelifetime = 28800s<br>    keylife = 14400s<br>    rekeymargin = 10m<br>    rekeyfuzz = 20%<br>    X-early = yes<br>    dpddelay = 10<br>    dpdtimeout = 120<br>    dpdaction = restart<br>    X-custadmin = off<br><br><br><br>config setup<br>    protostack = netkey<br>    klipsdebug = none<br>    plutodebug = none<br>    uniqueids = yes<br>    hidetos = no<br><br>conn YYY<br>    type = tunnel<br>    left = Y-Y-Y-Y-Y<br>    right = %any<br>    leftnexthop = Z-Z-Z-Z-Z<br>    leftsubnet = <a href="http://10.50.1.0/24" target="_blank">10.50.1.0/24</a><br>    rightsubnet = <a href="http://10.50.3.0/24" target="_blank">10.50.3.0/24</a><br>    auto = add<br>    keyexchange = ike<br>    authby = secret<br>    auth = esp<br>    keyingtries = 0<br>    esp = AES128-SHA1<br>    pfs = yes<br>    rekey = yes<br>    leftid = 174.47.49.246<br>    rightid = %any<br>    ike = 3DES-SHA-MODP1024<br>    ikelifetime = 28800s<br>    keylife = 14400s<br>    rekeymargin = 10m<br>    rekeyfuzz = 20%<br>    X-early =<br>    dpddelay = 10<br>    dpdtimeout = 120<br>    dpdaction = restart<br>    X-custadmin = off<br>==============================<div dir="ltr">============<br><br>So, when I was not able to identify the problem, generically, I started looking into the code.<br>I found out the following:<br><br>1) plutomain.c (main())<br>main() -> call_server()<br><br>2) server.c<br>call_server() -> comm_handle()<br><br>3) demux.c<br>comm_handle() -> read_packet() -> process_packet()                                                                    <br><br>process_packet():<br><br>case ISAKMP_MAJOR_VERSION<br>process_v1_packet()<br><br>4) ikev1.c<br>process_v1_packet() -> process_packet_tail()<br><br>process_packet_tail()
 -> in_struct() -> [%s of %s has an unknown value = next payload 
type of ISAKMP Hash Payload has an unknown value: 201]<br><br>process_packet_tail() -> [malformed payload in packet]<br><br>SEND_NOTIFICATION(PAYLOAD_MALFORMED)<br><br>5) ikev1_main.c<br><br>send_notification -> [payload malformed after IV]<br><br>================================<br><br>Our problem is at 4) point.<br><br>Yesterday, I went to <a href="https://libreswan.org/" target="_blank">https://libreswan.org/</a> and saw the following text mentioned in red:<br><br>August 24st, 2015: CVE-2015-3240: Receiving a bad DH gx causes IKE daemon restart<br>Libreswan
 up to 3.14 is vulnerable to unauthenticated packets with a malicious DH
 gx payload causing the daemon to hit a passert() and restart. See our 
CVE-2015-3240 page for details. No remote code execution is possible. 
Please upgrade libreswan to version 3.15 or later.<br><br>Also looked into:<br><a href="https://libreswan.org/security/CVE-2015-3240/CVE-2015-3240.txt" target="_blank">https://libreswan.org/security/CVE-2015-3240/CVE-2015-3240.txt</a><br><br>So, do you feel in this case also the problem is above vulnerability (the bad DH issue).<br><br>In case you want any other information, please do revert.<br><br>Thanks<br></div><div>Rajeev<br></div><br></div>