Welcome! Log In Create A New Profile

Advanced

Re: ngx_lua location capture issue

Nginx User
October 20, 2011 12:04PM
On 20 October 2011 14:48, agentzh <agentzh@gmail.com> wrote:
> As I said, try using external .lua file and
> content/rewrite/access/set_by_lua_file to avoid nginx string escaping
> issues.

Understood. However, when I follow your instructions on this, things
fail. They seem to work my way.

Take this regex for example: (?:^>[\w\s]*<\/?\w{2,}>)

When I use my "incorrect" escaping in access_by_lua file ...

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>
if query_string then
ngx.exit(ngx.HTTP_BAD_REQUEST)
end

.... the debug log entry is ....

[debug] 24803#0: *154 lua regex cache miss for match regex
"(?:^>[\w\s]*<\/?\w{2,}>)" with options "io"
[debug] 24803#0: *154 lua compiling match regex
"(?:^>[\w\s]*<\/?\w{2,}>)" with options "io" (compile once: 1)
[debug] 24803#0: *154 lua saving compiled regex (0 captures) into the
cache (entries 6)
[debug] 24803#0: *154 regex "(?:^>[\w\s]*<\/?\w{2,}>)" not matched on
string "/trackip/?searchip=213.162.113.89" starting from 0

I.E. the match regex, "(?:^>[\w\s]*<\/?\w{2,}>)" is the same as the original.

I don't know why, but it works and the "correct" escaping does not.

So I'm sticking with this until I start to see problems.

Cheers.

_______________________________________________
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: 176
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