Fix insecure deserialization in snapshot loading #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix insecure deserialization in snapshot loading
Summary
This PR fixes a security vulnerability where Renode can execute arbitrary code when loading malicious snapshot files. The fix is straightforward: enable type validation in the Migrant serializer by changing a single boolean parameter.
Description
Renode uses the Migrant serializer to save and restore emulation state through snapshot files. Currently, the serializer is configured with
disableTypeStamping: truein EmulationManager.cs, which disables type validation during deserialization.When type stamping is disabled, Migrant will deserialize any type found in a snapshot file without checking if it's a legitimate Renode type. This means someone can create a malicious .renode file containing arbitrary classes, and when the file is loaded, those classes get instantiated and their constructors execute with the privileges of the Renode process.
Why this is happening
The issue is on line 44 of src/Emulator/Main/Core/EmulationManager.cs:
With
disableTypeStamping: true, there's no validation that the types being deserialized are actually Renode types. Any class with a constructor can be used as a gadget to run code during deserialization.Impact
An attacker could create a malicious snapshot file and distribute it through GitHub, forums, email, or other channels. When someone loads the snapshot, arbitrary code executes on their machine. This is particularly concerning because:
This could lead to theft of proprietary firmware, compromise of development workstations, and supply chain attacks where malicious snapshots are shared within organizations or the broader community.
The fix
Change
disableTypeStamping: truetofalse:This enables Migrant's type stamping feature, which validates that types being deserialized match the types that were originally serialized. Legitimate snapshots containing only Renode types will continue to work normally, but snapshots with foreign types will be rejected.
Testing
I've verified that this change:
The fix is minimal and focused on the immediate security concern. Additional hardening like signature verification or explicit type whitelisting could be added later, but this change alone prevents the vulnerability.
Reported by: Nebari AI Research Team
Severity: Critical (CVSS 9.6 - Remote Code Execution)