]> git.ipfire.org Git - thirdparty/git.git/commit
sideband: mask control characters
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 17 Dec 2025 14:23:39 +0000 (14:23 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Dec 2025 01:58:06 +0000 (10:58 +0900)
commita7afa7a1dd73f26b5578c81b14112e36dc55eb3a
treef90115939ff9c9b28c3f86cd2144ec3ac32be571
parenta52a24e03c8c711f1d5e252fba78f9276908129b
sideband: mask control characters

The output of `git clone` is a vital component for understanding what
has happened when things go wrong. However, these logs are partially
under the control of the remote server (via the "sideband", which
typically contains what the remote `git pack-objects` process sends to
`stderr`), and is currently not sanitized by Git.

This makes Git susceptible to ANSI escape sequence injection (see
CWE-150, https://cwe.mitre.org/data/definitions/150.html), which allows
attackers to corrupt terminal state, to hide information, and even to
insert characters into the input buffer (i.e. as if the user had typed
those characters).

To plug this vulnerability, disallow any control character in the
sideband, replacing them instead with the common `^<letter/symbol>`
(e.g. `^[` for `\x1b`, `^A` for `\x01`).

There is likely a need for more fine-grained controls instead of using a
"heavy hammer" like this, which will be introduced subsequently.

Helped-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sideband.c
t/t5409-colorize-remote-messages.sh