3206: Protect against CNI plugin being called with the host namespace
adding a check to verify if network namespace is not host network namespace Fixes #3206
This commit is contained in:
1 parent
58eaf19026
commit
27f9aa16d6
1 file changed
+10
@@ -117,6 +117,16 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
|
||||
}
|
||||
defer ns.Close()
|
||||
|
||||
hostNs, err := netns.Get()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error accessing host network namespace: %s", err)
|
||||
}
|
||||
defer hostNs.Close()
|
||||
|
||||
if ns.Equal(hostNs) {
|
||||
return fmt.Errorf("can not specify host network namespace as network namespace to which container should be added")
|
||||
}
|
||||
|
||||
id := args.ContainerID
|
||||
if len(id) < 5 {
|
||||
data := make([]byte, 5)
|
||||
|
||||
Reference in new issue
Block a user