Welcome! Log In Create A New Profile

Advanced

Re: ngx_lua location capture issue

Nginx User
October 21, 2011 03:36AM
On 21 October 2011 07:13, agentzh <agentzh@gmail.com> wrote:
> On Fri, Oct 21, 2011 at 12:08 PM, agentzh <agentzh@gmail.com> wrote:
>>>       local query_string = ngx.re.match(ngx.var.request_uri,
>>> "(?:^>[\\\w\\\s]*<\\\/?\\\w{2,}>)", "io")
>>>                -- finds unquoted attribute breaking injections -- xss -- csrf
>>>                -- <impact>2</impact>
>
> BTW, it's bad practice to match against $request_uri directly because
> query strings may be escaped according to URI escaping rules. (Yes!
> there's escaping everywhere!)
>
> For example, Forefox will escape "<a>3</a>" into "a=%3Ca%3E3%3C/a%3E",
> which will surely never be matched by the regexes used here.
>
> You can try ngx.unescape_uri to preprocess the $request_uri thing first, see:
>
>    http://wiki.nginx.org/HttpLuaModule#ngx.unescape_uri
>
> Good luck!

Thanks for the emails above. I'll look into tackling the issues
raised in due course.
"/" is escaped because the original regex is from a php application
which uses "/" as a delimiter. I left it in place because the snippet
posted in just a part of the result of a series of "find and replace"
sequences on an xml file
(https://dev.itratos.de/svn/php-ids/trunk/lib/IDS/default_filter.xml)
that changes it to the lua format. "-- <impact>2</impact>" is not the
target but just a hang over from the original xml I couldn't find an
easy find and replace for to cater for all possible "<impact>" tags
and is there as a lua comment.

As said, things are working as expected for me at present in that the
resultant regexes are consistent with the target regexes from the xml
file so I am keeping them as they are. I will change them if/when I
see issues.

In any case, this is just a fallback I put in place when trying to
call the actual application and having just recompiled with rc17, I'll
look into having a go at that again.

Thanks!

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx_lua location capture issue

Nginx User October 18, 2011 12:56PM

Re: ngx_lua location capture issue

Nginx User October 18, 2011 01:30PM

Re: ngx_lua location capture issue

Nginx User October 18, 2011 01:30PM

Re: ngx_lua location capture issue

Nginx User October 18, 2011 02:00PM

Re: ngx_lua location capture issue

agentzh October 18, 2011 10:42PM

Re: ngx_lua location capture issue

agentzh October 18, 2011 10:50PM

Re: ngx_lua location capture issue

Nginx User October 19, 2011 12:46PM

Re: ngx_lua location capture issue

agentzh October 18, 2011 10:34PM

Re: ngx_lua location capture issue

agentzh October 19, 2011 05:26AM

Re: ngx_lua location capture issue

Nginx User October 19, 2011 02:12PM

Re: ngx_lua location capture issue

agentzh October 19, 2011 08:44PM

Re: ngx_lua location capture issue

Nginx User October 20, 2011 04:28AM

Re: ngx_lua location capture issue

agentzh October 20, 2011 04:48AM

Re: ngx_lua location capture issue

Nginx User October 20, 2011 06:50AM

Re: ngx_lua location capture issue

agentzh October 20, 2011 07:50AM

Re: ngx_lua location capture issue

Nginx User October 20, 2011 12:04PM

Re: ngx_lua location capture issue

agentzh October 21, 2011 12:10AM

Re: ngx_lua location capture issue

agentzh October 21, 2011 12:14AM

Re: ngx_lua location capture issue

Nginx User October 21, 2011 03:36AM

Re: ngx_lua location capture issue

Nginx User October 21, 2011 03:56AM

Re: ngx_lua location capture issue

Nginx User October 21, 2011 10:02AM

Re: ngx_lua location capture issue

Nginx User October 21, 2011 10:28AM

Re: ngx_lua location capture issue

Nginx User October 21, 2011 10:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready