Trustwave SpiderLabs Exposes Unique Cybersecurity Threats in the Public Sector. Learn More

Trustwave SpiderLabs Exposes Unique Cybersecurity Threats in the Public Sector. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Open Challenge: Ruby YAML.load(YOUR_STRING_HERE) == RCE?

For some, the challenge may already be quite clear by the title of this post, but I'm going to add a little color for the sake of clarity.

Background

Back in January 2013, there was a lot of excitement about a vulnerability in Ruby on Rails (CVE-2013-0156). In short, the vulnerability allowed a remote attacker to craft a request to Rails that would allow object creation via YAML deserialization and result in remote code execution (RCE). You can check the plethora of blog posts that covered the topic at the time to learn more (I've provided some of the better ones below as references).

Since that time, there has been a lot of discussion surrounding the use of Ruby YAML.load on user-controlled content in any Ruby application because of the RCE risk. And of course, I understand that it's important for us to learn from past mistakes and try to make a safer way to load YAML content. Examples of this include using something like YAML.safe_load or using white-listing techniques to restrict your object class exposure when you actually need to deserialize objects using YAML.load.

 

My Concerns

However, one of my concerns about such potential RCE scenarios, and maybe I'm not alone, is that of context. The issue I have with context is that in all the public PoC's I've observed, the attacker needed either an existing object behaving badly (ie. ActionController::Routing::RouteSet::NamedRouteCollection) or the creation of a contrived dangerous object being loaded manually to achieve such RCE.

The question I'd like posited is whether or not it's possible to achieve arbitrary RCE with a YAML.load using only standard lib objects, which are loaded by default. After all, if you're allowing the loading of dangerous/contrived objects with eval behavior, isn't this in the same vein as evaluating a user-controlled string?

I've done a little bit of poking around this topic myself and frankly, I've come up short. I've even consulted other fellow Rubyists to provide such an example, and I've yet to get a positive response that was acceptable to demonstrate such a risk.

 

The Challenge

As a Rubyist and a Security professional, I'm compelled to test such things and seek the truth. As such, I'm opening up a community challenge to see if there are some smart people out there willing to take on such a challenge.

Here are the basic constraints:

  • Must use a currently supported Ruby version
  • Must be a string that is supplied to the YAML.load function
  • Must use STDLIB only (ie. whatever's available to you after typing "irb" at a command prompt, no additional libs, requires, or .irbrc-type behavior)
  • Must be able to do something with the RCE (i.e., throw a shell, exfill, etc.)

The challenge is open as of now and will be completed on Thursday, May 14th. I will update this post as soon as the challenge is solved or will provide an update if it goes unsolved in the time window.

 

Submissions

Please submit your solutions to the challenge by sending an e-mail to trustwaveadvisories@trustwave.com and include the subject line "Ruby YAML.load Challenge".

References

***UPDATE - May 29, 2015--No one solved the challenge, bummer. Thanks for playing!

Latest SpiderLabs Blogs

2024 Public Sector Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies

Trustwave SpiderLabs’ 2024 Public Sector Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies report details the security issues facing public sector security teams as...

Read More

How to Create the Asset Inventory You Probably Don't Have

This is Part 12 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

Guardians of the Gateway: Identity and Access Management Best Practices

This is Part 10 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More