CVE-2022-23950 (published 2022-09-21T19:15Z)

In Keylime before 6.3.0, Revocation Notifier uses a fixed /tmp path for UNIX domain socket which can allow unprivileged users a method to prohibit keylime operations.

CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)

Weakness information:
cwe_id: CWE-668
cwe_name: Exposure of Resource to Wrong Sphere
description: The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
extended_description: 
            Resources such as files and directories may be inadvertently exposed through mechanisms such as insecure permissions, or when a program accidentally operates on the wrong object. For example, a program may intend that private files can only be provided to a specific user. This effectively defines a control sphere that is intended to prevent attackers from accessing these private files. If the file permissions are insecure, then parties other than the user will be able to access those files.
            A separate control sphere might effectively require that the user can only access the private files, but not any other files on the system. If the program does not ensure that the user is only requesting private files, then the user might be able to access other files on the system.
            In either case, the end result is that a resource has been exposed to the wrong party.
         
         

Fix information:
repo_url: https://github.com/keylime/keylime
commit_details: repo_url: https://github.com/keylime/keylime
author: Alberto Planas
author_date: 2022-01-18 17:27:31+01:00
msg: revocation_notifier: move zmq socket to /var/run/keylime

Currently we are placing the zmq IPC socket in /tmp, that can be
accessed by all the users.

This patch moves the socket into /var/run/keylime, making sure that the
directory is created and present with the correct user permissions.

Signed-off-by: Alberto Planas <aplanas@suse.com>
repository: repo_url: https://github.com/keylime/keylime
repo_name: keylime/keylime
description: A CNCF Project to Bootstrap & Maintain Trust on the Edge / Cloud and IoT
repo_language: Python
owner: keylime
file_changes: filename: revocation_notifier.py
change_type: ModificationType.MODIFY
diff: @@ -23,12 +23,23 @@ from keylime import secure_mount
 logger = keylime_logging.init_logging('revocation_notifier')
 broker_proc = None
 
+_SOCKET_PATH = "/var/run/keylime/keylime.verifier.ipc"
+
 
 def start_broker():
     def worker():
+        dir_name = os.path.dirname(_SOCKET_PATH)
+        if not os.path.exists(dir_name):
+            os.makedirs(dir_name, 0o700)
+        else:
+            if os.stat(_SOCKET_PATH).st_mode & 0o777 != 0o700:
+                msg = f"{_SOCKET_PATH} present with wrong permissions"
+                logger.error(msg)
+                raise Exception(msg)
+
         context = zmq.Context(1)
         frontend = context.socket(zmq.SUB)
-        frontend.bind("ipc:///tmp/keylime.verifier.ipc")
+        frontend.bind(f"ipc://{_SOCKET_PATH}")
 
         frontend.setsockopt(zmq.SUBSCRIBE, b'')
 
@@ -52,8 +63,8 @@ def stop_broker():
     global broker_proc
     if broker_proc is not None:
         # Remove the socket file before  we kill the process
-        if os.path.exists("/tmp/keylime.verifier.ipc"):
-            os.remove("/tmp/keylime.verifier.ipc")
+        if os.path.exists(f"ipc://{_SOCKET_PATH}"):
+            os.remove(f"ipc://{_SOCKET_PATH}")
         logger.info("Stopping revocation notifier...")
         broker_proc.terminate()
         broker_proc.join()
@@ -63,7 +74,7 @@ def notify(tosend):
     def worker(tosend):
         context = zmq.Context()
         mysock = context.socket(zmq.PUB)
-        mysock.connect("ipc:///tmp/keylime.verifier.ipc")
+        mysock.connect(f"ipc://{_SOCKET_PATH}")
         # wait 100ms for connect to happen
         time.sleep(0.2)
         # now send it out via 0mq

programming_language: Python