Skip to content

Commit

Permalink
Eval symlinks when checking allowed volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbroms committed Jan 25, 2023
1 parent b4c0e38 commit f6bfa8e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docker/allow/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"path"
"path/filepath"
"strings"

"github.com/docker/docker/api/types/container"
Expand Down Expand Up @@ -45,6 +46,7 @@ func ContainerCreate(req authorization.Request, config *types.Config) *types.All
for _, b := range cc.HostConfig.Binds {
vol := strings.Split(b, ":")

vol[0], _ = filepath.Abs(vol[0])
if !AllowVolume(vol[0], config) {
return &types.AllowResult{
Allow: false,
Expand Down Expand Up @@ -427,6 +429,11 @@ func AllowVolume(vol string, config *types.Config) bool {
return false
}

evaluatedVol, _ := filepath.EvalSymlinks(vol)
if strings.Compare(vol, evaluatedVol) != 0 {
return false
}

// Check for one volume path
vo := objtypes.VolumeOptions{
Recursive: false,
Expand Down

0 comments on commit f6bfa8e

Please sign in to comment.