-
Notifications
You must be signed in to change notification settings - Fork 52
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
Write-based buffer overflow in uvwasi__normalize_path #251
Comments
Thank you for sharing this case and for fuzzing new cases in the codebase, it's great to verify these API surfaces. As you note, the specific function call contract for Were you able to tell if there is any potential for this case given the current call site usage? Then further, can you clarify the alternative refactoring you were suggesting here? Is the suggestion to instead have the len be a definition of the length that includes the zero byte? |
@AdamKorcz any chance you can answer:
|
Apologies for the delay.
Yes. As I see it there are probably these options:
Am not sure if you mean if we found any potential uses of the code that could misuse it? If so, then no. The only place could perhaps be the test where the size is not indicated explicitly to be |
@DavidKorczynski, I'm good with option 3 |
Fixes: nodejs#251 Signed-off-by: David Korczynski <david@adalogics.com>
This is a disclosure for an issue in node.js's use of UVWASI that we have found during a security audit of node.js.
The issue is a heap write-based buffer overflow in
src/path_resolver.c:uvwasi__normalize_path
. The issue was found by the following fuzzer:The fuzzer finds an issue with the following ASAN report:
The issue occurs on line 141 in
path_resolver.c
:uvwasi/src/path_resolver.c
Lines 139 to 141 in 2d0c0d0
The problem is that
ptr += cur_len
may setptr
to point atnormalized_path + normalized_len
which causes an off-by-one issue when thenormalized_len
corresponds to the size of the normalized_path buffer.The proposed fix is to check that
ptr
has not increased beyond the bounds ofnormalized_path
:It's important to highlight in this case that the function used within uvwasi always allocates an extra byte such as here and here. However, we consider it counter-intuitive that uvwasi__normalize_path reads beyond the specified length, this is made more counter-intuitive considering the tests of this function provides the size of the buffer and not 1 less than the size of the normalized buffer here.
Considering that the API is used correctly in the places it's called, we consider the best option to either change the tests to ensure proper sizing is enabled, or, better yet to ensure that the funtion does not read beyond the speified length and adjust the callers of the function accordingly.
The fuzzer we used for this is:
The text was updated successfully, but these errors were encountered: