<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by handball10 on Medium]]></title>
        <description><![CDATA[Stories by handball10 on Medium]]></description>
        <link>https://medium.com/@handball10?source=rss-a6466bb20d42------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by handball10 on Medium</title>
            <link>https://medium.com/@handball10?source=rss-a6466bb20d42------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 09:04:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@handball10/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From self XSS to RCE in Ruby on rails]]></title>
            <link>https://handball10.medium.com/from-self-xss-to-rce-in-ruby-on-rails-1f9f2d33c1cb?source=rss-a6466bb20d42------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f9f2d33c1cb</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[remote-code-execution]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[xss-attack]]></category>
            <dc:creator><![CDATA[handball10]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 06:44:58 GMT</pubDate>
            <atom:updated>2025-04-10T06:44:58.361Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there,<br>this is my first blog post here about a recent interesting finding I came accross on a private bug bounty target.</p><p><strong>Discovery</strong></p><p>Using subfinder I found the service which basically provided a sign up form and only a profile page. Additionally there was a possibily to register for specific surveys to attend from time to time.</p><p>Wappalyzer noted that the page was built with Ruby on Rails.<br>In total the page had no exiting functionality to explore and was very limited (only a small set of registered users which led to a later downgrade of the bounty to a tier 3 asset)</p><p>I initially checked for some XSS within the profile fields and found that the first name was vulnerable to stored self-XSS using a payload like:</p><pre>&quot;onfocus=&quot;alert(1)&quot; autofocus=&quot;</pre><p>The question was how to escalate this finding as I was just annoying myself?<br>I decided to take a break and switch to another subdomain of the program.</p><p><strong>The return and fuzzing to the win!</strong></p><p>After some days I decided to come back and do some basic fuzzing with ffuf. There were no special findings except one that caught my attention:</p><p>The page returned a large response when adding .pdf to the end of the url 🙈</p><p>I quickly opened the page with the url https://subdomain.redacted.com/.pdf</p><p>To my surprise the landing page content was returned as a PDF document.</p><p>WTF?</p><p>Testing other paths showed the same behaviour and the server returned the requested pages as PDF document…</p><p><strong>The pdf document</strong></p><p>When analyzing the pdf using FileAlayzer revealed, that the file was created with wkhtmltopdf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRbS_4NUTC6qdjyEoO_oiw.png" /></figure><p>Remember the stored self-XSS? How about trying to turn this into a server side xss and reading local files and escalate this?</p><p>Requesting https://subdomain.redacted.com/start/profile.pdf rendered the profile data page in a PDF aaaaand — it was a match 😍</p><p>My self-XSS was rendered in the PDF… 🎉</p><p><strong>Exploitation</strong></p><p>I now tried different methods described here: <a href="https://medium.com/r3d-buck3t/xss-to-exfiltrate-data-from-pdfs-f5bbb35eaba7">https://medium.com/r3d-buck3t/xss-to-exfiltrate-data-from-pdfs-f5bbb35eaba7</a></p><p>I tried to read local files using</p><pre>&quot;&gt;&lt;iframe src=&quot;file:///etc/passwd&quot;&gt;&lt;/iframe&gt;</pre><p>but had no success and the iframe was empty every time. Looks like that the flag --enable-local-file-access was not set so it blocked the access to local files.</p><p>Also trying to request services on localhost was not successful as the server was somehow crashing every time and I had to wait for a restart.</p><p>In the next step, I tried to get some more information about the environment the renderer was running:</p><pre>&quot;onfocus=&quot;document.write(JSON.stringify(window.location));&quot;autofocus=&quot;</pre><p>This returned a PDF document with the following content:</p><pre>{&quot;origin&quot;:&quot;file://&quot;,&quot;hash&quot;:&quot;&quot;,&quot;href&quot;:&quot;file:////tmp/wicked_pdf20250319-23102-<br>1jmrqgy.html&quot;,&quot;pathname&quot;:&quot;//tmp/wicked_pdf20250319-23102-<br>1jmrqgy.html&quot;,&quot;hostname&quot;:&quot;&quot;,&quot;protocol&quot;:&quot;file:&quot;,&quot;port&quot;:&quot;&quot;,&quot;host&quot;:&quot;&quot;,&quot;search&quot;:&quot;&quot;}</pre><p>The temp file name prefix wicked_pdf caught my attention and a quick search led me to the github repo of wkhtmltopdf wrapper for Ruby on Rails: <a href="https://github.com/mileszs/wicked_pdf">https://github.com/mileszs/wicked_pdf</a></p><p>All right — we now know the wrapper for wkhtmltopd but we are not able to read local files 😞</p><p>When reading through the docs this was an interesting section:<br><a href="https://github.com/mileszs/wicked_pdf?tab=readme-ov-file#wicked_pdf-helpers">https://github.com/mileszs/wicked_pdf?tab=readme-ov-file#wicked_pdf-helpers</a></p><p>This looked like that it was possible in the html template file to use inline ruby code to include custom functions.</p><p>This brought up the following idea of how the content is being processed:</p><ol><li>page is rendered (our stored xss also happens)</li><li>html page content is passed to wicked_pdf which also executes inline ruby in the html file, then calls wkhtmltopdf</li><li>pdf document is served</li></ol><p>As the xss was working I though about what happens when trying to inject inline ruby tags?</p><pre>&quot;&gt;&lt;?= Time.now ?&gt;</pre><p>The result was very exciting!<br>Everytime I requested the PDF, I got the current server time being printed 🙈<br>I finally turned my self-XSS into a RCE:</p><pre>&quot;&gt;&lt;%= `uname -a` %&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*oKUjMtHSyMTpEfUEOsr1Xg.png" /></figure><p><strong>Escalation</strong></p><p>I immediately reported it but decided to dig a bit further for additional findings and more impact.</p><pre>&lt;%= `ls -lsa /home/` %&gt;</pre><p>This gave me an overview about available users and I went through some directories and found a lot of valuable stuff like git repos, config files and database dumps from other projects that were hosted on the same server. So the company missed to separate the projects from each other and put them also on critical risk that they get compromised as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*JnhkYpDr4oQqWVLpP9vT4Q.png" /><figcaption>🙈</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*dDJQBw6AhVcbqMXhmN9iQw.png" /><figcaption>Files and dirs in the home dir of the current user.</figcaption></figure><p>Finally the program responded within one day and awarded the vulnerability with a €€€€ bounty.<br>Thanks for that :)</p><p>Finally when I entered my profile page I saw, that the inline ruby code was also directly executed here. So it was no issue with wicked_pdf and somehow happened in a previous state when the ruby application rendered the page content.</p><p>Thanks for reading and hope you enjoyed the journey from a simple self xss to a full server takeover :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f9f2d33c1cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>