summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2024-09-20 11:08:25 +0530
committerArmin Kuster <akuster808@gmail.com>2024-09-22 10:06:37 -0400
commitce456f692384f56f03328d3466a36f05146314f2 (patch)
tree7eaf7f6d4f07b824760c0c18d8c32a5e7bb0a714
parente2f0fb24c56d8e8cb66c608d9e4ea42ded2f4fd0 (diff)
downloadmeta-openembedded-ce456f692384f56f03328d3466a36f05146314f2.tar.gz
tgt: fix CVE-2024-45751
Upstream-Status: Backport from https://github.com/fujita/tgt/commit/abd8e0d987ab56013d360077202bf2aca20a42dd Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch71
-rw-r--r--meta-networking/recipes-extended/tgt/tgt_1.0.90.bb1
2 files changed, 72 insertions, 0 deletions
diff --git a/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch b/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch
new file mode 100644
index 0000000000..2de9ae9b28
--- /dev/null
+++ b/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch
@@ -0,0 +1,71 @@
1From abd8e0d987ab56013d360077202bf2aca20a42dd Mon Sep 17 00:00:00 2001
2From: Richard Weinberger <richard@nod.at>
3Date: Tue, 3 Sep 2024 16:14:58 +0200
4Subject: [PATCH] chap: Use proper entropy source
5
6The challenge sent to the initiator is based on a poor
7source of randomness, it uses rand() without seeding it by srand().
8So the glibc PRNG is always seeded with 1 and as a consequence the
9sequence of challenges is always the same.
10
11An attacker which is able to monitor network traffic can apply a replay
12attack to bypass the CHAP authentication. All the attacker has to do
13is waiting for the server or the service to restart and replay with a
14previously record CHAP session which fits into the sequence.
15
16To overcome the issue, use getrandom() to query the kernel random
17number generator.
18Also always send a challenge of length CHAP_CHALLENGE_MAX, there is no
19benefit in sending a variable length challenge.
20
21Signed-off-by: Richard Weinberger <richard@nod.at>
22
23Upstream-Status: Backport [https://github.com/fujita/tgt/commit/abd8e0d987ab56013d360077202bf2aca20a42dd]
24CVE: CVE-2024-45751
25Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
26---
27 usr/iscsi/chap.c | 12 +++++-------
28 1 file changed, 5 insertions(+), 7 deletions(-)
29
30diff --git a/usr/iscsi/chap.c b/usr/iscsi/chap.c
31index aa0fc67..b89ecab 100644
32--- a/usr/iscsi/chap.c
33+++ b/usr/iscsi/chap.c
34@@ -28,6 +28,7 @@
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38+#include <sys/random.h>
39
40 #include "iscsid.h"
41 #include "tgtd.h"
42@@ -359,22 +360,19 @@ static int chap_initiator_auth_create_challenge(struct iscsi_connection *conn)
43 sprintf(text, "%u", (unsigned char)conn->auth.chap.id);
44 text_key_add(conn, "CHAP_I", text);
45
46- /*
47- * FIXME: does a random challenge length provide any benefits security-
48- * wise, or should we rather always use the max. allowed length of
49- * 1024 for the (unencoded) challenge?
50- */
51- conn->auth.chap.challenge_size = (rand() % (CHAP_CHALLENGE_MAX / 2)) + CHAP_CHALLENGE_MAX / 2;
52+ conn->auth.chap.challenge_size = CHAP_CHALLENGE_MAX;
53
54 conn->auth.chap.challenge = malloc(conn->auth.chap.challenge_size);
55 if (!conn->auth.chap.challenge)
56 return CHAP_TARGET_ERROR;
57
58+ if (getrandom(conn->auth.chap.challenge, conn->auth.chap.challenge_size, 0) != conn->auth.chap.challenge_size)
59+ return CHAP_TARGET_ERROR;
60+
61 p = text;
62 strcpy(p, "0x");
63 p += 2;
64 for (i = 0; i < conn->auth.chap.challenge_size; i++) {
65- conn->auth.chap.challenge[i] = rand();
66 sprintf(p, "%.2hhx", conn->auth.chap.challenge[i]);
67 p += 2;
68 }
69--
702.25.1
71
diff --git a/meta-networking/recipes-extended/tgt/tgt_1.0.90.bb b/meta-networking/recipes-extended/tgt/tgt_1.0.90.bb
index 35995f7876..f70f77f540 100644
--- a/meta-networking/recipes-extended/tgt/tgt_1.0.90.bb
+++ b/meta-networking/recipes-extended/tgt/tgt_1.0.90.bb
@@ -11,6 +11,7 @@ SRC_URI = "git://github.com/fujita/tgt.git;branch=master;protocol=https \
11 file://0001-usr-Makefile-WARNING-fix.patch \ 11 file://0001-usr-Makefile-WARNING-fix.patch \
12 file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \ 12 file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \
13 file://musl-__wordsize.patch \ 13 file://musl-__wordsize.patch \
14 file://CVE-2024-45751.patch \
14" 15"
15SRC_URI += "file://tgtd.init \ 16SRC_URI += "file://tgtd.init \
16 file://tgtd.service \ 17 file://tgtd.service \