git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: plug various command-line option injection holes

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 2, 2025, 21:52 UTC
Message-ID
<CAPig+cTPgkkhAdmws9XM58744zs7A4QDOkgnYPcbgB0G9f1ivQ@mail.gmail.com>
In-Reply-To
<22c8463a5eebc609b4848f6db1db231fcce7d839.1756840261.git.me@ttaylorr.com>
On Tue, Sep 2, 2025 at 3:11 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 30 quoted lines
> When running Gitweb and loading a blobdiff with the "hpb" ("hash parent
> base") query parameter set to a valid diff-tree option, say,
> "--output=/tmp/pwned", Gitweb will faithfully execute "diff-tree"
> internally (via "sub git_blobdiff") and blindly pass in the "hpb" query
> parameter.
>
> In other words, visiting a URL like:
>
>     http://127.0.0.1:1234/?p=<PROJECT_NAME>;a=blobdiff;f=*;hpb=--output=/tmp/pwned;hb=HEAD
>
> will result in the file "/tmp/pwned" being created. This happens as a
> result of gitweb executing something like:
>
>     git diff-tree -r -M --output=/tmp/pwned HEAD --
>
> , where "--output=/tmp/pwned" is substituted in as the value of
> "$hash_parent_base".
>
> There are various other spots in Gitweb which are too eager to pass
> untrusted query parameter values as command-line arguments, leading to
> at least the above option-injection attack, and likely many others.
>
> Since 51b4594b40 (parse-options: allow --end-of-options as a synonym for
> "--", 2019-08-06), we have the "--end-of-options" command-line flag as
> a standard mechanism to indicate that any further argument should not be
> interpreted as command-line options.
>
> Guard agains this and other option-injection attacks by placing the
> "--end-of-options" flag before any untrusted user-input in any place
> that gitweb spawns Git as a sub-process.
s/agains/against/
> Reported-by: Moritz Sanft <moritz.sanft@outlook.de>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Previous: Taylor Blau
Message 2 of 2 in “gitweb: plug various command-line option injection holes”
  1. gitweb: plug various command-line option injection holesTaylor Blau, Sep 2, 2025
  2. Eric SunshineSep 2, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.