Browse Source

Merge pull request #305 from tonistiigi/cve-2019-14271-1809

[18.09] Initialize nss libraries in Glibc so that the dynamic libraries are l…
Sebastiaan van Stijn 6 years ago
parent
commit
8ff992ae26
1 changed files with 9 additions and 0 deletions
  1. 9 0
      pkg/chrootarchive/archive.go

+ 9 - 0
pkg/chrootarchive/archive.go

@@ -4,13 +4,22 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
+	"net"
 	"os"
+	"os/user"
 	"path/filepath"
 
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/idtools"
 )
 
+func init() {
+	// initialize nss libraries in Glibc so that the dynamic libraries are loaded in the host
+	// environment not in the chroot from untrusted files.
+	_, _ = user.Lookup("docker")
+	_, _ = net.LookupHost("localhost")
+}
+
 // NewArchiver returns a new Archiver which uses chrootarchive.Untar
 func NewArchiver(idMapping *idtools.IdentityMapping) *archive.Archiver {
 	if idMapping == nil {