CVE-2022-24720

9.8 CRITICAL

📋 TL;DR

CVE-2022-24720 is a critical command injection vulnerability in the image_processing Ruby gem that allows attackers to execute arbitrary shell commands when processing user-supplied image operations. This affects any application using image_processing gem versions before 1.12.2, particularly Ruby on Rails applications with Active Storage that process user-uploaded images.

💻 Affected Systems

Products:
  • image_processing Ruby gem
  • Ruby on Rails Active Storage
Versions: image_processing < 1.12.2
Operating Systems: All operating systems running vulnerable Ruby applications
Default Config Vulnerable: ⚠️ Yes
Notes: Active Storage variants automatically call the vulnerable #apply method when processing user-uploaded images.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with remote code execution leading to data theft, ransomware deployment, or complete server takeover.

🟠

Likely Case

Unauthorized shell command execution allowing file system access, data exfiltration, or lateral movement within the environment.

🟢

If Mitigated

Limited impact with proper input validation and sanitization preventing command injection.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires user input to reach the vulnerable #apply method, which is common in image upload scenarios.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.12.2

Vendor Advisory: https://github.com/janko/image_processing/security/advisories/GHSA-cxf7-qrc5-9446

Restart Required: Yes

Instructions:

1. Update Gemfile to require 'image_processing', '>= 1.12.2'
2. Run 'bundle update image_processing'
3. Restart your Ruby application server

🔧 Temporary Workarounds

Input Sanitization Workaround

all

Sanitize user input by allowing only a constrained set of image processing operations before passing to image_processing.

🧯 If You Can't Patch

  • Implement strict input validation to only allow predefined safe image processing operations
  • Disable image processing for user-uploaded content or use alternative image processing libraries

🔍 How to Verify

Check if Vulnerable:

Check Gemfile.lock or run 'bundle show image_processing' to see installed version

Check Version:

bundle show image_processing | grep -o 'image_processing.*'

Verify Fix Applied:

Verify image_processing version is 1.12.2 or higher using 'bundle show image_processing'

📡 Detection & Monitoring

Log Indicators:

  • Unusual shell commands in application logs
  • Suspicious image processing parameters containing shell metacharacters

Network Indicators:

  • Outbound connections from application server to unexpected destinations

SIEM Query:

source="application.log" AND ("image_processing" OR "Active Storage") AND ("apply" OR "shell")

🔗 References

📤 Share & Export