|
|
Log in / Subscribe / Register

Security

GitHub incidents spawns Rails security debate

March 7, 2012

This article was contributed by Nathan Willis

On March 4, a GitHub user attracted considerable attention with a controversial attempt to provoke the Rails project to change an easily-exploitable setting in Rails's default configuration. He did it by demonstrating the problem in the wild, granting himself commit privileges to the Rails master repository. Within a few hours, the hole was patched on GitHub and a fix deployed in Rails, but the debate rolls on about which parties are responsible, and about what other sites remain vulnerable.

Mass assignments

At the center of the trouble is Rails's ActiveRecord::Base#attributes= method, which is widely used in applications for updating all sorts of database records. The method accepts input about which fields (or attributes) of the record to change concatenated together using a straightforward &someAttribute=someNewValue syntax like that found in an HTTP POST request.

By default, Rails allows any attributes to be updated through this method, which means that attackers can change any and all attributes of their choosing, simply by appending the command to unvalidated form input. For example, injecting &created_at=1955-11-05 into an HTTP request would overwrite the value of an attribute which should be off-limits, but the update sails through unimpeded. Rails does offer a whitelisting macro called attr_accessible and a blacklisting macro called attr_protected, with which developers can restrict access to critical attributes, but neither is active by default.

This "mass assignment" situation has been regarded as a security weakness for years — it is discussed, among other places, in a 2008 article on Rail Spikes, which provides pointers to a mass assignment audit tool and advice for protecting one's applications — and points out that four of the five most popular Rails applications are vulnerable to mass assignment exploits.

On March 1, Egor Homakov opened issue 5228 against Rails (which is hosted at GitHub) calling attention to the problem, and looking for a fix that would force developers to use attr_accessible. The initial comment asks only for ideas:

I don't mean that it is Rails problem, of course not. But let's get it real [...] how to avoid injections ? What should Rails framework do to force people to keep their rails websites safe? Making attr_accessible necessary field in model? What do you think guys.

It is after this initial bug report that opinion begins to diverge. The issue was closed and reopened quickly by a core Rails developer, one developer accused Homakov of trolling, and there was little in the way of in-depth discussion. Then Homakov opened issue 5239 against Rails on March 2, exploiting GitHub's own mass assignment vulnerability to overwrite the timestamp and peg the bug report as coming from the year 3012. In a comment, he apologized for the "inconvenience" and called the stunt "naughty testing" (though observing that he could use the exploit to close the issue himself).

Rails developer Xavier Noria then closed issue 5228 with the comment that "the consensus is the pros of the default configuration outweigh the pros of the alternative." Homakov protested that issue 5239 proved that the problem was widespread and that the Rails project should assume responsibility for offering secure defaults — at least by blacklisting certain obvious attributes, such as the creation-date overwritten in issue 5239. Noria replied that Homakov was "not discovering anything unknown, we already know this stuff and we like attr protection to work the way it is", and that "it is your responsibility to secure your application. It is your responsibility to avoid XSS, to ensure that the user is editing a resource that belongs to him, etc.".

On March 4, Homakov re-used the mass assignment vulnerability to grant commit privileges to his account for the Rails repository, and used it to add a file named "hacked" to Rails's master, containing the line "another showcase of rails apps vulnerability."

Responses

That commit is what was widely reported as the "hacking" or compromise of GitHub. Within an hour or so, GitHub pushed out a fix to the vulnerability, suspended Homakov's GitHub account, and published a blog announcement that it had "started an investigation."

To many commenters on the blog post and on issue 5228, that seemed like an overreaction, since it seemed clear that Homakov had only attempted to call attention to the security hole, and had not taken any destructive action. Later in the day, GitHub reinstated Homakov's account (at that point referring to it as a temporary suspension that had been made "pending a full investigation"), after concluding that he did not act with malicious intent. The second blog post also said that Homakov had privately reported a security flaw to GitHub on March 2, and that GitHub "worked with him to fix it in a timely fashion" — in contrast to the March 4 commit, which the blog post characterized as "without responsible disclosure".

It is not clear what the March 2 vulnerability report was; GitHub user Max Bernstein said he had exchanged email with Homakov, who said he wrote to GitHub about the vulnerability and GitHub had not responded. Nevertheless, the GitHub ship was righted relatively quickly.

