[Bug] debug:renderer-event accepts arbitrary domain via lying type assertion
Problem
The debug:renderer-event IPC handler accepts a domain field from the renderer and forwards it to the logger via a type assertion as 'renderer'. The cast is a lie — at runtime, payload.domain is whatever string the renderer sent, not necessarily 'renderer'. This means a renderer can inject debug events under any domain name ('db', 'gateway', 'ws', etc.), polluting main-process debug logs and the getRecentEvents({ domain: [...] }) filter result with events that never actually came from that subsystem. Breaks the trust boundary between main and renderer and makes debugging upstream bugs harder.
Location
File: packages/desktop/src/main/ipc/debug-handlers.ts:9-30
ipcMain.on(
'debug:renderer-event',
(_event, payload: {
domain: string;
event: string;
// ...
}) => {
const logger = getDebugLogger();
logger.info({
domain: (payload.domain || 'renderer') as 'renderer', // ← lie
event: payload.event,
traceId: payload.traceId,
feature: payload.feature,
data: payload.data,
});
},
);
Fix Approach
Two options:
- Simplest: hard-code
domain: 'renderer', drop thepayload.domainfield entirely. The channel name already tells us where the event came from. - If sub-domains within renderer are wanted: keep an explicit whitelist of renderer sub-domains (e.g.
'renderer','renderer.settings','renderer.chat') and validate against it; otherwise coerce to'renderer'.
Either way, drop the as 'renderer' cast — it is masking a real runtime contract violation.
Verification
- Run
pnpm check— must pass. - Unit test: call the IPC with
payload.domain = 'db'; assert the persisted event'sdomainis'renderer'(or the validated fallback), not'db'.
Context
- WG: Observability & DX (security — trust boundary)
- Priority: Low (good first issue)
- Estimated effort: 15-20 minutes
Hi @samzong, Thanks for opening an issue! We will look into it as soon as possible.
Details
Instructions for interacting with me using comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.
The as 'renderer' cast is masking runtime input — I'd just hard-code domain: 'renderer' and drop payload.domain entirely, since the IPC channel name already tells us where the event came from. Sending a fix.