LWN.net Logo

Security

Mozilla's Content Security Policy

By Jake Edge
July 1, 2009

Cross-site scripting (XSS) is a common web application flaw that can lead to a wide variety of attacks. The problem, and ways to eliminate it, have been known for years, but new instances of XSS crop up regularly in web applications—live sites as well as packages like content management systems. Mozilla has taken the lead on a new security policy, Content Security Policy (CSP), which provides a way for sites to avoid XSS. It does that by fundamentally changing the way JavaScript content is treated by the browser, but does so in a way that allows sites to opt-in to the new policy.

XSS works by injecting JavaScript content into the data returned by a web server. Normally that happens because some kind of user input was not properly filtered before it was echoed back on a web page. If that user input—in the form of a comment on an article, for example—contains unfiltered JavaScript, the users browser will happily execute it as if it originated with the site. At that point, an attacker-controlled code is running with the privileges of the browser user and the origin site.

As described by Mozilla's security program manager Brandon Sterne, on the Mozilla Security Blog, CSP changes that model. Instead of treating all content received in a response as having the same privilege level, CSP allows the site owner to explicitly list what kinds of JavaScript to trust. In order to do that, however, CSP strictly limits where JavaScript can originate, and where it can appear in HTML.

Basically, CSP allows a site operator to list hosts from which JavaScript content will be accepted. If that option is used (via an HTTP X-Content-Security-Policy header or HTML <META> tag), all JavaScript must be loaded from external files from hosts on the list—all other mechanisms for executing JavaScript are disabled for that page. Sterne describes it this way:

In order to differentiate legitimate content from injected or modified content, CSP requires that all JavaScript for a page be 1) loaded from an external file, and 2) served from an explicitly approved host. This means that all inline script, javascript: URIs, and event-handling HTML attributes will be ignored. Only script included via a <script> tag pointing to a white-listed host will be treated as valid.

This will be an enormous change for sites that want to use CSP, but it is backward-compatible with older browsers (or those that do not support CSP), and there are ways to incrementally approach the implementation. Sterne notes that all sites should be able to make the switch, and Mozilla intends to provide a migration guide to help sites convert to CSP. But, it remains to be seen whether sites will actually use it. Mozilla security lead, Daniel Veditz, commented about that in the bug entry that tracks CSP implementation:

Funny you should mentions the onclick attribute as that one specifically is a popular one to abuse. Whether the burden of rewriting your site to the supported safe subset of HTML is worth it depends on how valuable the contents of your site are.

Note that we are not eliminating event handlers, just the ability to specify them inline. AddEventListener() will still work, as will setting the .click property of a DOM node. This is a little cumbersome, but there are already sites that do this for some of their content.

CSP is a gamble, it could be that the hurdle will turn out to be too high. But if we can get authors over that hurdle we can promise them a safer site.

Another interesting feature of CSP is its ability to notify a site when there is an attempt to violate the policy. This will even benefit users of browsers that don't support CSP, as XSS holes can be recognized and fixed more quickly. Sterne is optimistic about the effect of CSP:

The bottom line is that it will be extremely difficult to mount a successful XSS attack against a site with CSP enabled. All common vectors for script injection will no longer work and the bar for a successful attack is placed much, much higher.

The open question is whether site operators are concerned enough about XSS to change the way they handle JavaScript. Over time, automated tools may help with that process, which could lower the bar somewhat, but it is still a daunting task. One would guess that the other browsers will take a "wait and see" attitude before deciding whether to implement it. Though the implementation is progressing, there is no word from Mozilla on when it might release a browser with CSP either.

Perhaps CSP is too heavy-handed of a solution to the XSS problem, but it is good to see Mozilla taking a lead in trying to find something that will alleviate the problem. There are other, similar efforts in the works at Mozilla including the Origin header to mitigate cross-site request forgery and clickjacking.

While these web application vulnerabilities are largely understood and techniques to avoid them are known, they keep cropping up. Finding ways to make users' browsers more resistant to these kinds of attacks can only help improve web security.

Comments (18 posted)

New vulnerabilities

git: denial of service

Package(s):git CVE #(s):CVE-2009-2108
Created:June 25, 2009 Updated:February 1, 2010
Description: git has a denial of service vulnerability From the National Vulnerability Database entry: git-daemon in git 1.4.4.5 through 1.6.3 allows remote attackers to cause a denial of service (infinite loop and CPU consumption) via a request containing extra unrecognized arguments.
Alerts:
Debian DSA-1841-2 2010-01-31
Mandriva MDVSA-2009:176 2009-07-29
Debian DSA-1841-1 2009-07-25
Mandriva MDVSA-2009:155 2009-07-19
Gentoo 200907-05 2009-07-12
Fedora FEDORA-2009-6936 2009-06-23
Fedora FEDORA-2009-6839 2009-06-23
Fedora FEDORA-2009-6809 2009-06-23

Comments (none posted)

html2text.php: arbitrary code execution

Package(s):html2text.php CVE #(s):CVE-2008-5619
Created:June 25, 2009 Updated:July 1, 2009
Description: html2text.php has a arbitrary code execution vulnerability. From the National Vulnerability Database entry: html2text.php in Chuggnutt HTML to Text Converter, as used in RoundCube Webmail (roundcubemail) 0.2-1.alpha and 0.2-3.beta, Mahara, and AtMail Open 1.03, allows remote attackers to execute arbitrary code via crafted input that is processed by the preg_replace function with the eval switch.
Alerts:
Ubuntu USN-791-1 2009-06-24

Comments (none posted)

kdegraphics: multiple vulnerabilities

Package(s):kdegraphics CVE #(s):CVE-2009-0945 CVE-2009-1709
Created:June 25, 2009 Updated:January 25, 2011
Description: kdegraphics has multiple vulnerabilities. From the Red Hat alert: A use-after-free flaw was found in the KDE KSVG animation element implementation. A remote attacker could create a specially-crafted SVG image, which once opened by an unsuspecting user, could cause a denial of service (Konqueror crash) or, potentially, execute arbitrary code with the privileges of the user running Konqueror. (CVE-2009-1709) A NULL pointer dereference flaw was found in the KDE, KSVG SVGList interface implementation. A remote attacker could create a specially-crafted SVG image, which once opened by an unsuspecting user, would cause memory corruption, leading to a denial of service (Konqueror crash). (CVE-2009-0945)
Alerts:
SUSE SUSE-SR:2011:002 2011-01-25
openSUSE openSUSE-SU-2011:0024-1 2011-01-12
openSUSE openSUSE-SU-2010:1035-1 2010-12-09
Mandriva MDVSA-2010:182 2010-09-14
Debian DSA-1988-1 2010-02-02
Mandriva MDVSA-2010:027 2010-01-27
Debian DSA-1950 2009-12-12
Mandriva MDVSA-2009:331 2009-12-10
Ubuntu USN-836-1 2009-09-23
Ubuntu USN-823-1 2009-08-24
Ubuntu USN-822-1 2009-08-24
Debian DSA-1866-1 2009-08-19
Ubuntu USN-857-1 2009-11-10
Fedora FEDORA-2009-8049 2009-07-27
Fedora FEDORA-2009-8039 2009-07-27
Fedora FEDORA-2009-6166 2009-06-15
CentOS CESA-2009:1130 2009-06-26
Red Hat RHSA-2009:1130-01 2009-06-25

Comments (none posted)

kdelibs: multiple vulnerabilities

Package(s):kdelibs CVE #(s):CVE-2009-1687 CVE-2009-1690 CVE-2009-1698
Created:June 25, 2009 Updated:January 25, 2011
Description: kdelibs has multiple vulnerabilities. From the Red Hat alert: A flaw was found in the way the KDE CSS parser handled content for the CSS "style" attribute. A remote attacker could create a specially-crafted CSS equipped HTML page, which once visited by an unsuspecting user, could cause a denial of service (Konqueror crash) or, potentially, execute arbitrary code with the privileges of the user running Konqueror. (CVE-2009-1698) A flaw was found in the way the KDE HTML parser handled content for the HTML "head" element. A remote attacker could create a specially-crafted HTML page, which once visited by an unsuspecting user, could cause a denial of service (Konqueror crash) or, potentially, execute arbitrary code with the privileges of the user running Konqueror. (CVE-2009-1690) An integer overflow flaw, leading to a heap-based buffer overflow, was found in the way the KDE JavaScript garbage collector handled memory allocation requests. A remote attacker could create a specially-crafted HTML page, which once visited by an unsuspecting user, could cause a denial of service (Konqueror crash) or, potentially, execute arbitrary code with the privileges of the user running Konqueror. (CVE-2009-1687)
Alerts:
openSUSE openSUSE-SU-2011:0024-1 2011-01-12
SUSE SUSE-SR:2011:002 2011-01-25
openSUSE openSUSE-SU-2010:1034-1 2010-12-09
Debian DSA-1988-1 2010-02-02
Mandriva MDVSA-2010:027 2010-01-27
Mandriva MDVSA-2009:346 2009-12-29
Debian DSA-1950 2009-12-12
Mandriva MDVSA-2009:330 2009-12-10
Ubuntu USN-836-1 2009-09-23
Fedora FEDORA-2009-9391 2009-09-09
Fedora FEDORA-2009-9400 2009-09-09
Ubuntu USN-822-1 2009-08-24
Debian DSA-1868-1 2009-08-19
Debian DSA-1867-1 2009-08-19
Fedora FEDORA-2009-8020 2009-07-27
Fedora FEDORA-2009-8046 2009-07-27
Fedora FEDORA-2009-8049 2009-07-27
Fedora FEDORA-2009-8039 2009-07-27
CentOS CESA-2009:1127 2009-06-26
CentOS CESA-2009:1128 2009-06-25
Red Hat RHSA-2009:1128-01 2009-06-25
Red Hat RHSA-2009:1127-01 2009-06-25
Ubuntu USN-857-1 2009-11-10

Comments (none posted)

kernel: buffer overflow

Package(s):kernel CVE #(s):CVE-2009-1389
Created:June 25, 2009 Updated:September 23, 2010
Description: The kernel has a buffer overflow vulnerability. From the National Vulnerability Database entry: Buffer overflow in the RTL8169 NIC driver (drivers/net/r8169.c) in the Linux kernel before 2.6.30 allows remote attackers to cause a denial of service (kernel memory corruption and crash) via a long packet.
Alerts:
openSUSE openSUSE-SU-2010:0664-1 2010-09-23
SUSE SUSE-SA:2010:036 2010-09-01
openSUSE openSUSE-SU-2010:0397-1 2010-07-19
SUSE SUSE-SA:2010:031 2010-07-20
Red Hat RHSA-2009:1469-01 2009-09-30
Red Hat RHSA-2009:1457-01 2009-09-22
SuSE SUSE-SA:2009:045 2009-08-20
Debian DSA-1865-1 2009-08-16
Red Hat RHSA-2009:1211-01 2009-08-13
CentOS CESA-2009:1193 2009-08-05
Red Hat RHSA-2009:1193-01 2009-08-04
Debian DSA-1844-1 2009-07-28
Ubuntu USN-807-1 2009-07-28
rPath rPSA-2009-0111-1 2009-07-24
SuSE SUSE-SA:2009:038 2009-07-23
Red Hat RHSA-2009:1157-01 2009-07-14
Mandriva MDVSA-2009:148 2009-07-07
Fedora FEDORA-2009-6768 2009-06-19
Fedora FEDORA-2009-6883 2009-06-23
Fedora FEDORA-2009-6846 2009-06-23

Comments (none posted)

moodle: arbitrary SQL execution

Package(s):moodle CVE #(s):CVE-2008-6124
Created:June 25, 2009 Updated:July 1, 2009
Description: moodle has an arbitrary SQL execution vulnerability. From the National Vulnerability Database entry: SQL injection vulnerability in the hotpot_delete_selected_attempts function in report.php in the HotPot module in Moodle 1.6 before 1.6.7, 1.7 before 1.7.5, 1.8 before 1.8.6, and 1.9 before 1.9.2 allows remote attackers to execute arbitrary SQL commands via a crafted selected attempt.
Alerts:
Ubuntu USN-791-1 2009-06-24

Comments (none posted)

net-snmp: denial of service

Package(s):net-snmp CVE #(s):CVE-2009-1887
Created:June 25, 2009 Updated:July 20, 2009
Description: net-snmp has a denial of service vulnerability. From the Red Hat alert: A divide-by-zero flaw was discovered in the snmpd daemon. A remote attacker could issue a specially-crafted GETBULK request that could crash the snmpd daemon. (CVE-2009-1887) Note: An attacker must have read access to the SNMP server in order to exploit this flaw.
Alerts:
Mandriva MDVSA-2009:156 2009-07-19
CentOS CESA-2009:1124 2009-06-25
Red Hat RHSA-2009:1124-01 2009-06-25

Comments (none posted)

openssl: multiple vulnerabilities

Package(s):openssl CVE #(s):CVE-2009-1379 CVE-2009-1386 CVE-2009-1387
Created:June 26, 2009 Updated:March 2, 2010
Description: From the Ubuntu advisory:

It was discovered that OpenSSL did not properly handle certain server certificates when processing DTLS packets. A remote DTLS server could cause a denial of service by sending a message containing a specially crafted server certificate. (CVE-2009-1379)

It was discovered that OpenSSL did not properly handle a DTLS ChangeCipherSpec packet when it occured before ClientHello. A remote attacker could cause a denial of service by sending a specially crafted request. (CVE-2009-1386)

It was discovered that OpenSSL did not properly handle out of sequence DTLS handshake messages. A remote attacker could cause a denial of service by sending a specially crafted request. (CVE-2009-1387)

Alerts:
Slackware SSA:2010-060-02 2010-03-02
Mandriva MDVSA-2009:310 2009-12-03
Gentoo 200912-01 2009-12-01
Mandriva MDVSA-2009:239 2009-09-22
Mandriva MDVSA-2009:238 2009-09-21
Mandriva MDVSA-2009:237 2009-09-21
Debian DSA-1888-1 2009-09-15
CentOS CESA-2009:1335 2009-09-15
Red Hat RHSA-2009:1335-02 2009-09-02
SuSE SUSE-SR:2009:012 2009-07-03
Ubuntu USN-792-1 2009-06-25

Comments (none posted)

pam_krb5: information disclosure

Package(s):pam_krb5 CVE #(s):CVE-2009-1384
Created:June 29, 2009 Updated:March 31, 2010
Description:

From the Red Hat bugzilla entry:

A security flaw was found in PAM pam_krb5 module, providing user authentication based on Kerberos principals. A remote attacker could use this flaw to recognize, if some username/login belongs to set of user accounts, existing on the system, and subsequently perform dictionary based password guess attack.

Alerts:
Red Hat RHSA-2010:0258-04 2010-03-30
Mandriva MDVSA-2010:054 2010-03-04
Fedora FEDORA-2009-5983 2009-06-15
Fedora FEDORA-2009-6255 2009-06-15
Fedora FEDORA-2009-6279 2009-06-15

Comments (none posted)

php: crash with corrupted JPEG file

Package(s):php CVE #(s):
Created:June 29, 2009 Updated:July 1, 2009
Description:

From the PHP bug report:

There seems to be a problem in exif_read_data(), where some fields representing offsets(?) are taken directly from the file without being validated, resulting in a segmentation fault.

Alerts:
Mandriva MDVSA-2009:145 2009-06-28

Comments (none posted)

rt3: privilege escalation

Package(s):rt3 CVE #(s):
Created:June 25, 2009 Updated:July 1, 2009
Description: rt3 has a privilege escalation vulnerability. From the Fedora alert: Bug #506885 - rt3: privilege to edit 'RT at a Glance' unintentionally granted by "ShowConfigTab" right.
Alerts:
Fedora FEDORA-2009-6899 2009-06-23
Fedora FEDORA-2009-6837 2009-06-23

Comments (none posted)

samba: several vulnerabilities

Package(s):samba CVE #(s):CVE-2009-1886 CVE-2009-1888
Created:June 26, 2009 Updated:December 7, 2009
Description: From the Debian advisory: Several vulnerabilities have been discovered in Samba, a SMB/CIFS file, print, and login server. The Common Vulnerabilities and Exposures project identifies the following problems:

The smbclient utility contains a formatstring vulnerability where commands dealing with file names treat user input as format strings to asprintf. CVE-2009-1886

In the smbd daemon, if a user is trying to modify an access control list (ACL) and is denied permission, this deny may be overridden if the parameter "dos filemode" is set to "yes" in the smb.conf and the user already has write access to the file. CVE-2009-1888

Alerts:
Mandriva MDVSA-2009:320 2009-12-06
Ubuntu USN-839-1 2009-10-01
Mandriva MDVSA-2009:196 2009-08-07
Red Hat RHSA-2009:1529-01 2009-10-27
Red Hat RHSA-2009:1585-01 2009-11-16
CentOS CESA-2009:1529 2009-10-30
Slackware SSA:2009-177-01 2009-06-29
Debian DSA-1823-1 2009-06-25
CentOS CESA-2009:1529 2009-10-27
rPath rPSA-2009-0145-1 2009-11-12

Comments (none posted)

seamonkey: multiple vulnerabilities

Package(s):seamonkey CVE #(s):
Created:June 25, 2009 Updated:September 8, 2009
Description: seamonkey has multiple vulnerabilities. From the Mozilla advisory: MFSA 2009-33 Crash viewing multipart/alternative message with text/enhanced part MFSA 2009-32 JavaScript chrome privilege escalation MFSA 2009-29 Arbitrary code execution using event listeners attached to an element whose owner document is null MFSA 2009-27 SSL tampering via non-200 responses to proxy CONNECT requests MFSA 2009-26 Arbitrary domain cookie access by local file: resources MFSA 2009-24 Crashes with evidence of memory corruption (rv:1.9.0.11) MFSA 2009-21 POST data sent to wrong site when saving web page with embedded frame MFSA 2009-17 Same-origin violations when Adobe Flash loaded via view-source: scheme
Alerts:
Slackware SSA:2009-250-01 2009-09-08
Slackware SSA:2009-176-01 2009-06-25

Comments (none posted)

smarty: PHP code injection

Package(s):smarty CVE #(s):CVE-2008-4810
Created:June 25, 2009 Updated:August 18, 2010
Description: Smarty has a PHP code injection vulnerability. From the National Vulnerability Database entry: The _expand_quoted_text function in libs/Smarty_Compiler.class.php in Smarty 2.6.20 before r2797 allows remote attackers to execute arbitrary PHP code via vectors related to templates and (1) a dollar-sign character, aka "php executed in templates;" and (2) a double quoted literal string, aka a "function injection security hole." NOTE: each vector affects slightly different SVN revisions.
Alerts:
Debian DSA-1919-2 2010-08-17
Gentoo 201006-13 2010-06-02
Debian DSA-1919-1 2009-10-25
Ubuntu USN-791-1 2009-06-24

Comments (none posted)

thunderbird: arbitrary code execution

Package(s):mozilla-thunderbird CVE #(s):CVE-2009-2210
Created:June 29, 2009 Updated:July 16, 2009
Description:

From the CVE entry:

Mozilla Thunderbird before 2.0.0.22 and SeaMonkey before 1.1.17 allow remote attackers to cause a denial of service (application crash) or possibly execute arbitrary code via a multipart/alternative e-mail message containing a text/enhanced part that triggers access to an incorrect object type.

Alerts:
Fedora FEDORA-2009-7614 2009-07-15
Fedora FEDORA-2009-7567 2009-07-15
CentOS CESA-2009:1134 2009-07-01
Red Hat RHSA-2009:1134-01 2009-06-30
Slackware SSA:2009-178-01 2009-06-29
Mandriva MDVSA-2009:141 2009-06-17
Gentoo 201301-01 2013-01-07

Comments (none posted)

Page editor: Jake Edge
Next page: Kernel development>>

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds