mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
config: Protect ctlpath from annotation attack
This also adds annotation for ctlpath which were not present before. It's better to implement the code consistenly right now to make sure that we don't end up with a leaky implementation tacked on later. Fixes: #901 Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
@@ -278,6 +278,9 @@ type HypervisorConfig struct {
|
||||
// HypervisorPathList is the list of hypervisor paths names allowed in annotations
|
||||
HypervisorPathList []string
|
||||
|
||||
// HypervisorCtlPathList is the list of hypervisor control paths names allowed in annotations
|
||||
HypervisorCtlPathList []string
|
||||
|
||||
// HypervisorCtlPath is the hypervisor ctl executable host path.
|
||||
HypervisorCtlPath string
|
||||
|
||||
|
@@ -214,6 +214,7 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
||||
HypervisorPath: sconfig.HypervisorConfig.HypervisorPath,
|
||||
HypervisorPathList: sconfig.HypervisorConfig.HypervisorPathList,
|
||||
HypervisorCtlPath: sconfig.HypervisorConfig.HypervisorCtlPath,
|
||||
HypervisorCtlPathList: sconfig.HypervisorConfig.HypervisorCtlPathList,
|
||||
JailerPath: sconfig.HypervisorConfig.JailerPath,
|
||||
JailerPathList: sconfig.HypervisorConfig.JailerPathList,
|
||||
BlockDeviceDriver: sconfig.HypervisorConfig.BlockDeviceDriver,
|
||||
@@ -479,6 +480,7 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
||||
HypervisorPath: hconf.HypervisorPath,
|
||||
HypervisorPathList: hconf.HypervisorPathList,
|
||||
HypervisorCtlPath: hconf.HypervisorCtlPath,
|
||||
HypervisorCtlPathList: hconf.HypervisorCtlPathList,
|
||||
JailerPath: hconf.JailerPath,
|
||||
JailerPathList: hconf.JailerPathList,
|
||||
BlockDeviceDriver: hconf.BlockDeviceDriver,
|
||||
|
@@ -66,6 +66,10 @@ type HypervisorConfig struct {
|
||||
// HypervisorCtlPath is the hypervisor ctl executable host path.
|
||||
HypervisorCtlPath string
|
||||
|
||||
// HypervisorCtlPathList is the list of hypervisor control paths names allowed in annotations
|
||||
HypervisorCtlPathList []string
|
||||
|
||||
// HypervisorCtlPath is the hypervisor ctl executable host path.
|
||||
// JailerPath is the jailer executable host path.
|
||||
JailerPath string
|
||||
|
||||
|
@@ -44,6 +44,9 @@ const (
|
||||
// JailerPath is a sandbox annotation for passing a per container path pointing at the jailer that will constrain the container VM.
|
||||
JailerPath = kataAnnotHypervisorPrefix + "jailer_path"
|
||||
|
||||
// CtlPath is a sandbox annotation for passing a per container path pointing at the acrn ctl binary
|
||||
CtlPath = kataAnnotHypervisorPrefix + "ctlpath"
|
||||
|
||||
// FirmwarePath is a sandbox annotation for passing a per container path pointing at the guest firmware that will run the container VM.
|
||||
FirmwarePath = kataAnnotHypervisorPrefix + "firmware"
|
||||
|
||||
|
@@ -405,6 +405,13 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
|
||||
config.HypervisorConfig.JailerPath = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.CtlPath]; ok {
|
||||
if !regexpContains(runtime.HypervisorConfig.HypervisorCtlPathList, value) {
|
||||
return fmt.Errorf("hypervisor control %v required from annotation is not valid", value)
|
||||
}
|
||||
config.HypervisorConfig.HypervisorCtlPath = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.KernelParams]; ok {
|
||||
if value != "" {
|
||||
params := vc.DeserializeParams(strings.Fields(value))
|
||||
|
Reference in New Issue
Block a user