{"id":21159140,"url":"https://github.com/rufflewind/detrojt","last_synced_at":"2025-03-14T15:41:44.133Z","repository":{"id":57618481,"uuid":"92885917","full_name":"Rufflewind/detrojt","owner":"Rufflewind","description":"A hack to make arbitrary trait objects deserializable (requires POSIX + 64-bit)","archived":false,"fork":false,"pushed_at":"2018-01-19T04:12:32.000Z","size":1141,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T05:53:03.274Z","etag":null,"topics":["rust","serde","trait-object"],"latest_commit_sha":null,"homepage":"https://rufflewind.com/detrojt","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rufflewind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-30T23:49:27.000Z","updated_at":"2019-10-25T13:08:51.000Z","dependencies_parsed_at":"2022-09-08T08:11:08.111Z","dependency_job_id":null,"html_url":"https://github.com/Rufflewind/detrojt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rufflewind%2Fdetrojt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rufflewind%2Fdetrojt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rufflewind%2Fdetrojt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rufflewind%2Fdetrojt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rufflewind","download_url":"https://codeload.github.com/Rufflewind/detrojt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243602289,"owners_count":20317607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","serde","trait-object"],"created_at":"2024-11-20T12:59:41.284Z","updated_at":"2025-03-14T15:41:44.112Z","avatar_url":"https://github.com/Rufflewind.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deserializeable trait objects\n\n[![Documentation](https://docs.rs/detrojt/badge.svg)](https://docs.rs/detrojt)\n[![Crates.io](https://img.shields.io/crates/v/detrojt.svg)](https://crates.io/crates/detrojt)\n\n[Documentation for the `master` branch](https://rufflewind.com/detrojt)\n\nA dirty hack to support deserialization of arbitrary trait objects.\n\nThis is a proof-of-concept created in response to [rust-lang/rfcs#668](https://github.com/rust-lang/rfcs/issues/668) as well as Dmitry Gordon's question [*How can deserialization of polymorphic trait objects be added in Rust if at all?*](https://stackoverflow.com/q/44231020/440302) ([related Rust Forum post](https://users.rust-lang.org/t/reflection-in-rust/11069)).\n\n## Caveat emptor\n\n**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.\n\nEven for trusted data, deserializing may cause undefined behavior on platforms and configurations that violate any of the following assumptions:\n\n  - The data being deserialized was originally serialized by the exact same executable built under identical conditions (architecture, optimization levels, other compiler flags, etc)\n  - All vtables are mapped to a single contiguous block of memory, located at fixed positions relative to each other (same for every execution)\n  - Trait objects have the layout `{ data: *mut _, vtable: *mut _ }`\n  - Vtables have the layout `{ destructor: fn(_), size: usize, alignment: usize, ... }`\n  - A POSIX system with either `/dev/random` or `/dev/null` (it shouldn't be too hard to port this to other platforms)\n  - 64-bit pointers (not entirely necessary, but 32-bit pointers would make it easier to exploit)\n\nIf [Rust adds support for `#[repr(align = \"N\")]`](https://github.com/rust-lang/rust/issues/33626), it may be possible to use a custom alignment as a secondary sanity check.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frufflewind%2Fdetrojt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frufflewind%2Fdetrojt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frufflewind%2Fdetrojt/lists"}