Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opencontainers/runc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.11
Choose a base ref
...
head repository: opencontainers/runc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.12
Choose a head ref
  • 14 commits
  • 12 files changed
  • 3 contributors

Commits on Jan 2, 2024

  1. VERSION: back to development

    Signed-off-by: lfbzhm <lifubang@acmcoder.com>
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    lifubang authored and cyphar committed Jan 2, 2024
    Configuration menu
    Copy the full SHA
    7887736 View commit details
    Browse the repository at this point in the history
  2. merge #4160 into opencontainers/runc:release-1.1

    lfbzhm (2):
      VERSION: back to development
      VERSION: release 1.1.11
    
    LGTMs: AkihiroSuda cyphar
    cyphar committed Jan 2, 2024
    Configuration menu
    Copy the full SHA
    452f520 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. keyring: update cyphar@cyphar.com key expiry

    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    d561e5d View commit details
    Browse the repository at this point in the history
  2. keyring: update AkihiroSuda key expiry

    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    d0b1a37 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. merge #4177 into opencontainers/runc:release-1.1

    Aleksa Sarai (2):
      keyring: update AkihiroSuda key expiry
      keyring: update cyphar@cyphar.com key expiry
    
    LGTMs: AkihiroSuda lifubang
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    099ff69 View commit details
    Browse the repository at this point in the history
  2. Fix File to Close

    (This is a cherry-pick of 937ca10.)
    
    Signed-off-by: hang.jiang <hang.jiang@daocloud.io>
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    hang.jiang authored and cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    506552a View commit details
    Browse the repository at this point in the history
  3. init: verify after chdir that cwd is inside the container

    If a file descriptor of a directory in the host's mount namespace is
    leaked to runc init, a malicious config.json could use /proc/self/fd/...
    as a working directory to allow for host filesystem access after the
    container runs. This can also be exploited by a container process if it
    knows that an administrator will use "runc exec --cwd" and the target
    --cwd (the attacker can change that cwd to be a symlink pointing to
    /proc/self/fd/... and wait for the process to exec and then snoop on
    /proc/$pid/cwd to get access to the host). The former issue can lead to
    a critical vulnerability in Docker and Kubernetes, while the latter is a
    container breakout.
    
    We can (ab)use the fact that getcwd(2) on Linux detects this exact case,
    and getcwd(3) and Go's Getwd() return an error as a result. Thus, if we
    just do os.Getwd() after chdir we can easily detect this case and error
    out.
    
    In runc 1.1, a /sys/fs/cgroup handle happens to be leaked to "runc
    init", making this exploitable. On runc main it just so happens that the
    leaked /sys/fs/cgroup gets clobbered and thus this is only consistently
    exploitable for runc 1.1.
    
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    Co-developed-by: lifubang <lifubang@acmcoder.com>
    Signed-off-by: lifubang <lifubang@acmcoder.com>
    [refactored the implementation and added more comments]
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    0994249 View commit details
    Browse the repository at this point in the history
  4. setns init: do explicit lookup of execve argument early

    (This is a partial backport of a minor change included in commit
    dac4171.)
    
    This mirrors the logic in standard_init_linux.go, and also ensures that
    we do not call exec.LookPath in the final execve step.
    
    While this is okay for regular binaries, it seems exec.LookPath calls
    os.Getenv which tries to emit a log entry to the test harness when
    running in "go test" mode. In a future patch (in order to fix
    CVE-2024-21626), we will close all of the file descriptors immediately
    before execve, which would mean the file descriptor for test harness
    logging would be closed at execve time. So, moving exec.LookPath earlier
    is necessary.
    
    Ref: dac4171 ("runc-dmz: reduce memfd binary cloning cost with small C binary")
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    fbe3eed View commit details
    Browse the repository at this point in the history
  5. init: close internal fds before execve

    If we leak a file descriptor referencing the host filesystem, an
    attacker could use a /proc/self/fd magic-link as the source for execve
    to execute a host binary in the container. This would allow the binary
    itself (or a process inside the container in the 'runc exec' case) to
    write to a host binary, leading to a container escape.
    
    The simple solution is to make sure we close all file descriptors
    immediately before the execve(2) step. Doing this earlier can lead to very
    serious issues in Go (as file descriptors can be reused, any (*os.File)
    reference could start silently operating on a different file) so we have
    to do it as late as possible.
    
    Unfortunately, there are some Go runtime file descriptors that we must
    not close (otherwise the Go scheduler panics randomly). The only way of
    being sure which file descriptors cannot be closed is to sneakily
    go:linkname the runtime internal "internal/poll.IsPollDescriptor"
    function. This is almost certainly not recommended but there isn't any
    other way to be absolutely sure, while also closing any other possible
    files.
    
    In addition, we can keep the logrus forwarding logfd open because you
    cannot execve a pipe and the contents of the pipe are so restricted
    (JSON-encoded in a format we pick) that it seems unlikely you could even
    construct shellcode. Closing the logfd causes issues if there is an
    error returned from execve.
    
    In mainline runc, runc-dmz protects us against this attack because the
    intermediate execve(2) closes all of the O_CLOEXEC internal runc file
    descriptors and thus runc-dmz cannot access them to attack the host.
    
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    284ba30 View commit details
    Browse the repository at this point in the history
  6. cgroup: plug leaks of /sys/fs/cgroup handle

    We auto-close this file descriptor in the final exec step, but it's
    probably a good idea to not possibly leak the file descriptor to "runc
    init" (we've had issues like this in the past) especially since it is a
    directory handle from the host mount namespace.
    
    In practice, on runc 1.1 this does leak to "runc init" but on main the
    handle has a low enough file descriptor that it gets clobbered by the
    ForkExec of "runc init".
    
    OPEN_TREE_CLONE would let us protect this handle even further, but the
    performance impact of creating an anonymous mount namespace is probably
    not worth it.
    
    Also, switch to using an *os.File for the handle so if it goes out of
    scope during setup (i.e. an error occurs during setup) it will get
    cleaned up by the GC.
    
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    b6633f4 View commit details
    Browse the repository at this point in the history
  7. libcontainer: mark all non-stdio fds O_CLOEXEC before spawning init

    Given the core issue in GHSA-xr7r-f8xq-vfvv was that we were unknowingly
    leaking file descriptors to "runc init", it seems prudent to make sure
    we proactively prevent this in the future. The solution is to simply
    mark all non-stdio file descriptors as O_CLOEXEC before we spawn "runc
    init".
    
    For libcontainer library users, this could result in unrelated files
    being marked as O_CLOEXEC -- however (for the same reason we are doing
    this for runc), for security reasons those files should've been marked
    as O_CLOEXEC anyway.
    
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    683ad2f View commit details
    Browse the repository at this point in the history
  8. init: don't special-case logrus fds

    We close the logfd before execve so there's no need to special case it.
    In addition, it turns out that (*os.File).Fd() doesn't handle the case
    where the file was closed and so it seems suspect to use that kind of
    check.
    
    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    e9665f4 View commit details
    Browse the repository at this point in the history
  9. merge 1.1-GHSA-xr7r-f8xq-vfvv into release-1.1

    This is a security fix for CVE-2024-21626. See the advisory[1] for more
    details.
    
    Aleksa Sarai (6):
      init: don't special-case logrus fds
      libcontainer: mark all non-stdio fds O_CLOEXEC before spawning init
      cgroup: plug leaks of /sys/fs/cgroup handle
      init: close internal fds before execve
      setns init: do explicit lookup of execve argument early
      init: verify after chdir that cwd is inside the container
    
    Hang Jiang (1):
      Fix File to Close
    
    [1]: GHSA-xr7r-f8xq-vfvv
    
    Fixes: GHSA-xr7r-f8xq-vfvv CVE-2024-21626
    LGTMs: cyphar AkihiroSuda kolyshkin lifubang
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    2a4ed3e View commit details
    Browse the repository at this point in the history
  10. VERSION: release 1.1.12

    Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
    cyphar committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    51d5e94 View commit details
    Browse the repository at this point in the history
Loading