Repository navigation
Description
Affected layers
- Backend (
server/): affected.readJsonWithLimitinserver/src/bounded-json.tscounts the bytes it receives against a limit, but keeps every chunk the stream delivers as a separate object until the body ends. Each chunk costs a fixed overhead on top of its bytes, so a peer that sends its body in tiny pieces makes the read hold far more memory than its limit. It has two callers.fetchMonitoringJsoninserver/src/index.tsreads the monitoring APIs for the Telegram snapshot with a 1 MiB limit. The Telegram API client inserver/src/telegram.tsuses a 4 MiB limit, but its peer isapi.telegram.orgover TLS, so the monitoring peer is the practical source. - Frontend (
src/): not affected. shared/: not affected.
Problem
The limit bounds the body's bytes, not the memory the read holds. Reproduced on main at ed7d84b with the Loupe test under Node 24: a valid JSON answer of 512 KiB, half the monitoring limit, delivered one byte per chunk, exhausts a 48 MiB heap. Over a real local connection, Loupe measured about 11 MiB retained for a 50 KB body sent as one-byte chunks within the 5-second deadline. How finely a real connection delivers a body depends on timing, so the amplification in practice is lower than the stream test's.
Impact
Whoever controls a monitoring peer, in practice a compromised mining container, can make each Telegram snapshot read hold many times its 1 MiB limit. Those reads run every few seconds while Telegram alerts are paired and enabled, with no browser open, and on a memory-constrained host they can exhaust the management process, which holds the Docker socket. The same attacker already has an unbounded path through the two monitoring proxies until #397 is fixed. Loupe rates it medium.
Expected outcome
- The memory a bounded response read holds stays proportional to the bytes it accepted, plus a fixed allowance, however the peer splits the body into chunks.
- Answers within the limit are parsed as today, and answers over it are rejected as today.
Loupe findings
- project-loupe/audit-sv2-ui#114: the bounded JSON reader keeps one object per received chunk until the body ends
Related issues and PRs
- http-boundary: a monitoring proxy forwards at most a bounded response body #397 asks for a bound on the two monitoring proxies, which buffer with no limit at all. A fix there that reads through this helper would inherit this defect, so the two should land together.
- http-boundary: monitoring reads never follow a redirect away from the monitoring service #403 covers the same Telegram monitoring reader following redirects.
- Add Experimental Telegram integration to get notifications (block found, best diff, workers connections) #228 added this reader.
- Tracker: [Tracker] Request origin and HTTP boundary #369.
Activity