-
Notifications
You must be signed in to change notification settings - Fork 10
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
Is this secure? #5
Comments
Good question! Short answer: No, this approach is not yet secure against malicious actors. However, if we assume non-malicious actors and typical (static or dynamic) linking conditions, then it's not unreasonable to consider it sound. Longer answer: Three things are serialized alongside the vtable pointer for the purpose of validation:
At some point in Rust's future, I think it would be great if the latter could be used to safely look up and create a trait object. As it is, that functionality doesn't exist yet, so what this crate does instead is serialize the vtable pointer (relative to a static base), and do as much validity checking as it reasonably can before it can be used and potentially invoke UB. The first two are checked for validity before usage of the vtable pointer. The Regarding collisions, the 128 bit The vtable pointer is (de)serialized as a usize relative to the vtable pointer of this static trait object. This enables it to work under typical dynamic linking conditions, where the absolute vtable addresses can differ across invocations of the same binary, but relative addresses remain constant. All together this leaves, as far as I'm aware, three soundness holes:
1I don't think this requirement is strictly necessary, as the The documentation definitely needs to include this information so I've gone ahead and added it. My use case includes serializing trait objects where the traits are implemented on generic types, which I don't believe is compatible with the |
Thank you for addressing this! I have an idea for a typetag-style system that would allow the serialization of parametric traits -- if you'd like, I'll message you if I get that figured out. |
@gretchenfrage I'd love to hear if you've made any progress on that? |
Add .editorconfig for tab_width = 4
I just looked through the code a bit, and I was amazed when I saw that you're bypassing the need to register traits by actually making a virtual function call into the vtable pointer. I wouldn't have thought of that. My question is, is this secure, and is it safe?
It seems like attempting to deserialize a bad vtable pointer, intentionally or unintentionally, could allow the execution of arbitrary memory regions, which seems like both a massive security flaw, and unsafe in that it could cause undefined behavior. Am I wrong about this?
It seems like, unless there's some verification that I missed, this needs to be addressed.
The text was updated successfully, but these errors were encountered: