CRITICAL🇬🇧 English

CVE-2022-24826

RCE w Git LFS na Windows via podatność CWE-426 (untrusted search path)

CVSS 9.8v3.1pub. 2022-04-20upd. 2024-11-21

Git Large File Storage (Git LFS) w wersjach 2.12.1–3.1.2 na systemie Windows jest podatny na wykonanie arbitralnego kodu (RCE) przy pracy z złośliwym repozytorium zawierającym odpowiednio nazwane pliki wykonywalne. Podatność wynika z błędu w obsłudze pustego ciągu znaków jako ścieżki do programu, co prowadzi do przeszukania bieżącego katalogu roboczego zamiast katalogów z PATH.

Pokaż oryginał (EN)

On Windows, if Git LFS operates on a malicious repository with a `..exe` file as well as a file named `git.exe`, and `git.exe` is not found in `PATH`, the `..exe` program will be executed, permitting the attacker to execute arbitrary code. This does not affect Unix systems. Similarly, if the malicious repository contains files named `..exe` and `cygpath.exe`, and `cygpath.exe` is not found in `PATH`, the `..exe` program will be executed when certain Git LFS commands are run. More generally, if the current working directory contains any file with a base name of `.` and a file extension from `PATHEXT` (except `.bat` and `.cmd`), and also contains another file with the same base name as a program Git LFS intends to execute (such as `git`, `cygpath`, or `uname`) and any file extension from `PATHEXT` (including `.bat` and `.cmd`), then, on Windows, when Git LFS attempts to execute the intended program the `..exe`, `..com`, etc., file will be executed instead, but only if the intended program is not found in any directory listed in `PATH`. The vulnerability occurs because when Git LFS detects that the program it intends to run does not exist in any directory listed in `PATH` then Git LFS passes an empty string as the executable file path to the Go `os/exec` package, which contains a bug such that, on Windows, it prepends the name of the current working directory (i.e., `.`) to the empty string without adding a path separator, and as a result searches in that directory for a file with the base name `.` combined with any file extension from `PATHEXT`, executing the first one it finds. (The reason `..bat` and `..cmd` files are not executed in the same manner is that, although the Go `os/exec` package tries to execute them just as it does a `..exe` file, the Microsoft Win32 API `CreateProcess()` family of functions have an undocumented feature in that they apparently recognize when a caller is attempting to execute a batch script file and instead run the `cmd.exe` command interpreter, passing the full set of command line arguments as parameters. These are unchanged from the command line arguments set by Git LFS, and as such, the intended program's name is the first, resulting in a command line like `cmd.exe /c git`, which then fails.) Git LFS has resolved this vulnerability by always reporting an error when a program is not found in any directory listed in `PATH` rather than passing an empty string to the Go `os/exec` package in this case. The bug in the Go `os/exec` package has been reported to the Go project and is expected to be patched after this security advisory is published. The problem was introduced in version 2.12.1 and is patched in version 3.1.3. Users of affected versions should upgrade to version 3.1.3. There are currently no known workarounds at this time.

🤖 Analiza AI
Jak działa

Gdy Git LFS nie odnajduje wymaganego programu (np. `git.exe`, `cygpath.exe`, `uname.exe`) w żadnym katalogu wymienionym w zmiennej środowiskowej `PATH`, przekazuje pusty ciąg znaków jako ścieżkę do pakietu Go `os/exec`. Pakiet ten zawiera błąd, który na systemie Windows dołącza na początku pustego ciągu nazwę bieżącego katalogu roboczego (`.`) bez separatora ścieżki, po czym przeszukuje ten katalog w poszukiwaniu pliku o nazwie bazowej `.` z dowolnym rozszerzeniem z listy `PATHEXT`. Jeśli złośliwe repozytorium zawiera plik `..exe` (lub inne rozszerzenie z `PATHEXT`) oraz plik imitujący oczekiwany program (np. `git.exe`), plik `..exe` zostanie wykonany zamiast zamierzonego programu. Podatność dotyczy wyłącznie systemu Windows; systemy Unix/Linux nie są nią dotknięte.

Skutki

Atakujący, który skłoni ofiarę do sklonowania lub operowania na złośliwym repozytorium, może doprowadzić do wykonania dowolnego kodu z uprawnieniami użytkownika uruchamiającego Git LFS, co w konsekwencji może prowadzić do pełnego przejęcia kontroli nad systemem.

Mitygacja

Należy zaktualizować Git LFS do wersji 3.1.3, w której podatność została naprawiona poprzez zgłaszanie błędu w przypadku nieznalezienia programu w PATH zamiast przekazywania pustego ciągu do pakietu Go `os/exec`. Producent nie wskazuje żadnych dostępnych obejść (workarounds). Dostępne pod adresem: https://github.com/git-lfs/git-lfs/releases

Kogo dotyczy

Git Large File Storage (Git LFS) w wersjach od 2.12.1 do 3.1.2 (włącznie) na systemie Windows.

Uwagi

Błąd w pakiecie Go `os/exec`, który leży u podstaw podatności, został zgłoszony do projektu Go i oczekiwał na patch w momencie publikacji tego advisory. Podatność została wprowadzona w wersji 2.12.1.

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Git Large File Storage Project Git Large File Storage

    APP
    Git Large File Storage Project
    2.12.1 – 3.1.3 (bez)
🔵
ZWERYFIKUJ U PRODUCENTA
Brak jednoznacznych danych o patchu. Sprawdź referencje od producenta.
Tagi
RCE
CWE
Referencje

Powiązane podatności

CVE-2020-27955CRITICAL9.8PL ✓ten sam produkt

RCE w Git Large File Storage (Git LFS) 2.12.0

CVE-2021-21237HIGH7.2ten sam produkt

Git LFS is a command line extension for managing large files with Git. On Windows, if Git LFS operates on a ma...

CVE-2017-17831HIGH8.8ten sam produkt

GitHub Git LFS before 2.1.1 allows remote attackers to execute arbitrary commands via an ssh URL with an initi...