How to fix: Ruby Marshal.load() Called With Request Data
Ruby's Marshal.load() is called directly with params/request data.
Why it matters
Marshal.load can instantiate arbitrary Ruby objects and invoke their initializer/finalizer methods during reconstruction, a documented gadget-chain RCE vector similar to Python pickle and Java native deserialization.
Marshal is Ruby's native, non-schema-constrained object serialization format. Ruby's own documentation warns against calling Marshal.load on data from an untrusted source for exactly this reason.
How to fix it
- 1Never call Marshal.load on request-derived or otherwise untrusted data.
- 2Use JSON (JSON.parse) or another schema-constrained format for any data crossing a trust boundary.
- 3If Marshal must be used for trusted internal caching, ensure the storage backend cannot be written to by external input.
Code examples
Use JSON instead of Marshal for untrusted data
# BAD
data = Marshal.load(params[:payload])
# GOOD
data = JSON.parse(params[:payload])References
Detected automatically by VulnRadar. The check id is code-deser-ruby-marshal-load, stable across every scan so you can filter or diff on it.
More code checks
- CriticalForm Submits Data Over Insecure HTTP
- MediumPotential Prototype Pollution Sinks Detected
- HighPotential Command Injection Vectors
- HighJWT Decoded Without Signature Verification
- HighPotential Path Traversal Vulnerability
- HighInsecure Authentication Mechanisms Detected
- HighPotential Insecure Deserialization
- Mediumeval() Usage in Inline Scripts
Questions
- How severe is Ruby Marshal.load() Called With Request Data?
- VulnRadar rates this critical severity in the code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id code-deser-ruby-marshal-load, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Ruby Marshal.load() Called With Request Data map to?
- It maps to CWE-502. In the OWASP Top 10 it falls under A08:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.