# Confirm my false error suspicions of Gitweb query injection

4 messages from 2012-09-10 to 2012-09-10. Participants: Joseph Leong, Matthieu Moy, Junio C Hamano.
Thread: https://gitlist.dev/t/31492

## Joseph Leong, 2012-09-10 16:45

Subject: Confirm my false error suspicions of Gitweb query injection
Message-ID: <CAMOg_eUjmnisevN+AaArz+6TMpWYJL660xwG0ptEaTO7stcL6A@mail.gmail.com>
URL: https://gitlist.dev/e/CAMOg_eUjmnisevN%2BAaArz%2B6TMpWYJL660xwG0ptEaTO7stcL6A%40mail.gmail.com

```
Hi Everyone,

I'm using Gitweb (Based on Git 1.7.9 on RHEL 5.8).

I was poking around and tried a GET Request (REQ) with some SQL
statements as a search query and noticed a 500. Can i just confirm
with anyone here that the error message I'm seeing in the Response
(RESP) is basically saying that the search parameters are invalid
because of it's funny chars are breaking the regex search and that
it's not anything database related.  Thank you!

[REQ]
GET /git/?s=%28select+1234%2C HTTP/1.0

[RESP]
500 - Internal Server Error
Unmatched ( in regex; marked by &lt;-- HERE in m/( &lt;-- HERE select
1234,/ at /var/www/git/gitweb.cgi line 4845.

[Code at gitweb.cgi line 4845]
next if $searchtext and not $pr->{'path'} =~ /$searchtext/ and not
$pr->{'descr_long'} =~ /$searchtext/;

```

## Matthieu Moy, 2012-09-10 17:15

Subject: Re: Confirm my false error suspicions of Gitweb query injection
Message-ID: <vpqvcflhk9c.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqvcflhk9c.fsf%40bauges.imag.fr
In-Reply-To: <CAMOg_eUjmnisevN+AaArz+6TMpWYJL660xwG0ptEaTO7stcL6A@mail.gmail.com>

```
Joseph Leong <josephcleong@gmail.com> writes:

> [RESP]
> 500 - Internal Server Error
> Unmatched ( in regex; marked by &lt;-- HERE in m/( &lt;-- HERE select
> 1234,/ at /var/www/git/gitweb.cgi line 4845.

Gitweb is feeding your input as a perl regex, which is not really clean
but shouldn't really harm either.

I could reproduce with an old gitweb version, but newer gitwebs seem to
be more clever about regular expression (there's an explicit tickbox to
search for re, and the error message is clean when what you provide
isn't a valid regexp).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2012-09-10 17:37

Subject: Re: Confirm my false error suspicions of Gitweb query injection
Message-ID: <7vlighok2h.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vlighok2h.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAMOg_eUjmnisevN+AaArz+6TMpWYJL660xwG0ptEaTO7stcL6A@mail.gmail.com>

```
Joseph Leong <josephcleong@gmail.com> writes:

> Hi Everyone,
>
> I'm using Gitweb (Based on Git 1.7.9 on RHEL 5.8).
>
> I was poking around and tried a GET Request (REQ) with some SQL
> statements as a search query and noticed a 500. Can i just confirm
> with anyone here that the error message I'm seeing in the Response
> (RESP) is basically saying that the search parameters are invalid
> because of it's funny chars are breaking the regex search and that
> it's not anything database related.

Yes, I think this was fixed in v1.7.9.4 if not earlier, with e65ceb6
(gitweb: Fix fixed string (non-regexp) project search, 2012-03-02).

```

## Joseph Leong, 2012-09-10 17:41

Subject: Re: Confirm my false error suspicions of Gitweb query injection
Message-ID: <CAMOg_eUVm08jQSNR1F1iU3Och-Lk07p=vWpkuUz7iZWpi4cEfg@mail.gmail.com>
URL: https://gitlist.dev/e/CAMOg_eUVm08jQSNR1F1iU3Och-Lk07p%3DvWpkuUz7iZWpi4cEfg%40mail.gmail.com
In-Reply-To: <7vlighok2h.fsf@alter.siamese.dyndns.org>

```
and you earned bonus points for the details - thank you very much!


On Mon, Sep 10, 2012 at 10:37 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Joseph Leong <josephcleong@gmail.com> writes:
>
>> Hi Everyone,
>>
>> I'm using Gitweb (Based on Git 1.7.9 on RHEL 5.8).
>>
>> I was poking around and tried a GET Request (REQ) with some SQL
>> statements as a search query and noticed a 500. Can i just confirm
>> with anyone here that the error message I'm seeing in the Response
>> (RESP) is basically saying that the search parameters are invalid
>> because of it's funny chars are breaking the regex search and that
>> it's not anything database related.
>
> Yes, I think this was fixed in v1.7.9.4 if not earlier, with e65ceb6
> (gitweb: Fix fixed string (non-regexp) project search, 2012-03-02).
>

```
