Skip to content

Commit a04ce13

Browse files
CBL-Mariner-Botarchana25-msjslobodzianaaruag
authored
[AUTO-CHERRYPICK] [HIGH] Patch cloud-init for CVE-2024-6174 & [MEDIUM] CVE-2024-11584 - branch 3.0-dev (microsoft#14287)
Co-authored-by: Archana Shettigar <[email protected]> Co-authored-by: jslobodzian <[email protected]> Co-authored-by: aaruag <[email protected]>
1 parent c4f6813 commit a04ce13

File tree

3 files changed

+240
-1
lines changed

3 files changed

+240
-1
lines changed

SPECS/cloud-init/CVE-2024-11584.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From ff05ded14b0555e8e7bc034bbe9c8fba35ed07bc Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <[email protected]>
3+
Date: Fri, 27 Jun 2025 10:59:56 +0000
4+
Subject: [PATCH] Address CVE-2024-11584
5+
Upstream Patch Reference: https://github.com/canonical/cloud-init/pull/6265/commits/6e10240a7f0a2d6110b398640b3fd46cfa9a7cf3
6+
7+
---
8+
cloudinit/cmd/devel/logs.py | 2 +-
9+
systemd/cloud-init-hotplugd.service | 2 +-
10+
systemd/cloud-init-hotplugd.socket | 5 +++--
11+
tools/cloud-init-hotplugd | 2 +-
12+
tools/hook-hotplug | 2 +-
13+
5 files changed, 7 insertions(+), 6 deletions(-)
14+
15+
diff --git a/cloudinit/cmd/devel/logs.py b/cloudinit/cmd/devel/logs.py
16+
index f18bfbe..45a300a 100755
17+
--- a/cloudinit/cmd/devel/logs.py
18+
+++ b/cloudinit/cmd/devel/logs.py
19+
@@ -295,7 +295,7 @@ def _get_run_dir(run_dir: pathlib.Path) -> Iterator[pathlib.Path]:
20+
Note that this only globs the top-level directory as there are currently
21+
no relevant files within subdirectories.
22+
"""
23+
- return (p for p in run_dir.glob("*") if p.name != "hook-hotplug-cmd")
24+
+ return run_dir.glob("*")
25+
26+
27+
def _collect_logs_into_tmp_dir(
28+
diff --git a/systemd/cloud-init-hotplugd.service b/systemd/cloud-init-hotplugd.service
29+
index 2e552a0..5f4c8e8 100644
30+
--- a/systemd/cloud-init-hotplugd.service
31+
+++ b/systemd/cloud-init-hotplugd.service
32+
@@ -1,5 +1,5 @@
33+
# Paired with cloud-init-hotplugd.socket to read from the FIFO
34+
-# /run/cloud-init/hook-hotplug-cmd which is created during a udev network
35+
+# hook-hotplug-cmd which is created during a udev network
36+
# add or remove event as processed by 90-cloud-init-hook-hotplug.rules.
37+
38+
# On start, read args from the FIFO, process and provide structured arguments
39+
diff --git a/systemd/cloud-init-hotplugd.socket b/systemd/cloud-init-hotplugd.socket
40+
index 8300e71..8d6d07c 100644
41+
--- a/systemd/cloud-init-hotplugd.socket
42+
+++ b/systemd/cloud-init-hotplugd.socket
43+
@@ -1,5 +1,5 @@
44+
# cloud-init-hotplugd.socket listens on the FIFO file
45+
-# /run/cloud-init/hook-hotplug-cmd which is created during a udev network
46+
+# hook-hotplug-cmd which is created during a udev network
47+
# add or remove event as processed by 90-cloud-init-hook-hotplug.rules.
48+
49+
# Known bug with an enforcing SELinux policy: LP: #1936229
50+
@@ -11,7 +11,8 @@ ConditionKernelCommandLine=!cloud-init=disabled
51+
ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled
52+
53+
[Socket]
54+
-ListenFIFO=/run/cloud-init/hook-hotplug-cmd
55+
+ListenFIFO=/run/cloud-init/share/hook-hotplug-cmd
56+
+SocketMode=0600
57+
58+
[Install]
59+
WantedBy=cloud-config.target
60+
diff --git a/tools/cloud-init-hotplugd b/tools/cloud-init-hotplugd
61+
index 70977d4..3d56fff 100755
62+
--- a/tools/cloud-init-hotplugd
63+
+++ b/tools/cloud-init-hotplugd
64+
@@ -9,7 +9,7 @@
65+
# upon a network device event). Anything received via the pipe is then
66+
# passed on via the "cloud-init devel hotplug-hook handle" command.
67+
68+
-PIPE="/run/cloud-init/hook-hotplug-cmd"
69+
+PIPE="/run/cloud-init/share/hook-hotplug-cmd"
70+
71+
mkfifo -m700 $PIPE
72+
73+
diff --git a/tools/hook-hotplug b/tools/hook-hotplug
74+
index e3cd2a1..7bd2830 100755
75+
--- a/tools/hook-hotplug
76+
+++ b/tools/hook-hotplug
77+
@@ -4,7 +4,7 @@
78+
# This script checks if cloud-init has hotplug hooked and if
79+
# cloud-init is ready; if so invoke cloud-init hotplug-hook
80+
81+
-fifo=/run/cloud-init/hook-hotplug-cmd
82+
+fifo=/run/cloud-init/share/hook-hotplug-cmd
83+
84+
should_run() {
85+
if [ -d /run/systemd ]; then
86+
--
87+
2.45.3
88+

SPECS/cloud-init/CVE-2024-6174.patch

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
From 161590728c951b933885ef40e664b9db9e585566 Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <[email protected]>
3+
Date: Fri, 27 Jun 2025 10:54:59 +0000
4+
Subject: [PATCH] Address CVE-2024-6174
5+
Upstream Patch Reference: https://github.com/canonical/cloud-init/commit/8c3ae1bb9f1d80fbf217b41a222ee434e7f58900
6+
7+
---
8+
doc/rtd/reference/breaking_changes.rst | 48 ++++++++++++++++++++++++++
9+
tests/unittests/test_ds_identify.py | 13 ++++---
10+
tools/ds-identify | 8 ++---
11+
3 files changed, 58 insertions(+), 11 deletions(-)
12+
13+
diff --git a/doc/rtd/reference/breaking_changes.rst b/doc/rtd/reference/breaking_changes.rst
14+
index 0eba443..6fab8e5 100644
15+
--- a/doc/rtd/reference/breaking_changes.rst
16+
+++ b/doc/rtd/reference/breaking_changes.rst
17+
@@ -11,6 +11,54 @@ releases.
18+
many operating system vendors patch out breaking changes in
19+
cloud-init to ensure consistent behavior on their platform.
20+
21+
+24.3.1
22+
+======
23+
+
24+
+Strict datasource identity before network
25+
+-----------------------------------------
26+
+Affects detection of Ec2, OpenStack or AltCloud datasources for non-x86
27+
+architectures where DMI may not be accessible.
28+
+
29+
+Datasource detection provided by ds-identify in cloud-init now requires strict
30+
+identification based on DMI platform information, kernel command line or
31+
+`datasource_list:` system configuration in /etc/cloud/cloud.cfg.d.
32+
+
33+
+Prior to this change, ds-identify would allow non-x86 architectures without
34+
+strict identifying platform information to run in a discovery mode which would
35+
+attempt to reach out to well known static link-local IPs to attempt to
36+
+retrieve configuration once system networking is up.
37+
+
38+
+To mitigate the potential of a bad-actor in a local network responding
39+
+to such provisioning requests from cloud-init clients, ds-identify will no
40+
+longer allow this late discovery mode for platforms unable to expose clear
41+
+identifying characteristics of a known cloud-init datasource.
42+
+
43+
+The most likely affected cloud platforms are AltCloud, Ec2 and OpenStack for
44+
+non-x86 architectures where DMI data is not exposed by the kernel.
45+
+
46+
+If your non-x86 architecture or images no longer detect the proper datasource,
47+
+any of the following steps can ensure proper detection of cloud-init config:
48+
+
49+
+- Provide kernel commandline containing ``ds=<lowercase_datasource_name>``
50+
+ which forces ds-identify to discover a specific datasource.
51+
+- Image creators: provide a config file part such as
52+
+ :file:`/etc/cloud/cloud.cfg.d/*.cfg` containing the
53+
+ case-sensitive ``datasource_list: [ <datasource_name> ]`` to force cloud-init
54+
+ to use a specific datasource without performing discovery.
55+
+
56+
+For example, to force OpenStack discovery in cloud-init any of the following
57+
+approaches work:
58+
+
59+
+- OpenStack: `attach a ConfigDrive`_ as an alternative config source
60+
+- Kernel command line containing ``ds=openstack``
61+
+- Custom images provide :file:`/etc/cloud/cloud.cfg.d/91-set-datasource.cfg`
62+
+ containing:
63+
+
64+
+.. code-block:: yaml
65+
+
66+
+ datasource_list: [ OpenStack ]
67+
+
68+
+
69+
24.3
70+
====
71+
72+
diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py
73+
index d8f10c1..d2b0f87 100644
74+
--- a/tests/unittests/test_ds_identify.py
75+
+++ b/tests/unittests/test_ds_identify.py
76+
@@ -208,9 +208,9 @@ system_info:
77+
"""
78+
79+
POLICY_FOUND_ONLY = "search,found=all,maybe=none,notfound=disabled"
80+
-POLICY_FOUND_OR_MAYBE = "search,found=all,maybe=all,notfound=disabled"
81+
-DI_DEFAULT_POLICY = "search,found=all,maybe=all,notfound=disabled"
82+
-DI_DEFAULT_POLICY_NO_DMI = "search,found=all,maybe=all,notfound=enabled"
83+
+POLICY_FOUND_OR_MAYBE = "search,found=all,maybe=none,notfound=disabled"
84+
+DI_DEFAULT_POLICY = "search,found=all,maybe=none,notfound=disabled"
85+
+DI_DEFAULT_POLICY_NO_DMI = "search,found=all,maybe=none,notfound=enabled"
86+
DI_EC2_STRICT_ID_DEFAULT = "true"
87+
OVF_MATCH_STRING = "http://schemas.dmtf.org/ovf/environment/1"
88+
89+
@@ -937,7 +937,7 @@ class TestDsIdentify(DsIdentifyBase):
90+
self._test_ds_found("OpenStack-AssetTag-Compute")
91+
92+
def test_openstack_on_non_intel_is_maybe(self):
93+
- """On non-Intel, openstack without dmi info is maybe.
94+
+ """On non-Intel, openstack without dmi info is none.
95+
96+
nova does not identify itself on platforms other than intel.
97+
https://bugs.launchpad.net/cloud-init/+bugs?field.tag=dsid-nova"""
98+
@@ -957,10 +957,9 @@ class TestDsIdentify(DsIdentifyBase):
99+
100+
# updating the uname to ppc64 though should get a maybe.
101+
data.update({"mocks": [MOCK_VIRT_IS_KVM, MOCK_UNAME_IS_PPC64]})
102+
- (_, _, err, _, _) = self._check_via_dict(
103+
- data, RC_FOUND, dslist=["OpenStack", "None"]
104+
- )
105+
+ (_, _, err, _, _) = self._check_via_dict(data, RC_NOT_FOUND)
106+
self.assertIn("check for 'OpenStack' returned maybe", err)
107+
+ self.assertIn("No ds found", err)
108+
109+
def test_default_ovf_is_found(self):
110+
"""OVF is identified found when ovf/ovf-env.xml seed file exists."""
111+
diff --git a/tools/ds-identify b/tools/ds-identify
112+
index 606be9c..bfc8db4 100755
113+
--- a/tools/ds-identify
114+
+++ b/tools/ds-identify
115+
@@ -14,7 +14,7 @@
116+
# The format is:
117+
# <mode>,found=value,maybe=value,notfound=value
118+
# default setting is:
119+
-# search,found=all,maybe=all,notfound=disabled
120+
+# search,found=all,maybe=none,notfound=disabled
121+
#
122+
# kernel command line option: ci.di.policy=<policy>
123+
# example line in /etc/cloud/ds-identify.cfg:
124+
@@ -40,7 +40,7 @@
125+
# first: use the first found do no further checking
126+
# all: enable all DS_FOUND
127+
#
128+
-# maybe: (default=all)
129+
+# maybe: (default=none)
130+
# if nothing returned 'found', then how to handle maybe.
131+
# no network sources are allowed to return 'maybe'.
132+
# all: enable all DS_MAYBE
133+
@@ -100,8 +100,8 @@ DI_MAIN=${DI_MAIN:-main}
134+
135+
DI_BLKID_EXPORT_OUT=""
136+
DI_GEOM_LABEL_STATUS_OUT=""
137+
-DI_DEFAULT_POLICY="search,found=all,maybe=all,notfound=${DI_DISABLED}"
138+
-DI_DEFAULT_POLICY_NO_DMI="search,found=all,maybe=all,notfound=${DI_ENABLED}"
139+
+DI_DEFAULT_POLICY="search,found=all,maybe=none,notfound=${DI_DISABLED}"
140+
+DI_DEFAULT_POLICY_NO_DMI="search,found=all,maybe=none,notfound=${DI_ENABLED}"
141+
DI_DMI_BOARD_NAME=""
142+
DI_DMI_CHASSIS_ASSET_TAG=""
143+
DI_DMI_PRODUCT_NAME=""
144+
--
145+
2.45.3
146+

SPECS/cloud-init/cloud-init.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Cloud instance init scripts
22
Name: cloud-init
33
Version: 24.3.1
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: GPLv3
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -11,6 +11,8 @@ Source0: https://github.com/canonical/%{name}/archive/refs/tags/%{version
1111
Source1: 10-azure-kvp.cfg
1212
Patch0: Add-Network-Interface-Renaming-Support-for-CAPM3-Met.patch
1313
Patch1: no-single-process.patch
14+
Patch2: CVE-2024-6174.patch
15+
Patch3: CVE-2024-11584.patch
1416
%define cl_services cloud-config.service cloud-config.target cloud-final.service cloud-init.service cloud-init.target cloud-init-local.service
1517
BuildRequires: automake
1618
BuildRequires: dbus
@@ -142,6 +144,9 @@ make check %{?_smp_mflags}
142144
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d/10-azure-kvp.cfg
143145

144146
%changelog
147+
* Fri Jun 27 2025 Archana Shettigar <[email protected]> - 24.3.1-2
148+
- Patch CVE-2024-6174 & CVE-2024-11584
149+
145150
* Tue Oct 01 2024 Minghe Ren <[email protected]> - 24.3.1-1
146151
- Upgrade cloud-init to 24.3.1 to support azure-proxy-agent
147152
- Add upstream patch no-single-process.patch to revert a behavior change on cloud-init systemd

0 commit comments

Comments
 (0)