Local interfaces: IPC, CLI and JSONL outputs
This page is published from the agent repository. Edit on GitHub View source
Besides the control plane, the agent talks to two local audiences: administrators on the host,
through a local control channel used by cli (and later the endpoint UI), and files on disk that
other tools read (the alert log, the optional raw event capture). This page explains both.
Local control channel
The ipc crate implements a small request/response protocol over a Unix
domain socket (Linux, macOS) or a named pipe (Windows). The agent hosts the server
(ipc_handler.rs); cli and
agent apply-content-manifest are clients.
| Module | Responsibility |
|---|---|
stream | OS-native Listener/Stream and the peer-credential read; the only place with cfg(target_family) code. |
frame | JSON-lines framing with a 1 MiB per-message cap. |
protocol | Wire types: ClientHello, ServerHello, Request, Response, WireError. |
server | Accept loop, per-connection task, dispatch to a Handler. |
client | Connect, handshake, typed calls; maps errors to messages an operator can act on. |
Connection lifecycle
sequenceDiagram
participant C as cli
participant S as agent (ipc Server)
C->>S: connect (socket / pipe)
S->>S: read peer credentials, check_authorized
alt not privileged
S-->>C: WireError::Unauthorized, then EOF
end
C->>S: ClientHello {version, client_name}
alt version != PROTOCOL_VERSION
S-->>C: WireError::UnsupportedVersion, then EOF
end
S-->>C: ServerHello {version, agent_version}
loop one request at a time
C->>S: Request
S-->>C: Response (or Response::Error)
end- Peer authentication (
PeerCreds::check_authorized) happens before a byte of the handshake is read:uid == 0on Unix (SO_PEERCRED, orLOCAL_PEERCREDon macOS), an elevated token on Windows (TokenElevationof the client process). Elevation, not group membership, is what an administrator runningclipasses. The check is in code rather than in a pipe security descriptor so that a non-elevated client still connects and gets an explicit refusal.client_nameis informational only. - Versioning is strict equality on
PROTOCOL_VERSION(currently 3). A new request variant bumps the version; additive fields on existing variants do not. - Serial per connection, parallel across connections. One tokio task per client; there are no
correlation IDs because only one request is in flight per connection. A slow handler blocks its
own connection, not the server. A failed
acceptis logged and the loop continues. - Framing (
read_message): one UTF-8 JSON object per line. JSON escapes newlines inside strings, so the delimiter is unambiguous. A line overMAX_MESSAGE_BYTES(1 MiB, newline included) or not valid UTF-8 ends the connection; the reader enforces the cap itself, since tokio'sread_linehas none. JSON lines were chosen so the wire is readable with standard tools and matches every other artifact the project writes. - Endpoints.
ipc.endpointinagent.toml: an absolute socket path such as/var/run/synthaea/agent.sock, or\\.\pipe\synthaea-agent. On Unix a stale socket file is removed before binding, so a restart after a crash does not fail with "address in use".
Requests
| Request | Effect | Notes |
|---|---|---|
Status | version, start time, pipeline health, active suppressions | |
SensorHealth | per-sensor state | |
RecentDetections { limit } | the most recent detections, oldest first | clamped to RECENT_DETECTIONS_HARD_LIMIT (256), no error |
PolicyVersion | applied policy metadata | |
ReloadContent | re-read Sigma/YARA content and swap it into the running pipeline | sent by apply-content-manifest after it has verified and written content |
SuppressVerdict / UnsuppressVerdict | silence or restore one technique on one entity (ppid, comm) in the fused verdict | reversible, audited, never touches the alert log |
The channel is read-mostly by design. The three mutating requests are exceptions because they act
only on the agent's own state: ReloadContent loads content that was already signature-checked
over the mTLS channel, and suppressions change only the agent's verdict view. Commands that act on
other processes or files (kill, quarantine, isolate) are not on this channel; they need a
per-capability authorization model first.
A handler error becomes Response::Error(WireError::HandlerFailed) and the connection stays open;
authentication, version and framing failures close it.
Client errors
Client::connect separates "the agent is not there"
(ClientError::Connect) from "the agent said no"
(ClientError::Refused). Permission denied on the socket, Windows
error 5, and an Unauthorized reply are all reported as access denied rather than as a missing
agent; a pipe closed during the handshake is reported as such. There is no connection pool and no
reconnect: clients are short-lived.
cli
cli holds no privileges of its own; it is a pure client of the IPC channel
(installed on Linux as /usr/bin/synthaea-ctl).
| Command | Does |
|---|---|
config init [--force] | Write the default agent.toml template to the discovered path; refuses to overwrite without --force. |
config check, config path | Validate the configuration, print where it was found. No network. |
status, health, detections [--limit 20], policy | IPC reads. |
suppress PPID COMM TECHNIQUE, unsuppress ... | IPC suppressions. |
Configuration discovery: --config, then SYNTHAEA_CONFIG, then the OS default path. Every IPC
command accepts --json (one line of JSON) and exits non-zero with a copy-pasteable message when the
agent is unreachable or refuses.
JSONL outputs
The sinks crate writes local JSON Lines. The agent speaks only
neutral formats; vendor SIEM connectors belong to the control plane's export, not to each agent.
JsonlWriter: oneMutex<BufWriter<File>>opened in append mode, one serialized value per line, flushed per line (the files are tailed while the agent runs, and losing buffered lines on a crash costs more than the syscall). A write error is ignored: a missed local log line must not stop capture.- Torn-tail repair. On open, if the file is non-empty and does not end in a newline (a crash mid-write), a newline is appended first, so the first new record does not fuse with the torn line and make both unreadable.
- Escaping is
serde_json's: a process renamed to contain quotes or control bytes still yields valid JSON (tested intests.rs). JsonlEventSinkwrites every normalized event in the schema's canonical serialization, unfiltered; used byagent capture-eventsand by the optional raw event log ofagent run.AlertRecordis the alert-log record shape.
In agent run the raw event log is written by the enrichment worker, after redaction, never by a
capture thread, and is off unless requested: it grows without bound and only labs and ML calibration
need it (DetectionSink::new).
Syslog/CEF and OCSF/ECS mappings are planned additions to this crate.
Testing
| Test | What it proves |
|---|---|
crates/ipc/tests/e2e.rs | A real server and client round-trip every request; a wrong version is refused. Run privileged in CI (see Development). |
Unit tests in stream.rs, frame.rs, client.rs | Authorization policy, framing limits, error classification. |
crates/sinks/src/tests.rs | Round trip, hostile strings, append across reopen, torn-tail repair. |
cli has no tests of its own; its IPC calls are covered by the ipc tests.