Somewhere on a diagnostic console, a row turns green. An IPsec Security Association sits in the MATURE state. The SPI is there, the algorithms are listed, the addresses match, the lifetime is counting down. An engineer exhales and closes the ticket.

RFC 2367, the specification that put the PF_KEY interface between a key-management daemon and the kernel's Key Engine, is the document that quietly explains why that exhale was premature. The row is a local receipt. It is not a certificate. And the gap between those two things is where an entire genre of security reporting goes to die.

Summary

  • RFC 2367 placed a privileged socket API between a key-management application and the local Key Engine. Its replies describe that local interface and its database — not a completed security outcome across two endpoints.
  • SADB_GET, SADB_DUMP and the states LARVAL, MATURE, DYING and DEAD are bounded records. MATURE means an SA was added or updated locally. It does not prove peer authentication, current policy applicability or packet use.
  • A defensible result joins caller authority, PF_KEY transaction, local SA, key custody, remote negotiation, policy selection, per-packet AH/ESP processing, remote receipt and application evidence — without letting one layer impersonate the next.

The important diagram in RFC 2367 has three paths, not one. A key-management daemon speaks PF_KEY to a local Key Engine. The same daemon uses PF_INET or PF_INET6 to talk to a remote key-management entity. Kernel IPsec processing reaches the Key Engine through a third, internal interface. A successful event on the first path cannot silently testify for the other two — and yet that is exactly the testimony dashboards keep extracting from it.

That separation is what made PF_KEY portable in the first place. A trusted application could add a complete SA with SADB_ADD, reserve an SPI and finish it with SADB_UPDATE, retrieve it with SADB_GET, or request creation after SADB_ACQUIRE. The API could report expiration, delete one entry, flush a class, and expose the table for debugging. It standardized a local control surface and then had the discipline to stop there — no pretending to standardize every key exchange, every policy engine, every packet outcome. The interface fixed the minimum; running code settled the rest, which is precisely the ordering Lu Heng describes in Running-Code Primacy.

“Mature” is a database verb, not a verdict

The four state names sound operationally conclusive. They are narrower than they sound, and considerably less romantic. LARVAL follows SADB_GETSPI. MATURE follows an update or an add. DYING records soft-lifetime expiry. DEAD records hard-lifetime expiry before collection. Each name answers one question — what happened to this local record — and declines to answer the interesting ones: did the remote endpoint install its directional companion, was an authenticated identity actually authorised for these traffic selectors, did a single packet ever select this SA?

The same modesty applies to the fields. An SPI is a lookup coordinate, not a credential. An algorithm identifier says which operation is configured, not that its key stayed protected or that the operation succeeded. A lifetime counter is local accounting, not bilateral freshness. RFC 2367 even permits a zero to mean that authentication or encryption is simply not used for a given SA. Reading the row accurately therefore matters more than finding reassuring words inside it.

SADB_DUMP is the most tempting shortcut, and the RFC is refreshingly rude about it. The operation can return the operating system's entire Key Table, one SA per message, followed by an end marker — and it is described as debugging-only, not intended for production use, with key-management applications explicitly told not to depend on it for basic operation. A dump is a situated snapshot: incomplete when messages drop, stale relative to policy, locally accurate while the peer has already diverged.

Message transport carries its own caveat. PF_KEY delivery is not guaranteed, especially when kernel or socket buffers are exhausted, and most errors arrive as reply messages. A monitor that faithfully records every successful row while losing an error, an expiration or a deletion notice will construct a cleaner history than the system ever produced. That is not observability. That is fiction with timestamps.

The privileged caller is part of the proof

PF_KEY was never designed for an ordinary application. Only trusted, privileged processes were to open the raw socket, and the manual interface handed those processes broad control over local SAs. RFC 2367's security considerations are blunt about the consequence: if an unprivileged user can create, read, modify or delete this state, the operating system cannot provide the related security service at all.

The audit therefore has to begin before the SA exists. Which executable opened the socket? Under which identity, and under which configuration generation? Who authorised the change? Where did plaintext key material live, and which process could retrieve it? A perfectly formed SADB_UPDATE from the wrong authority is not a secure result — it is a well-formatted mistake. Nor does a broadcast reply prove key custody: RFC 2367 deliberately omits keying material from returned update messages, because some listeners may not be allowed to see it.

Policy, negotiation and packets stay separate

Later IPsec architecture sharpens the joins that PF_KEY left implicit. RFC 4301 gives the SPD three choices — BYPASS, DISCARD, PROTECT — and the SAD supplies parameters only after policy has selected protection. SAD entries can outlive the SPD rules that justified them, and manually keyed entries may exist with no corresponding policy entry at all. A present SA is therefore not proof that the target flow should have used it, let alone did.

RFC 7296 moves remote identity, AUTH verification, Peer Authorization Database rules, traffic selectors and directional Child SAs into the IKEv2 exchange — and candidly acknowledges the timing windows in which two endpoints disagree about SA state. A local MATURE row cannot reconstruct the peer's credential decision, or its current installation, or its opinion of yours.

RFC 4303 then applies ESP to packets, one at a time. The chosen services depend on SA options and topology; outbound transformation and inbound integrity verification happen per packet. Only after that come forwarding, remote receipt, transport behaviour and application authorisation. A counter increment can support one link in that chain. It cannot finish it.

The useful operational record is therefore a join, not a screenshot: privileged caller; exact PF_KEY request and reply; current local SA and SPD generation; protected key provenance; authenticated and authorised peer exchange; the packet's policy match; AH/ESP result; independent remote observation; and application response. Every entry needs a timestamp and a shared correlation identity. Missing joins should stay visibly missing — that is the whole point of fixing only the minimum and letting the rest be adopted by running code.

Sources