Skip to content

[MOCA SBX] Exactly one audit event per injection, in MOCA's audit shape #1482

Not planned

Description

@pdettori

Priority: P1 · Part of the Cortex × MOCA SBX epic · #905 breakdown step 2 · MOCA contract: MI1 §8.5 item 6, conformance doc.go audit contract

Problem

On a shared host, "whose key went where" has to be answerable after the fact, one line per decision.

What Cortex does today

No audit event is recorded on a successful injection. Session events exist, but they are a recording store (issue 11), not an audit sink.

What MOCA needs

One JSON event per line. The fields the suite reads:

  • via, vm_id, sid, sub, host (normalised), method (CONNECT for a tunnel);
  • path, escaped, with no query, fragment or userinfo;
  • status;
  • decision: one of tunnel, forward, destination_denied, destination_private, conn_cap, request_cap, no_binding, credential_unavailable, upstream_unreachable, bad_request, aborted;
  • dial_addr, the evidence for resolve-once;
  • bytes_up and bytes_down;
  • plus the injected credential's name, never its value.

The sink is behind a seam: journald on the VM deployment, stdout for the suite.

Design questions

  1. Is this a new audit sink in Cortex, or a projection of session events?
  2. The via value: moca-egress is what the suite expects today. Should the suite accept cortex?

Done when

Conformance case audit_query_removed passes, and the interception-slice case "exactly one audit event per injection" passes.

Activity

  1. added
    enhancement
    on Oct 22, 2026
  2. evaline-ju commented on Nov 6, 2026

    @evaline-ju
    Contributor

    #1673 relies on this issue's sink being asynchronous, as moca's is (NewAsyncSink(NewJSONSink(os.Stdout), 0)). vmcontrol's sink is synchronous today, which has two effects on a VM host when the output stalls:

    • conn_cap events: a stalled sink ties up the VM's 8 refusal-answer slots. Past those, over-cap connections are closed without a 429.
    • Request audit lines: Unregister waits for every in-flight request's audit line to be written, so a stalled sink stalls Unregister. The same is true on main.

    An async sink with a bounded queue that counts what it drops (Event.Dropped) fixes both, while keeping one line per request.

  3. huang195 commented on Nov 23, 2026

    @huang195
    Member

    Replaced by #2089 (one complete, asynchronous audit event per request), under #2042.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions