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

Starting subshells via tags

From
DMDave Marotti <landshark666@gmail.com>
Date
Sep 12, 2018, 17:34 UTC
Message-ID
<CA+5phNzsn8wS39aSLZJDNahxYoBuK3QZX81KWpaSKavssVLREw@mail.gmail.com>
Hello -

This is not a git bug or issue. It's just something I stumbled across and didn't see any google results for. I thought others would benefit from being aware of it.

I saw a makefile which included of "git describe --tags --dirty" to define version information for a binary's --version command line parameter. The commit/tag information was passed to g++ in a Makefile via:

CXXFLAGS += -DBUILD_COMMIT="\"$(shell git describe --tags --dirty)\""

For fun (on Linux) I made simple c++ program and Makefile with the above CXXFLAGS, and a tag (backticks work too): git tag '$(echo>/tmp/test.txt)'

Then built. Make executes the git command via a shell and the shell executes the subshell. /tmp/test.txt was created.

The tags themselves don't allow spaces so the complexity of the command is limited, though I didn't explore what I could do with chaining shells or escape characters. It's easy enough to add a script to the repository where the tag is located and execute that script from the tag's subshell with a tag, such as $(./test.sh).

Again, this is not at all a git issue, git is just used as the transport. As with every other shell attack, it comes down to "always sanitize what you pass through to a shell". Or don't pass it to the shell at all, use another mechanism.

Message 1 of 1 in “Starting subshells via tags”
  1. Dave MarottiSep 12, 2018

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.