Skip to main content
CriticalCodeOWASP A08:2021CWE-502

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

  1. 1Never call Marshal.load on request-derived or otherwise untrusted data.
  2. 2Use JSON (JSON.parse) or another schema-constrained format for any data crossing a trust boundary.
  3. 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

Ruby
# 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.

See every code check

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.

Propose a checkHow a check is built

Scan your own site for ruby marshal.load() called with request data

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

Ruby Marshal.load() Called With Request Data fix | VulnRadar