-
Notifications
You must be signed in to change notification settings - Fork 5
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
uplink(fix): Fix use-after-free bug in edge::Gateway
#80
Conversation
fyi @ifraixedes - this is potentially a security vulnerability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GodTamIt good catch!
I detected these issues when I wrote one of the first integration tests. When I realized the problem, I changed all of them to types that Rust owns rather than dragging references to C pointers.
I changed all of those structs that I found however, I missed some that I changed when later I realized (e.g. 9bb1cfb).
I missed this one. One of the reasons is that there is no integration test for it https://github.com/storj-thirdparty/uplink-rust/blob/main/uplink/tests/edge_test.rs#L8
Thank you very much for your contribution.
@ifraixedes yep, all done! Thanks for the quick reviews :) Aside: for some of the memory freeing code paths, what's your opinion on using something like |
edge::Gateway
edge::Gateway
I got a suggestion when I talked about building this in a meetup. They said:
I stated it as a good idea. Unfortunately, I didn't think about it when I implemented it 😬 Did I respond to your question? |
Yeah that does. If I have some time, I could explore doing something like that. Otherwise, the library is working as intended so not critical. Just helps prevent leaks and bugs :) |
@GodTamIt the build fails because of unrelated issues. I'm addressing them |
You'll need to rebase once I merge #82 |
@GodTamIt it's merged. |
Previously, `from_ffi_credentials_result()` would free the underlying memory of the strings stored in `Gateway` (the FFI `EdgeCredentialsResult`) upon success, resulting in a use-after-free error for anyone trying to access those strings. Unfortunately, this will be a breaking change.
@ifraixedes it's rebased |
@GodTamIt I will make a new release later today or tomorrow. |
Previously,
from_ffi_credentials_result()
would free the underlying memory of the strings stored inGateway
(the FFIEdgeCredentialsResult
) upon success, resulting in a use-after-free error for anyone trying to access those strings.Unfortunately, this will be a breaking change.