Almost as quickly, Michael Koziarski committed a fix to Rails that requires developers to explicitly whitelist all attributes with attr_accessible — fixing the original issue.

Finger-pointing

Despite the speedy technical resolution, the debate over the incident continued to rage on — over whether or not Homakov had acted irresponsibly, whether the GitHub team had overreacted in suspending his account, and whether or not Rails or GitHub was ultimately at fault for the presence of the vulnerability in the first place.

It is the latter question that has the most far-reaching implications. After all, GitHub is offering a commercial service to the public, and has a responsibility to write secure code. But Rails, like any software framework, arguably exists to simplify the process of writing quality (in this case, secure) code. As GitHub user rainyday put it, "One of the reasons people use frameworks in the first place is because this type of thing is supposed to be done for you minimizing the chance of human error." Likewise, user Douwe Maan said "I'm disappointed that GitHub made such an obvious mistake" — but ultimately said Rails's defaults were to blame, which jeopardizes many other sites.

User Eric Mill commented on the GitHub-is-to-blame position, arguing that "The mechanism to secure Github is there without any code changes to Rails, which is how Github could fix it within minutes" — but also made the counterpoint, saying:

Rails has chosen a pattern which makes it more likely that even a foundational Rails site built by some of the most experienced Rails developers in the world is susceptible to unauthorized data entry. This is an obvious problem, and it reflects poorly on the Rails development team that they wouldn't take it seriously up until now. It's hard to get away from the feeling that as experienced Rails devs themselves, they simply could not empathize with the broader Rails community and chose to blame any vulnerabilities on the incompetence of individual developers.

The "disconnect" between the Rails development team and Rails application authors was echoed by others. As a commenter on LWN's own March 5 news item about the incident said:

If a language or platform has a misfeature which makes it hard to write secure code, it is hard for experts in that language to see why it's a problem. In principle, there is workaround XYZ which you should clearly use if you care about that stuff, but otherwise it is working as designed. The argument that *in practice* lots of programs end up with security holes does not carry the weight it should.

The whole affair reminded many of PHP's experience with register_globals. Although removed in PHP 5.4.0, in previous releases the register_globals directive was on by default, and allowed uninitialized variables to be injected into an application by many means — including HTML forms. The arguments for keeping it on were that many existing applications expected it to work that way, and that anyone who was concerned about the security implications could switch it off at will.

Ultimately, PHP bowed to public concern over the security of register_globals in the wild. Thus, although Rails did close the vulnerability after Homakov's stunt, GitHub user Karl Baron expressed surprise that the lesson needed to be learned again, saying in the issue 5228 comments: "Nobody here sees the irony in Rails redoing what PHP was ridiculed for for so long? Never. inject. user. input. by. default."

Finally, although the mass assignment problem may have been fixed in Rails's master, and repaired on GitHub, those fixes do not mark the end of the issue. If nothing else, the publicity surrounding the event has raised awareness — but certainly not everyone who has heard the news is free of malicious intent, and there are still scores of Rails applications vulnerable to the attack. Case in point: Chris Acky posted his own analysis of the events at Posterous (another Rails-based service), and shortly thereafter, comments began appearing with hacked timestamps, including one from Homakov stamped eight years in the past — and two others, apparently from someone else altogether.

The fact that the mass assignment vulnerability is so widespread in the wild illustrates why some have mixed feelings on whether or not Homakov's attention-grabbing stunt ought to be regarded as heroically daring or recklessly bad. It does not change the vulnerability of any site, but it greatly increases the likelihood of an attack. Yet it is also a clear reminder that web frameworks should provide sensible and secure defaults for their users — and that even popular frameworks like Rails have a responsibility to learn from the mistakes of others.

Comments (32 posted)

Brief items

Security quotes of the week

By making these and many related choices, I have made parts of my life slightly less easy, or at least less convenient. But I have gained something more important: liberty. I use the devices I purchase as I choose; I decline to live in the increasingly restricted environments that so many technology and communications companies have imposed on their customers. And to the extent that I am able, I’m preventing snoops, corporate and governmental, from watching my every move without my consent. On balance, I believe, I’ve made my life better.
-- Dan Gillmor on the Permission Taken project

Buying DRMed books is voting with your wallet for a system that criminalizes those that insist on living in freedom and will screw us all in the long run when DRM is the only choice we are offered and removing the DRM is difficult, unsafe, and illegal.
-- Benjamin Mako Hill

Both Apple and Nintendo argue that their curatorial process also intercepts low-quality and malicious software, preventing it from entering the platform. I don’t doubt their sincerity. But their curatorial model treats owners as adversaries and executes countermeasures to prevent people from knowing what the programs on their devices are doing. It has to, because a user who can fully inspect the operating system and its processes, and terminate or modify processes at will, can subvert the curation and undermine the manufacturer’s profits by choosing to buy software elsewhere.
-- Cory Doctorow

Comments (1 posted)

Github compromised

The Github repository site has been compromised; this posting contains a small amount of information. "At 9:53am Pacific Time this morning we rolled out a fix to the vulnerability and started an investigation into the impact of the attack. Database and log analysis have shown that the user compromised three accounts (rails and two others that appear to have been proofs of concept). All affected parties have been or will be contacted once we are certain of the findings." Anybody hosting a repository there should probably check its integrity just to be sure.

Comments (67 posted)

New vulnerabilities

apt: man-in-the-middle attack

Package(s):apt CVE #(s):CVE-2012-0214
Created:March 6, 2012 Updated:March 7, 2012
Description: From the Ubuntu advisory:

Simon Ruderich discovered that APT incorrectly handled repositories that use InRelease files. The default Ubuntu repositories do not use InRelease files, so this issue only affected third-party repositories. If a remote attacker were able to perform a man-in-the-middle attack, this flaw could potentially be used to install altered packages.

Alerts:
Ubuntu USN-1385-1 apt 2012-03-06

Comments (none posted)

bugzilla: cross-site request forgery

Package(s):bugzilla CVE #(s):CVE-2012-0453
Created:March 7, 2012 Updated:March 7, 2012
Description: Bugzilla does not properly validate form attributes passed to xmlrpc.cgi, enabling cross-site request forgery attacks.
Alerts:
Fedora FEDORA-2012-2398 bugzilla 2012-03-06

Comments (none posted)

file: crash from malformed CDF files

Package(s):file CVE #(s):
Created:March 1, 2012 Updated:March 7, 2012
Description:

From the Debian advisory:

The file type identification tool, file, and its associated library, libmagic, do not properly process malformed files in the Composite Document File (CDF) format, leading to crashes.

Alerts:
Debian DSA-2422-1 file 2012-02-29

Comments (none posted)

gnash: information disclosure

Package(s):gnash CVE #(s):CVE-2011-4328
Created:March 7, 2012 Updated:March 14, 2012
Description: The gnash flash player stores cookies in world-readable files with predictable names.
Alerts:
Gentoo 201207-08 gnash 2012-07-09
Debian DSA-2435-1 gnash 2012-03-20
openSUSE openSUSE-SU-2012:0369-1 gnash 2012-03-14
Fedora FEDORA-2012-2719 gnash 2012-03-08
Fedora FEDORA-2012-2771 gnash 2012-03-08
openSUSE openSUSE-SU-2012:0330-1 gnash 2012-03-07

Comments (none posted)

httpd: denial of service

Package(s):httpd CVE #(s):CVE-2007-6750
Created:March 7, 2012 Updated:March 8, 2012
Description: The Apache HTTPD server is subject to denial-of-service attacks using partial requests.
Alerts:
Gentoo 201309-12 apache 2013-09-23
SUSE SUSE-SU-2012:0323-1 Apache2 2012-03-06

Comments (2 posted)

imagemagick: code execution

Package(s):imagemagick CVE #(s):CVE-2012-0247 CVE-2012-0248
Created:March 6, 2012 Updated:March 8, 2012
Description: From the Gentoo advisory:

Two vulnerabilities have been found in ImageMagick:

  • Incorrect offset and count values in the ResolutionUnit tag in EXIF IFD could cause memory corruption (CVE-2012-0247).
  • IOP tag offsets pointing to the beginning of an IFD could cause an infinite loop of ImageMagick parsing the IFD structure (CVE-2012-0248).
A remote attacker could entice a user to open a specially crafted image, possibly resulting in execution of arbitrary code or a Denial of Service condition.
Alerts:
Oracle ELSA-2012-0545 ImageMagick 2012-05-08
Oracle ELSA-2012-0544 ImageMagick 2012-05-08
Scientific Linux SL-Imag-20120508 ImageMagick 2012-05-08
Scientific Linux SL-Imag-20120508 ImageMagick 2012-05-08
CentOS CESA-2012:0545 ImageMagick 2012-05-07
CentOS CESA-2012:0544 ImageMagick 2012-05-07
Red Hat RHSA-2012:0545-01 ImageMagick 2012-05-07
Red Hat RHSA-2012:0544-01 ImageMagick 2012-05-07
Ubuntu USN-1435-1 imagemagick 2012-05-01
Debian DSA-2427-1 imagemagick 2012-03-06
Gentoo 201203-09 imagemagick 2012-03-05
openSUSE openSUSE-SU-2012:0692-1 ImageMagick 2012-06-04
Mandriva MDVSA-2012:078 imagemagick 2012-05-17
Mandriva MDVSA-2012:077 imagemagick 2012-05-17

Comments (2 posted)

kernel: denial of service

Package(s):linux-ti-omap4 CVE #(s):CVE-2011-3619
Created:March 6, 2012 Updated:March 7, 2012
Description: From the Ubuntu advisory:

A flaw was discovered in the Linux kernel's AppArmor security interface when invalid information was written to it. An unprivileged local user could use this to cause a denial of service on the system.

Alerts:
openSUSE openSUSE-SU-2012:1439-1 kernel 2012-11-05
openSUSE openSUSE-SU-2012:0799-1 kernel 2012-06-28
Ubuntu USN-1394-1 Linux kernel (OMAP4) 2012-03-07
Ubuntu USN-1387-1 linux-lts-backport-maverick 2012-03-06
Ubuntu USN-1383-1 linux-ti-omap4 2012-03-06

Comments (none posted)

kernel: denial of service

Package(s):kernel CVE #(s):CVE-2012-1090
Created:March 7, 2012 Updated:June 1, 2012
Description: The CIFS filesystem can be made to leak open files; the resulting dentry reference count mismatch causes an oops when the filesystem is unmounted.
Alerts:
openSUSE openSUSE-SU-2012:1439-1 kernel 2012-11-05
Oracle ELSA-2012-2022 kernel 2012-07-02
Oracle ELSA-2012-2022 kernel 2012-07-02
openSUSE openSUSE-SU-2012:0799-1 kernel 2012-06-28
SUSE SUSE-SU-2012:0616-1 Linux kernel 2012-05-14
Ubuntu USN-1458-1 linux-ti-omap4 2012-05-31
Ubuntu USN-1440-1 linux-lts-backport-natty 2012-05-08
Ubuntu USN-1432-1 linux 2012-05-07
Ubuntu USN-1433-1 linux-lts-backport-oneiric 2012-04-30
Ubuntu USN-1431-1 linux 2012-04-30
SUSE SUSE-SU-2012:0554-2 kernel 2012-04-26
Ubuntu USN-1426-1 linux-ec2 2012-04-24
Ubuntu USN-1425-1 linux 2012-04-24
Oracle ELSA-2012-2008 enterprise kernel 2012-04-23
Oracle ELSA-2012-2008 enterprise kernel 2012-04-23
Oracle ELSA-2012-2007 enterprise kernel 2012-04-23
Oracle ELSA-2012-2007 enterprise kernel 2012-04-23
Oracle ELSA-2012-0481 kernel 2012-04-23
SUSE SUSE-SU-2012:0554-1 Linux kernel 2012-04-23
openSUSE openSUSE-SU-2012:0540-1 kernel 2012-04-20
Scientific Linux SL-kern-20120418 kernel 2012-04-18
CentOS CESA-2012:0481 kernel 2012-04-18
Red Hat RHSA-2012:0481-01 kernel 2012-04-17
Debian DSA-2443-1 linux-2.6 2012-03-26
Ubuntu USN-1405-1 linux 2012-03-27
Fedora FEDORA-2012-3030 kernel 2012-03-06
Fedora FEDORA-2012-2753 kernel 2012-03-06

Comments (none posted)

kernel: denial of service

Package(s):kernel CVE #(s):CVE-2011-4594
Created:March 7, 2012 Updated:March 7, 2012
Description: The sendmmsg() system call accesses user-space memory improperly, enabling denial-of-service attacks.
Alerts:
Oracle ELSA-2013-1645 kernel 2013-11-26
Oracle ELSA-2012-0862 kernel 2012-07-02
Oracle ELSA-2012-0350 kernel 2012-03-12
Scientific Linux SL-kern-20120308 kernel 2012-03-08
CentOS CESA-2012:0350 kernel 2012-03-07
Red Hat RHSA-2012:0350-01 kernel 2012-03-06

Comments (none posted)

kernel: denial of service

Package(s):kernel CVE #(s):CVE-2012-0879
Created:March 7, 2012 Updated:April 3, 2012
Description: The clone() system call does not properly handle the CLONE_IO option, enabling denial-of-service attacks.
Alerts:
Oracle ELSA-2013-1645 kernel 2013-11-26
Oracle ELSA-2012-0862 kernel 2012-07-02
SUSE SUSE-SU-2012:0616-1 Linux kernel 2012-05-14
Debian DSA-2469-1 linux-2.6 2012-05-10
Oracle ELSA-2012-2007 enterprise kernel 2012-04-23
Oracle ELSA-2012-2007 enterprise kernel 2012-04-23
Oracle ELSA-2012-0481 kernel 2012-04-23
Scientific Linux SL-kern-20120418 kernel 2012-04-18
CentOS CESA-2012:0481 kernel 2012-04-18
Red Hat RHSA-2012:0481-01 kernel 2012-04-17
Ubuntu USN-1415-1 linux-mvl-dove 2012-04-03
Ubuntu USN-1408-1 linux-fsl-imx51 2012-03-27
Ubuntu USN-1411-1 linux 2012-03-27
Ubuntu USN-1410-1 linux-ec2 2012-03-27
Ubuntu USN-1389-1 linux 2012-03-06

Comments (none posted)

kernel: denial of service

Package(s):kernel CVE #(s):CVE-2011-4621
Created:March 7, 2012 Updated:March 7, 2012
Description: In some situations, user-space processes can cause specific kernel threads to block.
Alerts:
Ubuntu USN-1394-1 Linux kernel (OMAP4) 2012-03-07

Comments (none posted)

libxml-atom-perl: unintended read access

Package(s):libxml-atom-perl CVE #(s):
Created:March 5, 2012 Updated:March 7, 2012
Description: From the Debian advisory:

It was discovered that the XML::Atom Perl module did not disable external entities when parsing XML from potentially untrusted sources. This may allow attackers to gain read access to otherwise protected [resources], depending on how the library is used.

Alerts:
Debian DSA-2424-1 libxml-atom-perl 2012-03-04

Comments (none posted)

libxslt: denial of service

Package(s):libxslt CVE #(s):CVE-2011-3970
Created:March 1, 2012 Updated:October 4, 2012
Description:

From the Mandriva advisory:

libxslt allows remote attackers to cause a denial of service (out-of-bounds read) via unspecified vectors (CVE-2011-3970).

Alerts:
Ubuntu USN-1595-1 libxslt 2012-10-04
Fedora FEDORA-2012-14048 libxslt 2012-09-27
Fedora FEDORA-2012-14083 libxslt 2012-09-26
Scientific Linux SL-libx-20120914 libxslt 2012-09-14
Oracle ELSA-2012-1265 libxslt 2012-09-14
Oracle ELSA-2012-1265 libxslt 2012-09-14
CentOS CESA-2012:1265 libxslt 2012-09-13
CentOS CESA-2012:1265 libxslt 2012-09-13
Red Hat RHSA-2012:1265-01 libxslt 2012-09-13
openSUSE openSUSE-SU-2012:0343-1 libxslt 2012-03-09
Gentoo 201203-08 libxslt 2012-03-05
Mandriva MDVSA-2012:028 libxslt 2012-03-01

Comments (none posted)

lightdm: permission bypass/denial of service

Package(s):lightdm CVE #(s):
Created:March 5, 2012 Updated:March 7, 2012
Description: From the Ubuntu advisory:

Austin Clements discovered that Light Display Manager incorrectly leaked file descriptors to child processes. A local attacker can use this to bypass intended permissions and write to the log file, cause a denial of service, or possibly have another unknown impact.

Alerts:
Ubuntu USN-1382-1 lightdm 2012-03-05

Comments (none posted)

movabletype-opensource: multiple vulnerabilities

Package(s):movabletype-opensource CVE #(s):
Created:March 5, 2012 Updated:March 7, 2012
Description: From the Debian advisory:

Several vulnerabilities were discovered in Movable Type, a blogging system:

Under certain circumstances, a user who has "Create Entries" or "Manage Blog" permissions may be able to read known files on the local file system.

The file management system contains shell command injection vulnerabilities, the most serious of which may lead to arbitrary OS command execution by a user who has a permission to sign-in to the admin script and also has a permission to upload files.

Session hijack and cross-site request forgery vulnerabilities exist in the commenting and the community script. A remote attacker could hijack the user session or could execute arbitrary script code on victim's browser under the certain circumstances.

Templates which do not escape variable properly and mt-wizard.cgi contain cross-site scripting vulnerabilities.

Alerts:
Debian DSA-2423-1 movabletype-opensource 2012-03-02

Comments (none posted)

python-sqlalchemy: SQL injection

Package(s):python-sqlalchemy CVE #(s):CVE-2012-0805
Created:March 7, 2012 Updated:September 27, 2012
Description: The SQLAlchemy object-relational mapper does not properly sanitize offset and limit values, enabling SQL injection attacks.
Alerts:
Gentoo 201209-16 sqlalchemy 2012-09-26
Mandriva MDVSA-2012:059 python-sqlalchemy 2012-04-16
Debian DSA-2449-1 sqlalchemy 2012-04-12
Fedora FEDORA-2012-3414 python-sqlalchemy0.5 2012-04-01
Fedora FEDORA-2012-3412 python-sqlalchemy0.5 2012-04-01
Scientific Linux SL-pyth-20120308 python-sqlalchemy 2012-03-08
Oracle ELSA-2012-0369 python-sqlalchemy 2012-03-07
CentOS CESA-2012:0369 python-sqlalchemy 2012-03-07
Red Hat RHSA-2012:0369-01 python-sqlalchemy 2012-03-07

Comments (none posted)

spamdyke: arbitrary code execution

Package(s):spamdyke CVE #(s):CVE-2012-0802
Created:March 6, 2012 Updated:March 7, 2012
Description: From the Gentoo advisory:

Boundary errors related to the "snprintf()" and "vsnprintf()" functions in spamdyke could cause a buffer overflow.

A remote attacker could possibly execute arbitrary code or cause a Denial of Service.

Alerts:
Gentoo 201203-01 spamdyke 2012-03-05

Comments (none posted)

stunnel: code execution

Package(s):stunnel CVE #(s):CVE-2011-2940
Created:March 1, 2012 Updated:March 7, 2012
Description:

From the Gentoo advisory:

An unspecified heap vulnerability was discovered in stunnel.

The vulnerability may possibly be leveraged to perform remote code execution or a Denial of Service attack.

Alerts:
Gentoo 201202-08 stunnel 2012-02-29

Comments (none posted)

ubunutone-couch: certificate validation flaw

Package(s):ubuntuone-couch CVE #(s):
Created:March 1, 2012 Updated:March 7, 2012
Description:

From the Ubuntu advisory:

It was discovered that Ubuntu One Couch did not perform any server certificate validation when using HTTPS connections. If a remote attacker were able to perform a man-in-the-middle attack, this flaw could be exploited to alter or compromise confidential information.

Alerts:
Ubuntu USN-1381-1 ubuntuone-couch 2012-03-01

Comments (none posted)

uzbl: information disclosure

Package(s):uzbl CVE #(s):CVE-2012-0843
Created:March 7, 2012 Updated:March 7, 2012
Description: The uzbl web browser stores cookies in a world-readable file.
Alerts:
Fedora FEDORA-2012-2384 uzbl 2012-03-06
Fedora FEDORA-2012-2364 uzbl 2012-03-06

Comments (none posted)

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


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