LevelBlue Completes Acquisition of Cybereason. Learn more

LevelBlue Completes Acquisition of Cybereason. Learn more

Services
Cyber Advisory
Managed Cloud Security
Data Security
Manage Detection & Response
Email Security
Managed Network Infrastructure Security
Exposure Management
Security Operations Platforms
Incident Readiness & Response
SpiderLabs Threat Intelligence
Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Operational Technology
End-to-end OT security
Microsoft Security
Unlock the full power of Microsoft Security
Securing the IoT Landscape
Test, monitor and secure network objects
Why LevelBlue
About Us
Awards and Accolades
LevelBlue SpiderLabs
LevelBlue Security Operations Platforms
Security Colony
Partners
Microsoft
Unlock the full power of Microsoft Security
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings

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!

ABOUT LEVELBLUE

LevelBlue is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo