CVE-2025-27111

7.5 HIGH

📋 TL;DR

CVE-2025-27111 is a log injection vulnerability in Rack's Sendfile middleware that allows attackers to inject escape sequences (like newlines) via the X-Sendfile-Type header. This can corrupt log files, potentially enabling log forging or log evasion attacks. All Ruby applications using vulnerable Rack versions with Sendfile middleware enabled are affected.

💻 Affected Systems

Products:
  • Rack (Ruby web server interface)
Versions: Rack versions before 2.2.12, 3.0.13, and 3.1.11
Operating Systems: All operating systems running Ruby applications with Rack
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using Rack::Sendfile middleware. Many Ruby web frameworks (Rails, Sinatra, etc.) use Rack by default.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could inject malicious content into log files, enabling log forging to hide other attacks, log evasion to bypass security monitoring, or potentially execute arbitrary code if logs are processed by vulnerable parsers.

🟠

Likely Case

Log file corruption and potential log evasion attacks that could help attackers hide other malicious activities from security monitoring systems.

🟢

If Mitigated

Minimal impact if proper log sanitization and monitoring are in place, though log integrity may still be compromised.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires sending HTTP requests with malicious X-Sendfile-Type headers. No authentication required if the application accepts external requests.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Rack 2.2.12, 3.0.13, or 3.1.11

Vendor Advisory: https://github.com/rack/rack/security/advisories/GHSA-8cgq-6mh2-7j6v

Restart Required: Yes

Instructions:

1. Update Gemfile to specify rack version >= 2.2.12, 3.0.13, or 3.1.11. 2. Run 'bundle update rack'. 3. Restart the application server. 4. Verify the update with 'bundle show rack'.

🔧 Temporary Workarounds

Disable Rack::Sendfile middleware

all

Remove or disable the Sendfile middleware if not required

# In config/environments/production.rb or similar
config.middleware.delete Rack::Sendfile

Input validation filter

all

Add middleware to sanitize X-Sendfile-Type header before it reaches Rack::Sendfile

# Add custom middleware before Rack::Sendfile
class SanitizeSendfileHeader
  def initialize(app)
    @app = app
  end
  
  def call(env)
    if env['HTTP_X_SENDFILE_TYPE']
      env['HTTP_X_SENDFILE_TYPE'] = env['HTTP_X_SENDFILE_TYPE'].gsub(/[\r\n]/, '')
    end
    @app.call(env)
  end
end

# Then in config:
config.middleware.insert_before Rack::Sendfile, SanitizeSendfileHeader

🧯 If You Can't Patch

  • Implement WAF rules to block requests containing newline characters in X-Sendfile-Type header
  • Monitor and alert on log anomalies or unexpected log file modifications

🔍 How to Verify

Check if Vulnerable:

Check Rack version with 'bundle show rack' or 'gem list rack'. If version is below 2.2.12 (for Rack 2.x), 3.0.13 (for Rack 3.0.x), or 3.1.11 (for Rack 3.1.x), the system is vulnerable.

Check Version:

bundle show rack || gem list rack | grep rack

Verify Fix Applied:

After updating, verify with 'bundle show rack' that version is 2.2.12+, 3.0.13+, or 3.1.11+. Test by sending requests with newlines in X-Sendfile-Type header and checking logs for injection.

📡 Detection & Monitoring

Log Indicators:

  • Unexpected newlines or escape sequences in log entries
  • Log entries that appear to span multiple lines incorrectly
  • Malformed log file structure

Network Indicators:

  • HTTP requests containing X-Sendfile-Type header with newline characters (\r, \n)
  • Unusual patterns in X-Sendfile-Type header values

SIEM Query:

http.headers:X-Sendfile-Type AND (http.headers:X-Sendfile-Type:"*\n*" OR http.headers:X-Sendfile-Type:"*\r*")

🔗 References

📤 Share & Export