http2: avoid uaf while receiving and sending rst_stream#64166
Conversation
|
Review requested:
|
|
Can you use "-s" (for Signed-off-by) in first commit command, after run this command after: |
Mark the session as receiving around nghttp2_session_mem_recv() and defer RST_STREAM handling while receive is in progress. This prevents closing a stream while nghttp2 still processes it and avoids heap-use-after-free in nghttp2_session_mem_recv2(). Fixes: nodejs#64113 Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
|
Is everything correct now? |
RafaelGSS
left a comment
There was a problem hiding this comment.
Can you add a test case or an script that we could reproduce it?
The scripts are in the issue #64113 |
|
If you mean replace the code with this then it fixes uaf, but I get these failed tests: Or if I misunderstood you, please write your version. |
|
Ah, interesting, yes we'll have to investigate that @Eusgor. I took a bit more of a look, I think this is part of a bigger more fundamental issue - the nghttp2 docs say:
And in this method, we call The tests are reasonable (e.g. destroy after write - it should flush the written data before the stream is destroyed) but this method we're changing isn't - it should never call I had Claude do a quick scan, there's at least three places we ignore this nghttp2 requirement:
All of those are issues (good find!) and the new Can you take a look? Really I think we need to always defer anything anything that could call one of those methods while receiving - that means something like early-return in |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64166 +/- ##
==========================================
- Coverage 92.01% 90.24% -1.77%
==========================================
Files 379 739 +360
Lines 166972 241720 +74748
Branches 25554 45561 +20007
==========================================
+ Hits 153639 218150 +64511
- Misses 13041 15112 +2071
- Partials 292 8458 +8166
🚀 New features to boost your workflow:
|
62ef872 to
d1de20f
Compare
nghttp2 forbids calling nghttp2_session_mem_send() from mem_recv callbacks. Signed-off-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>
Mark the session as receiving around nghttp2_session_mem_recv() and defer RST_STREAM handling while receive is in progress. This prevents closing a stream while nghttp2 still processes it and avoids heap-use-after-free in nghttp2_session_mem_recv2().
Fixes: #64113