Skip to main content

Module tls_inspect

Module tls_inspect 

Source
Expand description

Host-side HTTPS forensic inspection for unkernel-rs.

Provides two complementary, pure-Rust decryption engines:

  1. Method 1 — Zero-Touch Host-Side VMI TLS Key Extraction (VmiTlsInspector): Extracts live TLS 1.3 and TLS 1.2 session keys directly from wasmtime::SharedMemory without injecting any CA certificate, modifying the guest filesystem, or breaking certificate pinning.

    • Pass 1 (client_random anchor): Scans SharedMemory for the exact 32-byte ClientHello.random observed on the wire, then verifies candidate traffic_secret (TLS 1.3) or master_secret (TLS 1.2) windows in the surrounding struct memory mathematically against the captured encrypted AEAD record (zero false positives). Optionally writes standard Wireshark SSLKEYLOGFILE lines on the host.
    • Pass 2 (FindAES round-key schedule fallback): For runtimes that wipe client_random after handshake, scans SharedMemory for algebraically valid AES-128 (176 B) / AES-256 (240 B) expanded round-key schedules and verifies nearby IV candidates against the captured GCM record.
  2. Method 2 — Opt-In Transparent Host TLS MITM Proxy (MitmCa + MitmSession): Generates an ephemeral per-VM ECDSA P-256 Root CA (rcgen) and dynamically signs per-SNI leaf certificates, terminating guest TLS and re-encrypting upstream via Sans-I/O rustls::ServerConnection + rustls::ClientConnection. Works across every cipher and runtime (OpenSSL, Go, Rust, Python, Node) with zero scanning overhead.

Structs§

MitmCa
Ephemeral per-VM Root CA and leaf certificate cache for transparent host-side --mitm-tls.
MitmSession
Sans-I/O transparent TLS MITM bridge (guest <-> ServerConnection <-> ClientConnection <-> upstream).
MitmStep
Output produced by feeding one side of a MitmSession.
ServerHelloInfo
Parsed fields from a TLS ServerHello handshake message.
VmiTlsContext
Shared host context for Method 1 VMI SharedMemory TLS key extraction.
VmiTlsInspector
Per-connection zero-touch VMI TLS passive decryptor.

Functions§

extract_client_random
Extract the 32-byte ClientHello.random from a TLS ClientHello record.
find_32byte_matches
Find all byte offsets in haystack equal to the 32-byte needle using a fast 8-byte prefilter.
looks_like_tls_client_hello
Check whether data starts with a TLS Handshake (0x16) ClientHello (0x01) record.
parse_server_hello_handshake
Extract server_random, cipher_suite, and TLS 1.3 version indicator from a ServerHello handshake message payload (starting at handshake header byte 0x02).
scan_aes_key_schedules
Scan a memory image for algebraically valid AES-128 (176-byte) or AES-256 (240-byte) expanded round-key schedules (both big-endian and little-endian u32 word layouts, as used by OpenSSL, Go, and ring). Returns (offset_in_mem, raw_key_bytes).
summarize_tls_plaintext
Format a compact HTTP summary (request line or status line) and sanitized lossy preview.