Skip to content

quic: reject zero addressLRUSize - #65827

Open
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:quic-fix-address-lru-size-zero
Open

quic: reject zero addressLRUSize#65827
christianaurichzm wants to merge 1 commit into
nodejs:mainfrom
christianaurichzm:quic-fix-address-lru-size-zero

Conversation

@christianaurichzm

Copy link
Copy Markdown
Contributor

new QuicEndpoint({ addressLRUSize: 0 }) crashes with a SIGSEGV on the first UDP packet received by the endpoint.

SocketAddressLRU<T>::Upsert inserts an entry and then evicts entries until the cache is within max_size_. With max_size_ == 0, the newly inserted entry is immediately removed. The final map_[address]->second then inserts a default-constructed std::list iterator and dereferences it, resulting in undefined behavior.

address_lru_size currently accepts any non-negative uint64_t, so both 0 and 0n can reach SocketAddressLRU. This changes the endpoint option validation to reject zero instead.

I reproduced the crash with an --experimental-quic build using listen() + connect(). The core dump goes through Endpoint::Receive and Endpoint::UDP::Impl::OnReceive. With this change, addressLRUSize: 0 throws ERR_INVALID_ARG_VALUE, while addressLRUSize: 1 still completes the handshake.

Added 0 and 0n to the existing invalid addressLRUSize test cases. All test/parallel/test-quic-*.mjs tests pass.

SocketAddressLRU::Upsert always inserts an entry before evicting down
to max_size_. With max_size_ == 0, it evicts the entry it just
inserted and then accesses the now-missing key via
map_[address]->second. operator[] recreates the key with a
default-constructed std::list iterator, which is then dereferenced.
This is undefined behavior, observed as a SIGSEGV in Endpoint::Receive
on the first UDP packet accepted by a QuicEndpoint constructed with
{ addressLRUSize: 0 }.

SocketAddressLRU has no useful semantics for a zero-capacity cache,
and Upsert's callers rely on it returning a valid pointer. Reject 0
(and 0n) at the options-parsing boundary instead of changing Upsert's
contract.

Signed-off-by: Christian Aurich <[email protected]>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/quic

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. quic Issues and PRs related to the QUIC transport implementation. labels Sep 5, 2026
@bjohansebas bjohansebas added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 5, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 5, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.17%. Comparing base (b265340) to head (6f29f75).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65827      +/-   ##
==========================================
- Coverage   90.18%   90.17%   -0.01%     
==========================================
  Files         770      770              
  Lines      264410   264410              
  Branches    50230    50236       +6     
==========================================
- Hits       238449   238439      -10     
- Misses      16966    16975       +9     
- Partials     8995     8996       +1     

see 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. quic Issues and PRs related to the QUIC transport implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants