summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2025-10-27 11:52:00 +0530
committerSteve Sakoman <steve@sakoman.com>2025-10-31 06:23:13 -0700
commitbee2fe9cc5d000c823869d709f9db45b4efe81c0 (patch)
treeed234f05c7d654f1904c691830e1326f72e1f95e
parentd0f445a1e2ba46644c8643de60d96fe31150cd8d (diff)
downloadpoky-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.patch97
-rw-r--r--meta/recipes-devtools/git/git_2.35.7.bb1
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 @@
1From 9de345cb273cc7faaeda279c7e07149d8a15a319 Mon Sep 17 00:00:00 2001
2From: Taylor Blau <me@ttaylorr.com>
3Date: Mon, 19 May 2025 18:30:29 -0400
4Subject: [PATCH] wincred: avoid buffer overflow in wcsncat()
5
6The wincred credential helper uses a static buffer ("target") as a
7unique key for storing and comparing against internal storage. It does
8this by building up a string is supposed to look like:
9
10 git:$PROTOCOL://$USERNAME@$HOST/@path
11
12However, the static "target" buffer is declared as a wide string with no
13more than 1,024 wide characters. The first call to wcsncat() is almost
14correct (it copies no more than ARRAY_SIZE(target) wchar_t's), but does
15not account for the trailing NUL, introducing an off-by-one error.
16
17But subsequent calls to wcsncat() have an additional problem on top of
18the off-by-one. They do not account for the length of the existing
19wide 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
27will result in a segmentation fault from over-filling buffer.
28
29This bug is as old as the wincred helper itself, dating back to
30a6253da (contrib: add win32 credential-helper, 2012-07-27). Commit
318b2d219 (wincred: improve compatibility with windows versions,
322013-01-10) replaced the use of strncat() with wcsncat(), but retained
33the buggy behavior.
34
35Fix this by using a "target_append()" helper which accounts for both the
36length of the existing string within the buffer, as well as the trailing
37NUL character.
38
39Reported-by: David Leadbeater <dgl@dgl.cx>
40Helped-by: David Leadbeater <dgl@dgl.cx>
41Helped-by: Jeff King <peff@peff.net>
42Signed-off-by: Taylor Blau <me@ttaylorr.com>
43
44CVE: CVE-2025-48386
45Upstream-Status: Backport [https://github.com/git/git/commit/9de345cb273cc7faaeda279c7e07149d8a15a319]
46Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
47---
48 .../wincred/git-credential-wincred.c | 22 +++++++++++++------
49 1 file changed, 15 insertions(+), 7 deletions(-)
50
51diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
52index 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--
962.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
33S = "${WORKDIR}/git-${PV}" 34S = "${WORKDIR}/git-${PV}"