0xMiden / 0xMiden/note-transport-service

Responses/streams are row-count-capped, not byte-capped — amplification and client wedge

Ouverte
#121 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
bug production-readiness
Langage dominant
Rust
Étoiles
3
Forks
10
Merge moyen
2 h 23 min
PR mergées (30 j)
4

Description

Severity: high.

### Summary

Batches are capped at 500 rows (`FETCH_NOTES_BATCH_SIZE`, `crates/node/src/database/sqlite/mod.rs:20`) with each note up to 512 KB, and no `max_encoding_message_size`/`max_decoding_message_size` is set anywhere. So:

- one ~20-byte `FetchNotes` request can pull a ~256 MB unary response, fully buffered in memory (amplification / memory-exhaustion lever, made worse by 4096 allowed concurrent requests);
- once 500 large notes accumulate past a client's cursor, every fetch of that batch **exceeds the client's default 4 MB decode limit** — the client can't decode, can't advance its cursor, and is permanently stuck. Same math applies to `StreamNotesUpdate` batches.

The decode side is also uncapped: the 512 KB `max_note_size` check runs only *after* tonic has decoded up to its 4 MiB default, so writes allocate ~8x the intended cap.

### Recommendation

- Cap batches by cumulative payload bytes (stop accumulating past ~1-3 MB, return the cursor) for both fetch and stream.
- Set explicit `max_encoding_message_size` and `max_decoding_message_size` (just above `max_note_size`) on the service.

Related: #46 (windowed pagination), #4 (pagination), #101 (cursor).

---
Part of #114.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.