CVE-2021-22885

7.5 HIGH

📋 TL;DR

This vulnerability in Ruby on Rails Action Pack allows attackers to perform information disclosure or unintended method execution when using redirect_to or polymorphic_url helpers with untrusted user input. It affects Ruby on Rails applications using Action Pack version 2.0.0 and later. Attackers can potentially redirect users to malicious sites or execute unintended controller methods.

💻 Affected Systems

Products:
  • Ruby on Rails Action Pack
Versions: >= 2.0.0, < 6.1.3.2, < 6.0.3.7, < 5.2.4.6, < 5.1.7
Operating Systems: All operating systems running Ruby on Rails
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using redirect_to or polymorphic_url helpers with untrusted user input

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full application compromise through remote code execution or sensitive data exfiltration via crafted redirects

🟠

Likely Case

Open redirect attacks leading to phishing, session theft, or limited information disclosure

🟢

If Mitigated

Minimal impact with proper input validation and URL sanitization in place

🌐 Internet-Facing: HIGH - Web applications are directly exposed to attackers who can craft malicious URLs
🏢 Internal Only: MEDIUM - Internal applications still vulnerable but attack surface is reduced

🎯 Exploit Status

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

Exploitation requires crafting malicious URLs that get passed to vulnerable helpers

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 6.1.3.2, 6.0.3.7, 5.2.4.6, 5.1.7

Vendor Advisory: https://weblog.rubyonrails.org/2021/5/5/Rails-6-1-3-2-6-0-3-7-5-2-4-6-and-5-1-7-have-been-released/

Restart Required: Yes

Instructions:

1. Update Gemfile to specify patched Rails version. 2. Run 'bundle update rails'. 3. Restart application server. 4. Test redirect functionality.

🔧 Temporary Workarounds

Input Validation Workaround

all

Validate and sanitize all user input before passing to redirect_to or polymorphic_url helpers

URL Whitelisting

all

Implement URL whitelisting for redirect destinations

🧯 If You Can't Patch

  • Implement strict input validation for all user-provided URLs
  • Use WAF rules to detect and block malicious redirect patterns

🔍 How to Verify

Check if Vulnerable:

Check Rails version with 'rails --version' or examine Gemfile.lock for Action Pack version

Check Version:

rails --version

Verify Fix Applied:

Verify Rails version is >= 6.1.3.2, 6.0.3.7, 5.2.4.6, or 5.1.7 depending on your major version

📡 Detection & Monitoring

Log Indicators:

  • Unusual redirect patterns
  • Redirects to external domains from user input
  • Multiple failed redirect attempts

Network Indicators:

  • HTTP 302 redirects to suspicious domains
  • URLs with encoded payloads in redirect parameters

SIEM Query:

event_type:web_access AND (status_code:302 OR status_code:301) AND url:*redirect* AND NOT destination_domain:trusted_domains

🔗 References

📤 Share & Export