Skip to content

Commit 2c9598c

Browse files
committed
libct/cgroups.OpenFile: clean "file" argument
This prevents potential exploit of using "../" in cgroups.OpenFile (as well as other methods that use OpenFile) to read or write to other cgroups. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent edd00eb commit 2c9598c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcontainer/cgroups/file.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111
"sync"
1212

13+
"github.com/opencontainers/runc/libcontainer/utils"
1314
"github.com/sirupsen/logrus"
1415
"golang.org/x/sys/unix"
1516
)
@@ -111,7 +112,7 @@ func openFile(dir, file string, flags int) (*os.File, error) {
111112
flags |= os.O_TRUNC | os.O_CREATE
112113
mode = 0o600
113114
}
114-
path := path.Join(dir, file)
115+
path := path.Join(dir, utils.CleanPath(file))
115116
if prepareOpenat2() != nil {
116117
return openFallback(path, flags, mode)
117118
}

0 commit comments

Comments
 (0)