Crates.io | detrojt |
lib.rs | detrojt |
version | 0.1.1 |
source | src |
created_at | 2017-07-08 17:46:41.551893 |
updated_at | 2017-07-08 17:51:39.840249 |
description | A hack to support deserialization of arbitrary trait objects |
homepage | |
repository | https://github.com/Rufflewind/detrojt |
max_upload_size | |
id | 22639 |
size | 30,738 |
Documentation for the master
branch
A dirty hack to support deserialization of arbitrary trait objects.
This is a proof-of-concept created in response to rust-lang/rfcs#668 as well as Dmitry Gordon's question How can deserialization of polymorphic trait objects be added in Rust if at all? (related Rust Forum post).
Deserialization may cause arbitrary code execution. The library has some sanity checks to make it hard to accidentally screw up, but there's no guarantee that this library is safe against a malicious attacker.
Even for trusted data, deserializing may cause undefined behavior on platforms and configurations that violate any of the following assumptions:
{ data: *mut _, vtable: *mut _ }
{ destructor: fn(_), size: usize, alignment: usize, ... }
/dev/random
or /dev/null
(it shouldn't be too hard to port this to other platforms)If Rust adds support for #[repr(align = "N")]
, it may be possible to use a custom alignment as a secondary sanity check.