浏览代码

Merge pull request #39612 from tiborvass/cve-2019-14271

Fix CVE-2019-14271 loading of nsswitch based config inside chroot under Glibc
Akihiro Suda 6 年之前
父节点
当前提交
11e48badcb
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      pkg/chrootarchive/archive.go

+ 9 - 0
pkg/chrootarchive/archive.go

@@ -4,13 +4,22 @@ import (
 	"fmt"
 	"fmt"
 	"io"
 	"io"
 	"io/ioutil"
 	"io/ioutil"
+	"net"
 	"os"
 	"os"
+	"os/user"
 	"path/filepath"
 	"path/filepath"
 
 
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/idtools"
 	"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
 // NewArchiver returns a new Archiver which uses chrootarchive.Untar
 func NewArchiver(idMapping *idtools.IdentityMapping) *archive.Archiver {
 func NewArchiver(idMapping *idtools.IdentityMapping) *archive.Archiver {
 	if idMapping == nil {
 	if idMapping == nil {