Is nginx vulnerable to the Hash Table Vulnerability (n.runs AG)?

29 views
Skip to first unread message

Justin Hart

unread,
Dec 31, 2011, 1:37:39 PM12/31/11
to ng...@nginx.org
http://www.securityweek.com/hash-table-collision-attacks-could-trigger-ddos-massive-scale

Without going through the way nginx parses an incoming request, I'm unsure if nginx isn't vulnerable to this, because of the availability to grab the value of a GET parameter via http://wiki.nginx.org/HttpCoreModule#.24arg_PARAMETER.  My hope is that especially if an $arg_PARAMETER isn't used in the config, it is not vulnerable because it wouldn't even attempt to parse the parameters, but I can't be sure.

Can anyone speak to this?  

Maxim Dounin

unread,
Dec 31, 2011, 7:34:57 PM12/31/11
to ng...@nginx.org
Hello!

It's not vulnerable even if $arg_* is used.

Maxim Dounin

_______________________________________________
nginx mailing list
ng...@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

agentzh

unread,
Jan 1, 2012, 12:54:08 AM1/1/12
to ng...@nginx.org

Well, the $arg_PARAMETER variable is not implemented with hash tables
at all ;) It scans the URI query string at every invocation :)

Regards,
-agentzh

Justin Hart

unread,
Jan 1, 2012, 12:58:48 AM1/1/12
to ng...@nginx.org
Thank you for the confirmation - I read through the parts of code in
question but wanted to get a second opinion.

How about the lua and/or the perl modules? It looks as if they are
using the nginx functions?

Sent from my iPhone

agentzh

unread,
Jan 1, 2012, 9:20:59 AM1/1/12
to ng...@nginx.org
On Sun, Jan 1, 2012 at 1:58 PM, Justin Hart <onyx...@gmail.com> wrote:
> Thank you for the confirmation - I read through the parts of code in
> question but wanted to get a second opinion.
>
> How about the lua and/or the perl modules?  It looks as if they are
> using the nginx functions?
>

The current released versions of ngx_lua does have this vulnerability
in its ngx.req.get_uri_args() and ngx.req.get_post_args() functions.
I've already worked out a patch for these two functions in ngx_lua's
git max-args branch here:

https://github.com/chaoslawful/lua-nginx-module/commit/75876

With this patch, both of these functions will only parse 100 query
args at most. And one can specify a custom maximum number of args
parsed with an optional function argument (default to 100) and
enforcing unlimited parsing by specifying a zero number.

This patch (as well as this branch) will be merged into the master
branch in 3 Jan.

Best,

Nginx User

unread,
Jan 1, 2012, 9:31:46 AM1/1/12
to ng...@nginx.org
On 1 January 2012 17:20, agentzh <age...@gmail.com> wrote:
> On Sun, Jan 1, 2012 at 1:58 PM, Justin Hart <onyx...@gmail.com> wrote:
>> Thank you for the confirmation - I read through the parts of code in
>> question but wanted to get a second opinion.
>>
>> How about the lua and/or the perl modules?  It looks as if they are
>> using the nginx functions?
>>
>
> The current released versions of ngx_lua does have this vulnerability
> in its ngx.req.get_uri_args() and ngx.req.get_post_args() functions.
> I've already worked out a patch for these two functions in ngx_lua's
> git max-args branch here:
>
>    https://github.com/chaoslawful/lua-nginx-module/commit/75876
>
> With this patch, both of these functions will only parse 100 query
> args at most. And one can specify a custom maximum number of args
> parsed with an optional function argument (default to 100) and
> enforcing unlimited parsing by specifying a zero number.
>
> This patch (as well as this branch) will be merged into the master
> branch in 3 Jan.

It would probably be a good idea at that point, to finally make a
release of v0.3.1 of the ngx_lua module as with about 45 "Release
Candidates", it must already hold some record :)

Sergey A. Osokin

unread,
Jan 1, 2012, 1:38:09 PM1/1/12
to ng...@nginx.org

+1.

--
Sergey A. Osokin
o...@FreeBSD.ORG.ru
o...@FreeBSD.ORG

agentzh

unread,
Jan 4, 2012, 6:48:35 AM1/4/12
to ng...@nginx.org
On Sun, Jan 1, 2012 at 10:20 PM, agentzh <age...@gmail.com> wrote:
> The current released versions of ngx_lua does have this vulnerability
> in its ngx.req.get_uri_args() and ngx.req.get_post_args() functions.
> I've already worked out a patch for these two functions in ngx_lua's
> git max-args branch here:
>
>    https://github.com/chaoslawful/lua-nginx-module/commit/75876
>
> With this patch, both of these functions will only parse 100 query
> args at most. And one can specify a custom maximum number of args
> parsed with an optional function argument (default to 100) and
> enforcing unlimited parsing by specifying a zero number.
>
> This patch (as well as this branch) will be merged into the master
> branch in 3 Jan.
>

I've also added similar protections to ngx.req.get_headers():

http://wiki.nginx.org/HttpLuaModule#ngx.req.get_headers

All of these changes have been released as ngx_lua 0.3.1rc45:

https://github.com/chaoslawful/lua-nginx-module/tags

and also included in the ngx_openresty bundle's devel version 1.0.10.39:

http://openresty.org/#Download

Feedback welcome!

Nginx User

unread,
Jan 4, 2012, 3:01:56 PM1/4/12
to ng...@nginx.org
On 4 January 2012 14:48, agentzh <age...@gmail.com> wrote:
> I've also added similar protections to ngx.req.get_headers():
>
>    http://wiki.nginx.org/HttpLuaModule#ngx.req.get_headers
>
> All of these changes have been released as ngx_lua 0.3.1rc45:
Nice one.

Thanks.

Reply all
Reply to author
Forward
0 new messages