CVE-2020-8165

9.8 CRITICAL

📋 TL;DR

This vulnerability allows remote code execution in Ruby on Rails applications using MemCacheStore or RedisCacheStore for caching. Attackers can exploit deserialization of untrusted data to execute arbitrary code on affected systems. Applications running Rails versions below 5.2.4.3 or 6.0.3.1 with these cache stores are vulnerable.

💻 Affected Systems

Products:
  • Ruby on Rails
Versions: Rails < 5.2.4.3, Rails < 6.0.3.1
Operating Systems: All operating systems running affected Rails versions
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using MemCacheStore or RedisCacheStore for caching. Other cache stores are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with attacker gaining remote code execution, potentially leading to data theft, lateral movement, or complete system takeover.

🟠

Likely Case

Remote code execution leading to application compromise, data exfiltration, and potential pivot to other systems in the network.

🟢

If Mitigated

Limited impact with proper network segmentation, minimal privileges, and monitoring in place, though RCE would still be possible.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the attacker to be able to send malicious cache data to the vulnerable cache store endpoints.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Rails 5.2.4.3, Rails 6.0.3.1

Vendor Advisory: https://groups.google.com/g/rubyonrails-security/c/bv6fW4S0Y1c

Restart Required: Yes

Instructions:

1. Update Rails gem to version 5.2.4.3 or higher for Rails 5.2.x, or 6.0.3.1 or higher for Rails 6.0.x. 2. Update Gemfile to specify the patched version. 3. Run bundle update rails. 4. Restart the Rails application server.

🔧 Temporary Workarounds

Switch to alternative cache store

all

Temporarily switch from MemCacheStore or RedisCacheStore to a non-vulnerable cache store like FileStore or MemoryStore

# In config/environments/production.rb
config.cache_store = :file_store, 'tmp/cache/'

🧯 If You Can't Patch

  • Implement strict network controls to limit access to cache store endpoints (typically TCP ports 11211 for Memcached or 6379 for Redis)
  • Monitor cache store access logs for unusual patterns and implement rate limiting on cache operations

🔍 How to Verify

Check if Vulnerable:

Check Rails version in Gemfile.lock or run 'rails --version' and verify if below 5.2.4.3 or 6.0.3.1, and check if using MemCacheStore or RedisCacheStore in config files.

Check Version:

rails --version

Verify Fix Applied:

Verify Rails version is 5.2.4.3+ or 6.0.3.1+ and restart application, then test cache functionality remains working.

📡 Detection & Monitoring

Log Indicators:

  • Unusual cache store access patterns
  • Errors in Rails logs related to cache deserialization
  • Unexpected process execution from Rails application

Network Indicators:

  • Unusual traffic to Memcached (port 11211) or Redis (port 6379) endpoints
  • Suspicious payloads in cache store communications

SIEM Query:

source="rails.log" AND ("cache_store" OR "MemCache" OR "RedisCache") AND ("deserialization" OR "marshal" OR "unmarshal")

🔗 References

📤 Share & Export