-
Notifications
You must be signed in to change notification settings - Fork 281
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
Potential buffer overflow in geotag.cpp on non-glibc systems #382
Comments
Thank you for reporting this. Do you have a proposed fix? I'm lost in your explanation. You'll be aware that realpath() is platform dependent. Are you talking about Linux? samples/geotag.cpp is sample code and we have a test in our test suite for that code. So the code is working on the supported platforms. Do you have a test case which fails, or is this a "potential" vulnerability? Or are you saying that we should be calling pathconf() on Linux? |
Thank for taking look into this, |
Gosh, you're quick! Thanks for such a speedy response. I haven't thought about this matter for years, however here's a way of testing it.
I've modified the code where realpath() is used as follows:
To test this:
Is that what you are thinking? |
Yup, the modified code for |
Patch:
@D4N Can you review and submit this for me please? |
Sorry, I'm a little late. To be honest I don't see the problem with the usage of
So in my eyes the code does exactly what it should be doing on Linux + glibc and it shouldn't create any issues. That is further indicated by the existence of glibc's I believe however that the behavior is definitely broken on POSIX systems where the libc does not @clanmills The proposed patch actually makes the |
I found that overflow here,
I believe over her |
@RootUp Please provide a command-line that produces an overflow. @D4N You're quite right that _MAX_PATH is an MSVC thing and defined (without reason) for Linux in geotag.cpp. When I looked at this on Sunday, I thought "I really don't know what's being discussed here, however perhaps we should call So gentlemen: can we determine and focus on a solid issue. How do we reproduce the overflow? |
@RootUp That is however potentially problematic if you have a path that is longer than 1024 bytes. So we have to fix this on POSIX systems that are not using glibc. |
I agree with the analysis done by @D4N here. Anyways, note that this file is a sample application, and maybe we should not get paranoid about it. If the code would have been in the library code I would not say the same, but in a sample application I could live with this situation 😺 . |
Since this has been opened for few months without taking any action about it, I'm going to close it. @RootUp feel free to reopen it if you find an example of how to reproduce the issue. |
File: geotag.cpp
and
According to the documentation of
realpath()
the output buffer needs to be at least of sizePATH_MAX
specifying output buffers large enough to handle the maximum-size possible result from path manipulation functions. In that instance, buf's size comes fromuv__fs_pathmax_size()
. That function attempts to usepathconf(path, _PC_PATH_MAX)
as noted in the realpath(3) docs.But over here
uv__fs_pathmax_size()
norpathconf(path, _PC_PATH_MAX)
is used.Passing an inadequately-sized output buffer to a path manipulation function can result in a buffer overflow. Such functions include
realpath()
readlink()
PathAppend()
and others.The text was updated successfully, but these errors were encountered: