diff options
author | Hitendra Prajapati <hprajapati@mvista.com> | 2024-09-20 11:08:25 +0530 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2024-09-22 10:06:37 -0400 |
commit | ce456f692384f56f03328d3466a36f05146314f2 (patch) | |
tree | 7eaf7f6d4f07b824760c0c18d8c32a5e7bb0a714 | |
parent | e2f0fb24c56d8e8cb66c608d9e4ea42ded2f4fd0 (diff) | |
download | meta-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.patch | 71 | ||||
-rw-r--r-- | meta-networking/recipes-extended/tgt/tgt_1.0.90.bb | 1 |
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 @@ | |||
1 | From abd8e0d987ab56013d360077202bf2aca20a42dd Mon Sep 17 00:00:00 2001 | ||
2 | From: Richard Weinberger <richard@nod.at> | ||
3 | Date: Tue, 3 Sep 2024 16:14:58 +0200 | ||
4 | Subject: [PATCH] chap: Use proper entropy source | ||
5 | |||
6 | The challenge sent to the initiator is based on a poor | ||
7 | source of randomness, it uses rand() without seeding it by srand(). | ||
8 | So the glibc PRNG is always seeded with 1 and as a consequence the | ||
9 | sequence of challenges is always the same. | ||
10 | |||
11 | An attacker which is able to monitor network traffic can apply a replay | ||
12 | attack to bypass the CHAP authentication. All the attacker has to do | ||
13 | is waiting for the server or the service to restart and replay with a | ||
14 | previously record CHAP session which fits into the sequence. | ||
15 | |||
16 | To overcome the issue, use getrandom() to query the kernel random | ||
17 | number generator. | ||
18 | Also always send a challenge of length CHAP_CHALLENGE_MAX, there is no | ||
19 | benefit in sending a variable length challenge. | ||
20 | |||
21 | Signed-off-by: Richard Weinberger <richard@nod.at> | ||
22 | |||
23 | Upstream-Status: Backport [https://github.com/fujita/tgt/commit/abd8e0d987ab56013d360077202bf2aca20a42dd] | ||
24 | CVE: CVE-2024-45751 | ||
25 | Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> | ||
26 | --- | ||
27 | usr/iscsi/chap.c | 12 +++++------- | ||
28 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
29 | |||
30 | diff --git a/usr/iscsi/chap.c b/usr/iscsi/chap.c | ||
31 | index 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 | -- | ||
70 | 2.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 | " |
15 | SRC_URI += "file://tgtd.init \ | 16 | SRC_URI += "file://tgtd.init \ |
16 | file://tgtd.service \ | 17 | file://tgtd.service \ |