Skip to content

Commit 91c9a01

Browse files
committed
Closes-Bug: #1985784 Change-Id: I66476a2b396e2cbe41e68ac51f57aae1806b2ed8 (cherry picked from commit 5b1da01)
1 parent b3e7221 commit 91c9a01

File tree

5 files changed

+24
-53
lines changed

5 files changed

+24
-53
lines changed

doc/source/admin/kolla_api.rst

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,17 @@ Here is an example configuration file:
9393
Passing the configuration file to the container
9494
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9595

96-
The configuration can be either passed via the ``KOLLA_CONFIG`` environment
97-
variable or as a file bind-mounted into the container. When bind-mounting the
98-
configuration file, the ``KOLLA_CONFIG_FILE`` environment variable controls
99-
where the file is located in the container, the default path being
96+
The configuration to the container can be passed through a dedicated path:
10097
``/var/lib/kolla/config_files/config.json``.
101-
102-
Passing the configuration file as environment variable:
103-
104-
.. code-block:: console
105-
106-
docker run -e KOLLA_CONFIG_STRATEGY=COPY_ALWAYS \
107-
-e KOLLA_CONFIG='{ "command": "...", "permissions": [ { "path": "...", } ] }' \
108-
kolla-image
98+
It is advised to ensure this path is mounted read-only for security reasons.
10999

110100
Mounting the configuration file in the container:
111101

112102
.. code-block:: console
113103
114104
docker run -e KOLLA_CONFIG_STRATEGY=COPY_ALWAYS \
115-
-e KOLLA_CONFIG_FILE=/config.json \
116-
-v /path/to/config.json:/config.json kolla-image
105+
-v /path/to/config.json:/var/lib/kolla/config_files/config.json:ro \
106+
kolla-image
117107
118108
.. _kolla_api_environment_variables:
119109

@@ -126,10 +116,6 @@ Variables to pass to the containers
126116
The Kolla containers also understand some environment variables to change their
127117
behavior at runtime:
128118

129-
* **KOLLA_CONFIG**: load kolla config from the environment, takes precedence
130-
over ``KOLLA_CONFIG_FILE``.
131-
* **KOLLA_CONFIG_FILE**: path to kolla json config file, defaults to
132-
``/var/lib/kolla/config_files/config.json``.
133119
* **KOLLA_CONFIG_STRATEGY** (required): Defines how the :ref:`kolla_start
134120
script <kolla_api_external_config>` copies the configuration file. Must be
135121
one of:

docker/base/set_configs.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,8 @@ def validate_source(data):
272272

273273

274274
def load_config():
275-
def load_from_env():
276-
config_raw = os.environ.get("KOLLA_CONFIG")
277-
if config_raw is None:
278-
return None
279-
280-
# Attempt to read config
281-
try:
282-
return json.loads(config_raw)
283-
except ValueError:
284-
raise InvalidConfig('Invalid json for Kolla config')
285-
286275
def load_from_file():
287-
config_file = os.environ.get("KOLLA_CONFIG_FILE")
288-
if not config_file:
289-
config_file = '/var/lib/kolla/config_files/config.json'
276+
config_file = '/var/lib/kolla/config_files/config.json'
290277
LOG.info("Loading config file at %s", config_file)
291278

292279
# Attempt to read config file
@@ -300,9 +287,7 @@ def load_from_file():
300287
raise InvalidConfig(
301288
"Could not read file %s: %r" % (config_file, e))
302289

303-
config = load_from_env()
304-
if config is None:
305-
config = load_from_file()
290+
config = load_from_file()
306291

307292
LOG.info('Validating config file')
308293
validate_config(config)

docker/base/sudoers

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# anyone in the kolla group may sudo -E (set the environment)
77
Defaults: %kolla setenv
88

9+
Defaults secure_path="/var/lib/kolla/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
10+
911
# root may run any commands via sudo as the network seervice user. This is
1012
# neededfor database migrations of existing services which have not been
1113
# converted to run as a non-root user, but instead do that via sudo -E glance
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
security:
3+
- |
4+
Fixes CVE-2022-38060, a sudo privilege escalation vulnerability.
5+
`LP#1985784 <https://launchpad.net/bugs/1889611>`__
6+
upgrade:
7+
- |
8+
To fix CVE-2022-38060, support for KOLLA_CONFIG and KOLLA_CONFIG_FILE
9+
environment variables in kolla-built containers has been dropped.
10+
Now, only the single trusted path of
11+
``/var/lib/kolla/config_files/config.json`` will be utilised for loading
12+
container config.
13+
We believe this is a reasonable tradeoff as these environment variables
14+
were not used by any known downstream and potential users in the wild
15+
can easily adapt as this does not limit the functionality per se, only
16+
making it stricter as to where the config can come from.

tests/test_set_config.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,6 @@ def test_load_ok(self):
5959
mock.call().__exit__(None, None, None)], mo.mock_calls)
6060

6161

62-
class LoadFromEnv(base.BaseTestCase):
63-
64-
def test_load_ok(self):
65-
in_config = json.dumps({'command': '/bin/true',
66-
'config_files': {}})
67-
68-
mo = mock.mock_open()
69-
with mock.patch.object(set_configs, 'open', mo):
70-
with mock.patch.dict('os.environ', {'KOLLA_CONFIG': in_config}):
71-
config = set_configs.load_config()
72-
set_configs.copy_config(config)
73-
self.assertEqual([mock.call('/run_command', 'w+'),
74-
mock.call().__enter__(),
75-
mock.call().write('/bin/true'),
76-
mock.call().__exit__(None, None, None)],
77-
mo.mock_calls)
78-
79-
8062
FAKE_CONFIG_FILES = [
8163
set_configs.ConfigFile(
8264
'/var/lib/kolla/config_files/bar.conf',

0 commit comments

Comments
 (0)