Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: fix a error in the check for frame->hd.type (related to CVE-2025-23085) #57644

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hgqxjj
Copy link

@hgqxjj hgqxjj commented Mar 27, 2025

http2: fix a typo in the check for frame->hd.type in 1b693fa

According to the description above, this should be checking
whether frame->hd.type is NGHTTP2_GOAWAY,
and the value of NGHTTP2_GOAWAY is 0x07. However,
it is written as 0x03 here, which I think it is a typo.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run. labels Mar 27, 2025
Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. Could you please add an additional test assertion to this? See the tests introduced by this change in 1b693fa

Copy link

codecov bot commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.22%. Comparing base (1123585) to head (2279ad5).
Report is 91 commits behind head on main.

Files with missing lines Patch % Lines
src/node_http2.cc 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57644      +/-   ##
==========================================
- Coverage   90.22%   90.22%   -0.01%     
==========================================
  Files         630      630              
  Lines      185055   185055              
  Branches    36216    36212       -4     
==========================================
- Hits       166975   166965      -10     
- Misses      11042    11050       +8     
- Partials     7038     7040       +2     
Files with missing lines Coverage Δ
src/node_http2.cc 84.63% <0.00%> (-0.25%) ⬇️

... and 22 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.

@hgqxjj
Copy link
Author

hgqxjj commented Mar 28, 2025

@RafaelGSS hi RafaelGSS, I have reviewed all your test files in 1b693fa, and it seems that none of them cover the Http2Session::OnFrameNotSent function test. I attempted to write a test for it, but it is quite difficult to trigger Http2Session::OnFrameNotSent with frame->hd.type equal to 0x07. Do you have any good ideas on how to achieve this? Alternatively, is it possible to merge this patch first if you think this modification is urgent.

@RafaelGSS
Copy link
Member

@hgqxjj, it seems your change is breaking test-http2-premature-close. This test is historically known for being flaky, so I'll re-run the suite just to make sure.

@hgqxjj
Copy link
Author

hgqxjj commented Mar 28, 2025

@RafaelGSS I think my change is unlikely to touch test-http2-premature-close. Maybe it still be flaky, haha

@hgqxjj
Copy link
Author

hgqxjj commented Mar 29, 2025

@RafaelGSS Unfortunately, the test failed again due to a timeout. I conducted the same test using different versions of Node.js in my side. When running test-http2-premature-close.js with Node.js 14.19, the program terminates as expected. However, when testing with Node.js 20.12, the program gets stuck.

Based on my analysis of the test-http2-premature-close.js script combined with debug logs, there are two errors in the client's header frame content.
1111

In Node.js 14.19, these errors cause the server to send an RST_STREAM upon receiving the header frame. For some reason, this also triggers the onFrameError function, leading to the session being closed, which subsequently triggers server.close(), allowing the program to terminate.
2
3

However, in Node.js 20.12, server seems to have ignored these errors and did not send RST_STREAM , and onFrameError is not triggered, and server.close() is not called, causing the program to hang. Therefore, the test failure does not seem to be related to my modifications but rather an issue with test-http2-premature-close.js itself.

@hgqxjj hgqxjj changed the title fix a typo in the check for frame->hd.type http2: fix a error in the check for frame->hd.type (relate to CVE-2025-23085) Mar 29, 2025
@hgqxjj hgqxjj changed the title http2: fix a error in the check for frame->hd.type (relate to CVE-2025-23085) http2: fix a error in the check for frame->hd.type (related to CVE-2025-23085) Mar 29, 2025
@hgqxjj
Copy link
Author

hgqxjj commented Apr 1, 2025

@RafaelGSS hi RafaelGSS,i already correct header frame content according to http2 related protocol so that make it exited successfully,please re-running the test suite to make sure at your convenience .

hgqxjj added 2 commits April 1, 2025 15:57
According to the description above, this should be
checking whether frame->hd.type is NGHTTP2_GOAWAY,
and the value of NGHTTP2_GOAWAY is 0x07. However,
it is written as 0x03 here, which I think
it is an error.
previously, due to some error in the content of
the header frame, the script could not exit properly,
which eventually led to a timeout error,this commit
correct header frame content according to http2
related protocol so that make it exited successfully.
correct comments
@hgqxjj
Copy link
Author

hgqxjj commented Apr 3, 2025

hi @RafaelGSS ,currently, all tests have passed. Could you please take some time to review this patch ? Thanks in advance

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 3, 2025
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

Failed to start CI
   ⚠  No approving reviews found
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/14248886630

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but this should wait @RafaelGSS approval too.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 4, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 4, 2025
@nodejs-github-bot
Copy link
Collaborator

@RafaelGSS
Copy link
Member

I will review this PR carefully tomorrow. I'll double check the memory leak.

@hgqxjj
Copy link
Author

hgqxjj commented Apr 8, 2025

hi @RafaelGSS , I'll paste some screenshots below to help explain the changes I made.
RFC7541 link is https://datatracker.ietf.org/doc/html/rfc7541#appendix-A

lx_clip1744102465680
lx_clip1744105000959

@RafaelGSS RafaelGSS added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. http2 Issues or PRs related to the http2 subsystem. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants