Security vulnerability found in Nginx
mailman.nginx.org
mailman.nginx.org
There are still no new patch level version of 0.7.67 available for Debian Squeeze[2] or Ubutu 10.4 LTS' 0.7.65 version[3]. EPEL for RHEL and derivatives also lack a new upstream version[4].
[1]: http://projects.archlinux.org/svntogit/community.git/commit/...
[2]: http://packages.debian.org/changelogs/pool/main/n/nginx/?C=M...
[3]: http://changelogs.ubuntu.com/changelogs/pool/universe/n/ngin...
[4]: http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/nginx...
Edit: changed [2] to [Debian/Ubuntu]
[0] http://www.freebsd.org/cgi/getmsg.cgi?fetch=753841+0+current...
[1] http://www.freebsd.org/cgi/getmsg.cgi?fetch=756257+0+current...
As a side note, there's an official Debian/Ubuntu repository maintained by nginx.org http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packa...
1.1.17 is also there in the development channel: https://launchpad.net/~nginx/+archive/development
Similar issues in Perl: http://www.phrack.org/issues.html?issue=55&id=7#article and other languages: http://hakipedia.com/index.php/Poison_Null_Byte#Perl_PHP_Nul...
Strings could be missing a "\0" and therefore some function could read too far later on..
The string functions in the C standard library suck. bstring is a better alternative: http://bstring.cvs.sourceforge.net/viewvc/bstring/tree/bstrl... . Glib also has a good string library...
[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/ope... [2] http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...
NtCreateFile[2] (and the kernel-side implementation of ZwCreateFile[3]) take a file name in the form of OBJECT_ATTRIBUTES, whose ObjectName field is of type PUNICODE_STRING. CreateFile is implemented in terms of NtCreateFile; CreateFile enforces Win32 semantics like case insensitivity that NtCreateFile does not; POSIX semantics can be implemented on top of NtCreateFile, but not easily with CreateFile.
[1] http://msdn.microsoft.com/en-us/library/windows/hardware/ff5...
[2] http://msdn.microsoft.com/en-us/library/bb432380%28v=vs.85%2...
[3] http://msdn.microsoft.com/en-us/library/windows/hardware/ff5...
The risk only arises if the component of a system that accepts and validates user input does not use (or account for) null-terminated strings. That validator will see a different string than the syscall will; this is called null-character injection, and while it is difficult to craft effectively, it can lead to accessing resources that you thought you had protected by validating the string.
You are quite correct that nulls are not legal characters in POSIX filenames; however, that is irrelevant. The nulls are only an issue in the processing; once they reach a syscall, the first one is treated as a terminator.
Just patch it.
I'm not complaining. It doesn't happen to me that often. Way more often, it's someone complaining about some anonymous employer or service provider and 20 people writing comments about how it's irresponsible for them not to say who it was. But it's the same kind of annoying every time.
Maybe the term ought to be in German. German works great for concepts like this.
Why did I leave the comment? Because it's hard to patch server software and people will often wait on patches until maintenance windows (advise you not do that this time) or take some time to figure out if they're affected. Especially with Apache, where oftentimes you aren't affected because the bug is in some random module most people don't use.
Don't take this the wrong way, but I think it was the tone of the response.
I.e. "What are the implications of this?" "It's a bad bug, patch it ASAP" "....."
It's the kind of non-response one would expect from a management type to a low level engineer. Somewhat odious to the average hacker, in other words.
(I could be COMPLETELY off the mark here, and if so, please disregard this entire message)
As to the average hacker, yes we want to know everything, but there are valid reasons not to be told everything. In this case, the information given is useful and sufficient, and the implications of what he said and how he said it are very clear indeed.
As for how many people it practically affects, that could well hurt. Saying anything more than "Applications are broadly vulnerable to this problem." like he did elsewhere in this thread could very well point out specific, detectable vulnerable instances. That's a bad thing. Just wait and more info will be out, but heed his advice!
(I said, when his comment was light grey...)
Master tracking bug: https://bugzilla.redhat.com/show_bug.cgi?id=803856
EPEL: https://bugzilla.redhat.com/show_bug.cgi?id=803859
Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=803858
RPMs for 1.0.14 are available in koji at those second two links, or you can grab it via "yum --enablerepo=updates-testing update nginx" once the mirrors all pick it up.
(you may also want to generate a new key and get a new certificate if you use nginx, concurrent with patching this...)
(This comment sounds more disagreeable than I mean it to; sorry, it's tricky for me to comment about this stuff).
You REALLY should be using multiple boxes if you're running load balancers (especially sw load balancers) with some kind of heartbeat failover. That way you can upgrade single boxes easily, and are ok in case one of them dies. With a bug of this severity, you won't have time to test the patch, so it's probably best to upgrade one at a time in production.
Remember, even if you're running Apache or something else for your actual web server, you can easily have something like nginx sitting in front as a proxy/load balancer. Often in front of your security monitoring devices... and you may have forgotten about it.
Looking for a consensus on the most stable way to update nginx installations from source.
Thanks!
https://github.com/tmm1/brew2deb
It provides a DSL for describing how to build and package something, including patching, and already has a nginx formula:
https://github.com/tmm1/brew2deb/blob/master/packages/nginx/...
Will likely be adding in this patch today...
But if you're going to learn a DSL for building debs, why not just learn how to build debs? Your distro already provides the necessary build formula, along with well-integrated startup scripts, etc.
To start out, just build as given:
apt-get build-dep nginx
apt-get source nginx
cd nginx-$VERSION
dpkg-buildpackage
Then to customize, go into the source tree and update whatever you want to update, and rebuild. You'll see there's already a debian/patches directory where you can drop patches to apply automatically.I tend to just keep the "debian" directory in source control, so I can take a fresh upstream tarball, check out my debian rules into it, and kick off the build.
But there are many ways to fry an egg. I prefer this way, but overall having a package is a big plus for commonality between systems and convenience vs simply building from source.
This is from a book called "Nginx HTTP server":
1. Replace the old Nginx binary (by default, /usr/local/nginx/sbin/nginx) with the new one.
2. Find the pid of the Nginx master process, for example, with ps x | grep nginx | grep master or by looking at the value found in the pid file.
3. Send a USR2 (12) signal to the master process—kill –USR2 , replacing with the pid found in step 2. This will initiate the upgrade by renaming the old .pid file and running the new binary.
4. Send a WINCH (28) signal to the old master process—kill –WINCH , replacing with the pid found in step 2. This will engage a graceful shutdown of the old worker processes.
5. Make sure that all the old worker processes are terminated, and then send a QUIT signal to the old master process—kill –QUIT , replacing with the pid found in step 2.
The makefile in the nginx source shows you how to do a hitless upgrade. This is what I do from the shell after correctly installing, essentially translated from the makefile.
kill -USR2 `cat /var/run/nginx.pid` && sleep 1 && test -f /var/run/nginx.pid.oldbin && kill -QUIT `cat /var/run/nginx.pid.oldbin` && echo restart successful
Obviously, modify paths to the pid files as appropriate.
* Get old version config flags with -V, e.g /opt/nginx/sbin/nginx -V
Mine had:
nginx: configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-cc-opt=-Wno-error --add-module=/usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/nginx
Download tarball:
* wget http://nginx.org/download/nginx-1.0.14.tar.gz
Extract and configure passing the same flags:
* tar zxvf nginx-1.0.14.tar.gz && cd nginx-1.0.14
* ./configure --prefix=/opt/nginx --with-http_ssl_module --with-cc-opt=-Wno-error --add-module=/usr/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/nginx
Compile and install
* make && make install clean
The make install action will check for old directories and files so no need to worry about stuff being overriden.
Verify your nginx version with:
/opt/nginx/sbin/nginx -v
nginx version: nginx/1.0.14
:)
A better approach to follow is (note this is only a rough guide from memory):
cp -R /usr/portage/www-client/nginx /usr/local/portage/www-client
cd /usr/local/portage/www-client/nginx
mv nginx-1.0.13.ebuild nginx-1.0.14.ebuild
ebuild nginx-1.0.14.ebuild digest
emerge -1q nginxI love portage, I use it whenever I can. In this case, I think I've did it like that because something was messed up with Passenger support in the port. It's the only package installed from source (bypassing portage) on my system and it's not an orphan in a way that /opt was dedicated purely for such scenarions. I can see all such packages by listing /opt assuming I keep the install prefix convention.
In any case, thanks for pointing that this is a wrong way to install packages, someone might benefit from this indeed.
Thank you all for your thoughtful replies.