diff options
| author | Hitendra Prajapati <hprajapati@mvista.com> | 2025-10-27 11:52:00 +0530 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-10-31 06:23:13 -0700 |
| commit | bee2fe9cc5d000c823869d709f9db45b4efe81c0 (patch) | |
| tree | ed234f05c7d654f1904c691830e1326f72e1f95e | |
| parent | d0f445a1e2ba46644c8643de60d96fe31150cd8d (diff) | |
| download | poky-bee2fe9cc5d000c823869d709f9db45b4efe81c0.tar.gz | |
git: fix CVE-2025-48386
Upstream-Status: Backport from https://github.com/git/git/commit/9de345cb273cc7faaeda279c7e07149d8a15a319
(From OE-Core rev: 3f2fce1ababbf6c94a9e4995d133d5338913b2ce)
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-devtools/git/git/CVE-2025-48386.patch | 97 | ||||
| -rw-r--r-- | meta/recipes-devtools/git/git_2.35.7.bb | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/meta/recipes-devtools/git/git/CVE-2025-48386.patch b/meta/recipes-devtools/git/git/CVE-2025-48386.patch new file mode 100644 index 0000000000..e78e95dbea --- /dev/null +++ b/meta/recipes-devtools/git/git/CVE-2025-48386.patch | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | From 9de345cb273cc7faaeda279c7e07149d8a15a319 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Taylor Blau <me@ttaylorr.com> | ||
| 3 | Date: Mon, 19 May 2025 18:30:29 -0400 | ||
| 4 | Subject: [PATCH] wincred: avoid buffer overflow in wcsncat() | ||
| 5 | |||
| 6 | The wincred credential helper uses a static buffer ("target") as a | ||
| 7 | unique key for storing and comparing against internal storage. It does | ||
| 8 | this by building up a string is supposed to look like: | ||
| 9 | |||
| 10 | git:$PROTOCOL://$USERNAME@$HOST/@path | ||
| 11 | |||
| 12 | However, the static "target" buffer is declared as a wide string with no | ||
| 13 | more than 1,024 wide characters. The first call to wcsncat() is almost | ||
| 14 | correct (it copies no more than ARRAY_SIZE(target) wchar_t's), but does | ||
| 15 | not account for the trailing NUL, introducing an off-by-one error. | ||
| 16 | |||
| 17 | But subsequent calls to wcsncat() have an additional problem on top of | ||
| 18 | the off-by-one. They do not account for the length of the existing | ||
| 19 | wide string being built up in 'target'. So the following: | ||
| 20 | |||
| 21 | $ perl -e ' | ||
| 22 | my $x = "x" x 1_000; | ||
| 23 | print "protocol=$x\nhost=$x\nusername=$x\npath=$x\n" | ||
| 24 | ' | | ||
| 25 | C\:/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe get | ||
| 26 | |||
| 27 | will result in a segmentation fault from over-filling buffer. | ||
| 28 | |||
| 29 | This bug is as old as the wincred helper itself, dating back to | ||
| 30 | a6253da (contrib: add win32 credential-helper, 2012-07-27). Commit | ||
| 31 | 8b2d219 (wincred: improve compatibility with windows versions, | ||
| 32 | 2013-01-10) replaced the use of strncat() with wcsncat(), but retained | ||
| 33 | the buggy behavior. | ||
| 34 | |||
| 35 | Fix this by using a "target_append()" helper which accounts for both the | ||
| 36 | length of the existing string within the buffer, as well as the trailing | ||
| 37 | NUL character. | ||
| 38 | |||
| 39 | Reported-by: David Leadbeater <dgl@dgl.cx> | ||
| 40 | Helped-by: David Leadbeater <dgl@dgl.cx> | ||
| 41 | Helped-by: Jeff King <peff@peff.net> | ||
| 42 | Signed-off-by: Taylor Blau <me@ttaylorr.com> | ||
| 43 | |||
| 44 | CVE: CVE-2025-48386 | ||
| 45 | Upstream-Status: Backport [https://github.com/git/git/commit/9de345cb273cc7faaeda279c7e07149d8a15a319] | ||
| 46 | Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> | ||
| 47 | --- | ||
| 48 | .../wincred/git-credential-wincred.c | 22 +++++++++++++------ | ||
| 49 | 1 file changed, 15 insertions(+), 7 deletions(-) | ||
| 50 | |||
| 51 | diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c | ||
| 52 | index 5091048..00ecd87 100644 | ||
| 53 | --- a/contrib/credential/wincred/git-credential-wincred.c | ||
| 54 | +++ b/contrib/credential/wincred/git-credential-wincred.c | ||
| 55 | @@ -93,6 +93,14 @@ static void load_cred_funcs(void) | ||
| 56 | |||
| 57 | static WCHAR *wusername, *password, *protocol, *host, *path, target[1024]; | ||
| 58 | |||
| 59 | +static void target_append(const WCHAR *src) | ||
| 60 | +{ | ||
| 61 | + size_t avail = ARRAY_SIZE(target) - wcslen(target) - 1; /* -1 for NUL */ | ||
| 62 | + if (avail < wcslen(src)) | ||
| 63 | + die("target buffer overflow"); | ||
| 64 | + wcsncat(target, src, avail); | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | static void write_item(const char *what, LPCWSTR wbuf, int wlen) | ||
| 68 | { | ||
| 69 | char *buf; | ||
| 70 | @@ -304,17 +312,17 @@ int main(int argc, char *argv[]) | ||
| 71 | |||
| 72 | /* prepare 'target', the unique key for the credential */ | ||
| 73 | wcscpy(target, L"git:"); | ||
| 74 | - wcsncat(target, protocol, ARRAY_SIZE(target)); | ||
| 75 | - wcsncat(target, L"://", ARRAY_SIZE(target)); | ||
| 76 | + target_append(protocol); | ||
| 77 | + target_append(L"://"); | ||
| 78 | if (wusername) { | ||
| 79 | - wcsncat(target, wusername, ARRAY_SIZE(target)); | ||
| 80 | - wcsncat(target, L"@", ARRAY_SIZE(target)); | ||
| 81 | + target_append(wusername); | ||
| 82 | + target_append(L"@"); | ||
| 83 | } | ||
| 84 | if (host) | ||
| 85 | - wcsncat(target, host, ARRAY_SIZE(target)); | ||
| 86 | + target_append(host); | ||
| 87 | if (path) { | ||
| 88 | - wcsncat(target, L"/", ARRAY_SIZE(target)); | ||
| 89 | - wcsncat(target, path, ARRAY_SIZE(target)); | ||
| 90 | + target_append(L"/"); | ||
| 91 | + target_append(path); | ||
| 92 | } | ||
| 93 | |||
| 94 | if (!strcmp(argv[1], "get")) | ||
| 95 | -- | ||
| 96 | 2.50.1 | ||
| 97 | |||
diff --git a/meta/recipes-devtools/git/git_2.35.7.bb b/meta/recipes-devtools/git/git_2.35.7.bb index 2079c3ddc8..063446645e 100644 --- a/meta/recipes-devtools/git/git_2.35.7.bb +++ b/meta/recipes-devtools/git/git_2.35.7.bb | |||
| @@ -28,6 +28,7 @@ SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \ | |||
| 28 | file://CVE-2024-52006.patch \ | 28 | file://CVE-2024-52006.patch \ |
| 29 | file://CVE-2025-27614-CVE-2025-27613-CVE-2025-46334-CVE-2025-46835.patch \ | 29 | file://CVE-2025-27614-CVE-2025-27613-CVE-2025-46334-CVE-2025-46835.patch \ |
| 30 | file://CVE-2025-48384.patch \ | 30 | file://CVE-2025-48384.patch \ |
| 31 | file://CVE-2025-48386.patch \ | ||
| 31 | " | 32 | " |
| 32 | 33 | ||
| 33 | S = "${WORKDIR}/git-${PV}" | 34 | S = "${WORKDIR}/git-${PV}" |
