#6854: fix(abort): add size limit to ABORT_MEMORY map to prevent memory leak
Cluster:
Memory Management Enhancements
## Summary
Fix [CWE-770](https://cwe.mitre.org/data/definitions/770.html) vulnerability in `src/auto-reply/reply/abort.ts`.
**Problem**: `ABORT_MEMORY` Map has no cleanup mechanism — entries accumulate indefinitely causing memory leak.
**Fix**: Add size limit (10k entries) + delete entry on `setAbortMemory(key, false)` instead of storing `false`.
## Risk Summary
- **Severity**: Medium (CWE-770 — Allocation of Resources Without Limits)
- **Regression risk**: None — adds eviction only when map exceeds 10k, existing behavior unchanged below limit
- **Scope**: Single file, 1 function modified
## Changes
- `src/auto-reply/reply/abort.ts`: Add `MAX_ABORT_ENTRIES` constant and modify `setAbortMemory()` to:
- Delete entry when value is `false` (wires into existing cleanup path in `body.ts:40`)
- Evict oldest entry (FIFO) when map reaches 10k entries
## Verification
- [x] `pnpm build` passes
- [x] `pnpm lint` passes (0 warnings, 0 errors)
- [x] `pnpm test` passes (804 test files, 4969 tests)
## Sign-Off
- Models used: Claude Opus 4.6
- Submitter effort: Traced ABORT_MEMORY lifecycle through abort.ts and body.ts, verified FIFO eviction uses Map iteration order (insertion order per spec), confirmed delete-on-false wires into existing cleanup
- Agent notes: N/A
lobster-biscuit
Most Similar PRs
#6923: fix(memory): add timeouts to Gemini batch API fetch calls (CWE-400)
by hclsys · 2026-02-02
63.8%
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
62.2%
#22143: Fix memory leak in WhatsApp channel reconnection loop
by lancejames221b · 2026-02-20
62.1%
#17823: fix: memory leak in cron isolated runs — agent-events Maps never cl...
by techboss · 2026-02-16
61.2%
#23744: fix(memory): add max size eviction to session manager cache
by kevinWangSheng · 2026-02-22
60.1%
#23311: fix(memory): expose maxOutputChars as configurable qmd limit
by haitao-sjsu · 2026-02-22
60.0%
#7187: fix(gateway): suppress AbortError during shutdown
by hclsys · 2026-02-02
60.0%
#16196: fix(gateway): add periodic cleanup to prevent memory leak in ToolEv...
by bianbiandashen · 2026-02-14
60.0%
#23745: fix(resilience): add timeout to unguarded fetch calls in browser su...
by kevinWangSheng · 2026-02-22
59.8%
#21016: Fix memory_forget candidate IDs to prevent deletion retry loop
by natustx · 2026-02-19
59.7%