KhronosGroup / KhronosGroup/Vulkan-Loader

VK_INSTANCE_LAYERS security inconsistent with VK_LOADER_LAYERS_* secutity

Open
#1,712 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
695
Forks
343
Avg merge
1d 1h
Merged PRs (30d)
17

Description

I noticed in Vulkan SDK 1.4.313.0 the Vulkan loader treats the new VK_LOADER_LAYERS_* environment variables differently to the old deprecated VK_INSTANCE_LAYERS environment variable.

The new VK_LOADER_LAYERS_* environment variables include VK_LOADER_LAYERS_ENABLE, VK_LOADER_LAYERS_DISABLE and VK_LOADER_LAYERS_ALLOW. All of these are read from the environment in the loader code using loader_secure_getenv(). If the Vulkan loader is executed with elevated privileges then this function will return NULL and not allow these environment variables to be used. The theory being that an elevated application may execute an untrusted (at that level) layer dll and cause harm.

However, the old VK_INSTANCE_LAYERS environment variable uses the loader_getenv() function in the loader code, which reads the environment variable without restrictions.

Since the functionality of VK_INSTANCE_LAYERS is basically the same as VK_LOADER_LAYERS_ENABLE, this means a Vulkan application running with elevated privileges could enable an untrusted layer DLL. Also if VK_INSTANCE_LAYERS is used it overrides VK_LOADER_LAYERS_DISABLE causing a layer to be used even if the user wanted to disable it.

I think using loader_secure_getenv() makes sense for VK_LAYER_PATH, VK_IMPLICIT_LAYER_PATH, VK_ADD_LAYER_PATH and VK_ADD_IMPLICIT_LAYER_PATH, so rogue layer DLL search paths can't be added for elevated processes, but I don't think it make sense for VK_LOADER_LAYERS_ENABLE, VK_LOADER_LAYERS_DISABLE and VK_LOADER_LAYERS_ALLOW which causes legitimate enabling/disabling of trusted layers impossible. In fact the documentation at https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderInterfaceArchitecture.md#active-environment-variables agrees with me since the "Ignored when running Vulkan application with elevated privileges." statement hasn't been added for VK_LOADER_LAYERS_ENABLE, VK_LOADER_LAYERS_DISABLE and VK_LOADER_LAYERS_ALLOW.

If you agree with the above, can the Vulkan loader be modified to allow VK_LOADER_LAYERS_ENABLE, VK_LOADER_LAYERS_DISABLE and VK_LOADER_LAYERS_ALLOW to be used with elevated privilege processes. This requires the calls to loader_secure_getenv() in parse_generic_filter_environment_var() and parse_layers_disable_filter_environment_var() to be modified to loader_getenv().

Contributor guide

Open the contributing guide

Research direction

The issue points to parse_generic_filter_environment_var() and parse_layers_disable_filter_environment_var(); start there and compare their environment-variable handling with VK_INSTANCE_LAYERS. Verify elevated-process behavior for the three VK_LOADER_LAYERS_* variables and confirm that the active-environment-variable documentation matches the resulting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.