XSS exploit of RDoc documentation generated by rdoc (CVE-2013-0256)
RDoc's paragraph formatter inserted raw paragraph text into generated HTML without escaping, so a crafted documentation source file could inject script tags into the output. An attacker who could get a malicious file processed by rdoc could have arbitrary script run in the browser of anyone viewing the generated documentation.
- Disclosed after 2 months
The exploit exists in paragraph formatting that allows malicious code to be injected into the generated documentation.
PoC
For example, let's create the example file with the following content:
\x[\<script>alert(1);</script>\]
Now, run rdoc:
rdoc --all
The output html will have the following injected javascript code:
<main role="main" aria-label="Page example">
<p>x[<script>alert(1);</script>]</p>
</main>
Solution
I may be wrong with the solution, but I want to be more helpful :) At first glance, the vulnerable code is here:
def accept_paragraph paragraph
@res << "\n<p>"
text = paragraph.text @hard_break
text = text.gsub(/\r?\n/, ' ')
@res << to_html(text) # <====== CGI.escapeHTML(text)) ???
@res << "</p>\n"
end
I suppose we should sanitize the output. For example, after changing text to CGI.escapeHTML(text) I've got the following result:
<main role="main" aria-label="Page example">
<p>x[<script>alert(1);</script>]</p>
</main>
I hope this doesn't break anything. ^_^
Impact
A cross-site scripting (XSS) vulnerability allows attackers to execute arbitrary web scripts or HTML via a crafted payload.
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The paragraph handler concatenated the paragraph text into the HTML output without HTML-escaping it.
Impact
Script supplied through documentation source could execute in the browser of anyone viewing the generated HTML, though the text does not demonstrate an attack against a hosted service.
What the attacker needed
Ability to supply a file processed by rdoc; victim views the generated HTML
The fix
The paragraph text should be HTML-escaped before being written into the output, which the author shows produces escaped entities instead of live markup.
How it was found
- Create a source file containing a paragraph with an embedded script tag
- Run rdoc over the file to generate HTML documentation
- Open the generated page and observe the script tag rendered as live markup
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
RDoc is a tool that turns source code comments into HTML documentation pages. The tool copied text straight into the web page without neutralising characters like angle brackets, so a line of text could become a real script tag. When someone opened the generated page, their browser would run that script as if the site had written it.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.