Drupal Flag Module 6.x-1.1 Multiple Vulnerabilities
Date of Contact: June 5, 2009 13:30 GMT -0400
Vendor Response: See below
Description of Vulnerability:
Drupal (http://drupal.org) is a robust content management system (CMS) written in PHP and MySQL that provides extensibility through various third party modules. The Flag module (http://drupal.org/project/flag) "is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, or users. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content."
The Flag module contains several cross site scripting vulnerabilities because it does not properly sanitize output of role names before display. The flag module also contains cross site scripting vulnerabilities because it fails to properly sanitize content type names. Additionally the Flag module contains a SQL injection vulnerability because it does not properly sanitize variables before concatenating them into a SQL query.
Drupal 6.12 with Flag 6.x-1.1 was tested and shown to be vulnerable.
XSS vulnerabilities may expose site administrative accounts to compromise which could lead to web server process compromise. SQL injection attack can manipulate the Drupal database, compromising data, exposing credentials, and could allow injection of XSS attacks in node content.
The Flag module must be installed. To carry out an role name XSS exploit against the Flag module the attacker must be able to inject malicious content into role names, which is possible for authenticated users with the 'administer permissions' permission. To carry out the content type XSS exploit against the Flag module the attacker must be able to inject malicious content into content type names, which is possible for authenticated users with the 'administer content types' permission. The SQL injection vulnerability has not yet been shown to be exploitable.
The Flag module uses the Drupal user_roles() function from user.module, which fails to sanitize role names before returning them (this is a known issue in Drupal 6.12 - http://www.madirish.net?article=256). On line 416 of flag.module the $roles variable is composed without sanitizing the return value of the user_roles() function. This leads to arbitrary HTML injection. The Flag module also fails to sanitize content type names returned by the node_get_types() function in flag.module on line 708.
The variables used to construct $result on line 40 of includes/flag_handler_argument_content_id.inc are not sanitized and could be used to perform SQL injection.
The vendor classifies these vulnerabilities as bugs and has reported them to the module maintainer for a fix. Ref: http://drupal.org/node/483218.