caelum0x ecac03914b fix(audit-log): bind source_service to verified mTLS peer identity, not the claimed field
Closes the mTLS-enabled half of docs/THREAT-MODEL.md's "Known gaps" item 2:
with mTLS disabled (the default) nothing bound a gRPC caller's transport
identity to the source_service string its AppendRequest claimed, so a
compromised agent calling audit-log.Append directly with
source_service: "ledger-core" could forge an entry that looked
authoritative. Added pkg/mtls.PeerCommonName (extracts the verified leaf
cert's CommonName from a gRPC context, ok=false for any non-mTLS peer)
and wired it into audit-log's Append: when a verified identity is
present it overrides the claimed source_service outright, rather than
merely checking it. The mTLS-disabled case is unavoidable and stays
exactly as documented. Full go test suite green across every module;
THREAT-MODEL.md's gap #2 and the earlier-stale gap #4 entry updated to
match what the code actually does today.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-21 16:23:43 +03:00
..