My IPsec test was pinging itself

4 min read work #security #openqa #ipsec #common-criteria

TL;DR: Our Common Criteria IPsec test reported every allowed ESP cipher as working. The check behind it was a ping to the client's own address, which works with or without a tunnel. The test now passes a cipher only if strongSwan built the SA with that cipher and real traffic went through it (#27417).

What was wrong

SUSE Linux Enterprise is Common Criteria certified. Part of the evidence is that IPsec accepts the ciphers the security target allows and refuses the others. In openQA this is the cc_ipsec test: two machines, a strongSwan server and a client, trying one cipher proposal after another.

The client asks the server for a virtual IP. The server's pool is 192.168.250.0/24, so the client always gets 192.168.250.1. After each proposal the test checked the connection like this:

# Test the IPSec connection
assert_script_run('ping -W1 -c1 192.168.250.1');

192.168.250.1 is the client itself. That ping succeeds whatever happens to the tunnel.

So the allowed ESP cases passed even when the server had answered NO_PROPOSAL_CHOSEN and no CHILD_SA existed. The CHILD_SA is the IPsec SA that actually carries the traffic. The weak 3DES case looked right for another wrong reason: the server rejected it during IKE_SA_INIT, before it ever looked at the ESP proposal.

A green run proved that IKE worked. It proved nothing about the ESP ciphers, which is what the test is named after.

How I found it

I was reviewing the IPsec modules for a planned refactor, and read the strongSwan logs of passing jobs to have a baseline. Every allowed ESP case logged no CHILD_SA built, and the test printed Okay right after. The only other check counted Security Associations (1 up, and that line counts the IKE SA.

The fix

The cipher cases were shell loops. They are now Perl, and each case has to prove its result:

  • A pass needs a CHILD_SA with the expected proposal, and a ping to the server (192.168.100.1) through it. The audit log must have the SPD and SAD records for add and delete.
  • A refusal needs the expected reason, at the expected stage.
  • The server accepts the proposals of all cases from the start. That removed a server restart in the middle of the test and two synchronisation points.
  • In FIPS mode the kernel disables rfc4543(gcm(aes)), so ESP AES-GMAC must fail there. A new server module checks in the journal that the kernel refused it, so a proposal mismatch can't pass for the same thing.

Result

BeforeAfter
"Allowed" ESP case passes whenthe client can ping itselfa CHILD_SA with that proposal carries traffic
Weak cipher refused atIKE_SA_INIT, for the wrong reasonthe ESP proposal, with the expected error
Server restarts mid-test10

Verification runs covered x86_64, aarch64 and s390x, SLE 15-SP4 to 15-SP7.

Kernel 5.14, used by 15-SP4 and 15-SP5, logs the same GMAC refusal with a different message than kernel 6.4. A follow-up, #27440, makes the check match the error number instead of the text, so it gives the same answer on every supported service pack.

Also fixed in November

  • #27415: the same IPsec test was flaky on s390x. Every s390x run used the same IP pair on a shared network, so two runs at the same time answered each other's traffic. The client failed in 3.7% of the runs that had no other cluster running at the same time, and in 35.8% of the runs that did. Each cluster now derives its own pair from the job ID and checks with arping that it's free.
  • #27249: the FTPS test failed now and then on uploads over TLS 1.3. lftp 4.9.2 leaves the server's session tickets unread, so the kernel resets the connection and the TLS close_notify is lost. While there: a hash mismatch only painted the step red without failing the test, and lftp's batch script exited 0 without running its commands.
  • #27271: every Python test run by openQA's agnostic test runner produced an XUnit suite called pytest. With two of them in one job, one result stayed none and the job failed with all tests green. This hit other teams' schedules too.
  • #27331: on SLE 16.0, postfix rewrites main.cf the first time it starts. The mail test configured TLS first and started postfix after, so its settings were wiped and every STARTTLS failed.
  • #27514: review of the lynis hardening checks. A quoting bug made the exception UNSAFE* mean "UNSAF followed by any number of E". Before changing the logic I replayed it offline on 1,534 real report sections: the old code matched openQA on 1,533, and the new code moved 8 from soft-fail to ok and none the other way.

How this was made
AI help: an AI agent parsed and correlated the strongSwan logs of the passing jobs, which is where the missing CHILD_SAs showed up.
Code: reviewed line by line by me, like any other patch, and checked in verification runs.