mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
config: Protect vhost_user_store_path against annotation attacks
This path could be used to overwrite data on the host. Fixes: #901 Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
@@ -412,6 +412,9 @@ type HypervisorConfig struct {
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath string
|
||||
|
||||
// VhostUserStorePathList is the list of valid values for vhost-user paths
|
||||
VhostUserStorePathList []string
|
||||
|
||||
// GuestHookPath is the path within the VM that will be used for 'drop-in' hooks
|
||||
GuestHookPath string
|
||||
|
||||
|
@@ -247,6 +247,7 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
|
||||
DisableVhostNet: sconfig.HypervisorConfig.DisableVhostNet,
|
||||
EnableVhostUserStore: sconfig.HypervisorConfig.EnableVhostUserStore,
|
||||
VhostUserStorePath: sconfig.HypervisorConfig.VhostUserStorePath,
|
||||
VhostUserStorePathList: sconfig.HypervisorConfig.VhostUserStorePathList,
|
||||
GuestHookPath: sconfig.HypervisorConfig.GuestHookPath,
|
||||
VMid: sconfig.HypervisorConfig.VMid,
|
||||
RxRateLimiterMaxRate: sconfig.HypervisorConfig.RxRateLimiterMaxRate,
|
||||
@@ -513,6 +514,7 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
|
||||
DisableVhostNet: hconf.DisableVhostNet,
|
||||
EnableVhostUserStore: hconf.EnableVhostUserStore,
|
||||
VhostUserStorePath: hconf.VhostUserStorePath,
|
||||
VhostUserStorePathList: hconf.VhostUserStorePathList,
|
||||
GuestHookPath: hconf.GuestHookPath,
|
||||
VMid: hconf.VMid,
|
||||
RxRateLimiterMaxRate: hconf.RxRateLimiterMaxRate,
|
||||
|
@@ -186,6 +186,9 @@ type HypervisorConfig struct {
|
||||
// related folders, sockets and device nodes should be.
|
||||
VhostUserStorePath string
|
||||
|
||||
// VhostUserStorePathList is the list of valid values for vhost-user paths
|
||||
VhostUserStorePathList []string
|
||||
|
||||
// GuestHookPath is the path within the VM that will be used for 'drop-in' hooks
|
||||
GuestHookPath string
|
||||
|
||||
|
@@ -435,6 +435,13 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig,
|
||||
}
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.VhostUserStorePath]; ok {
|
||||
if !regexpContains(runtime.HypervisorConfig.VhostUserStorePathList, value) {
|
||||
return fmt.Errorf("vhost store path %v required from annotation is not valid", value)
|
||||
}
|
||||
config.HypervisorConfig.VhostUserStorePath = value
|
||||
}
|
||||
|
||||
if value, ok := ocispec.Annotations[vcAnnotations.GuestHookPath]; ok {
|
||||
if value != "" {
|
||||
config.HypervisorConfig.GuestHookPath = value
|
||||
|
Reference in New Issue
Block a user