mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
config: Protect jailer_path annotation
The jailer_path annotation can be used to execute arbitrary code on the host. Add a jailer_path_list configuration entry providing a list of regular expressions that can be used to filter annotations that represent valid file names. Fixes: #901 Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
@@ -284,6 +284,9 @@ type HypervisorConfig struct {
|
||||
// JailerPath is the jailer executable host path.
|
||||
JailerPath string
|
||||
|
||||
// JailerPathList is the list of jailer paths names allowed in annotations
|
||||
JailerPathList []string
|
||||
|
||||
// BlockDeviceDriver specifies the driver to be used for block device
|
||||
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
||||
BlockDeviceDriver string
|
||||
|
@@ -215,6 +215,7 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
||||
HypervisorPathList: sconfig.HypervisorConfig.HypervisorPathList,
|
||||
HypervisorCtlPath: sconfig.HypervisorConfig.HypervisorCtlPath,
|
||||
JailerPath: sconfig.HypervisorConfig.JailerPath,
|
||||
JailerPathList: sconfig.HypervisorConfig.JailerPathList,
|
||||
BlockDeviceDriver: sconfig.HypervisorConfig.BlockDeviceDriver,
|
||||
HypervisorMachineType: sconfig.HypervisorConfig.HypervisorMachineType,
|
||||
MemoryPath: sconfig.HypervisorConfig.MemoryPath,
|
||||
@@ -479,6 +480,7 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
||||
HypervisorPathList: hconf.HypervisorPathList,
|
||||
HypervisorCtlPath: hconf.HypervisorCtlPath,
|
||||
JailerPath: hconf.JailerPath,
|
||||
JailerPathList: hconf.JailerPathList,
|
||||
BlockDeviceDriver: hconf.BlockDeviceDriver,
|
||||
HypervisorMachineType: hconf.HypervisorMachineType,
|
||||
MemoryPath: hconf.MemoryPath,
|
||||
|
@@ -69,6 +69,9 @@ type HypervisorConfig struct {
|
||||
// JailerPath is the jailer executable host path.
|
||||
JailerPath string
|
||||
|
||||
// JailerPathList is the list of jailer paths names allowed in annotations
|
||||
JailerPathList []string
|
||||
|
||||
// BlockDeviceDriver specifies the driver to be used for block device
|
||||
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
||||
BlockDeviceDriver string
|
||||
|
@@ -398,6 +398,13 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
|
||||
config.HypervisorConfig.HypervisorPath = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.JailerPath]; ok {
|
||||
if !regexpContains(runtime.HypervisorConfig.JailerPathList, value) {
|
||||
return fmt.Errorf("jailer %v required from annotation is not valid", value)
|
||||
}
|
||||
config.HypervisorConfig.JailerPath = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.KernelParams]; ok {
|
||||
if value != "" {
|
||||
params := vc.DeserializeParams(strings.Fields(value))
|
||||
|
Reference in New Issue
Block a user