Repository navigation
feat: aggregate audit denial floods per (action, agentId) (#114) - #148
Merged
Merged
Conversation
A denial flood (e.g. RATE_LIMITED long-poll rejections, M2) wrote one ~150 B row per event — unbounded audit growth from a self-DoS. Deny events now aggregate per (action, agentId) inside FileSecurityAuditLog: the first denial is written in full (forensic evidence), repeats within a 60 s window are counted, and the window closes with one aggregate row (kind: "aggregate", windowStart, count). Accept/degraded events are never aggregated. Windows flush on a 60 s unref'd timer and on the first event past the boundary; a relay crash loses only the unflushed count (the first event is already durable). SecurityEvent gains optional kind/windowStart/count; readers (readAuditTail, doctor) parse aggregates as ordinary rows — backward compatible. Tests: 5000-event flood writes 1 full + 1 aggregate + 1 (next window); per-key separation; accept events stay individual; readAuditTail reads aggregate rows; the existing tail test uses distinct keys so its intent (last-N readout) is preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема (issue #114)
Denial-события (напр. RATE_LIMITED-отказы long-poll, M2) писали по строке ~150 B в audit JSONL без границ: цикл отказов раздувает лог бесконечно — self-DoS на диск. Признано автором #93 в брейншторме, подтверждено security-ревью.
Решение
Агрегация deny-событий per
(action, agentId)внутриFileSecurityAuditLog(не в call-site'ах — центральная точка, как store-level аудит в #3):{kind: "aggregate", windowStart, count, ...поля первого события}— тот же JSONL, обратная совместимость полная (старые строки безkind= одиночные события).flush()доступен для shutdown.Принятые ограничения (зафиксированы в команде)
Readers
readAuditTailпарсит агрегаты как обычные строки; doctor/status встраивают tail без изменений;readDirectoryHealth/readOpenCodeRegistrationsфильтруют по action/decision — поля агрегата совпадают, поведение не меняется.Тесты
count: 5000) + 1 первое событие следующего окна.readAuditTailчитает агрегатную строку (kind/count доезжают).Полный
pnpm verifyзелёный: 133 файла / 1195 тестов.Closes #114.