Hotdog is a set of OCI hooks used to inject the Log4j Hot Patch into containers.

Hotdog

Hotdog is a set of OCI hooks used to inject the Log4j Hot Patch into containers.

How it works

When runc sets up the container, it invokes hotdog-cc-hook. hotdog-cc-hook bind-mounts the hotpatch files into the container's filesystem at /dev/shm/.hotdog. After the main container process starts, runc invokes hotdog-poststart-hook, which uses nsenter to enter the container's namespaces and fork off a hotdog-hotpatch process. hotdog-hotpatch runs several times with decreasing frequency (currently 1s, 5s, 10s, 30s) to detect and hotpach JVMs inside the container.

Limitations

  • Hotdog only provides hotpatching support for Java 8, 11, 15, and 17.
  • Hotdog only runs for a short time at the beginning of a container's lifetime. If new Java processes are started after the hotdog-hotpatch process exits, they will not be hot patched.
  • Hotdog only patches processes named "java". If your Java application has a different process name, hotdog will not patch it.
  • Hotdog works best when the container has its own pid namespace. If hotdog is used with a container that has a shared pid namespace, the hotdog-hotpatch might remain for a short time after the container exits.
  • Hotdog injects its components into /dev/shm/.hotdog inside the container. If /dev/shm does not exist (such as in the case of Docker containers launched with --ipc=none), hotdog will not be injected into the container and will not provide hotpatching.

Installation

To install Hotdog, you need to copy the following files to the right location and set the appropriate configuration.

  • Copy Log4jHotPatch.jar to /usr/share/hotdog (if you build the hotpatch from source, you'll find it in build/libs)
  • Run make && sudo make install to install hotdog-cc-hook and hotdog-poststart-hook to /usr/libexec/hotdog and hotdog-hotpatch to /usr/share/hotdog
  • Install oci-add-hooks
  • Configure oci-add-hooks with the hotdog hooks by writing the following contents to /etc/hotdog/config.json:
    {
      "hooks": {
        "prestart": [{
          "path": "/usr/libexec/hotdog/hotdog-cc-hook"
        }],
        "poststart": [{
          "path": "/usr/libexec/hotdog/hotdog-poststart-hook"
        }]
      }
    }
  • Configure Docker to use the hooks by writing the following contents into /etc/docker/daemon.json:
    {
      "runtimes": {
        "hotdog": {
          "path": "oci-add-hooks",
          "runtimeArgs": [
            "--hook-config-path", "/etc/hotdog/config.json",
            "--runtime-path", "/usr/sbin/runc"
          ]
        }
      }
    }

To run a container with hotpatching enabled, specify docker run --runtime hotdog. To run with hotpatching enabled by default in all containers, add the following contents to /etc/docker/daemon.json:

"default-runtime": "hotdog"

If you wish to opt-out of hotdog even when it is enabled by default, specify --runtime runc.

Troubleshooting

hotdog will add several files to the /dev/shm/.hotdog directory in each container. You can find the log from hotdog-hotpatch in /dev/shm/hotdog.log.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Comments
  • Upgrade go module to go `1.19` and bump dependencies

    Upgrade go module to go `1.19` and bump dependencies

    Description of changes:

    Match version of Go in latest bottlerocket-sdk
    
    Signed-off-by: John McBride <[email protected]>
    
    • Upgrades the go version to 1.19 (the version used in the latest SDK)
      • This also means we'll get to take advantage of the new go mod features which supply indirect dependencies
    • Bumps go dependencies

    Testing done

    Able to build with make


    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

  • Prepare for 1.0.2 release

    Prepare for 1.0.2 release

    Issue #, if available: N / A

    Description of changes: Fixes CVE-2022-0071

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

  • dep: update dependencies

    dep: update dependencies

    Issue #, if available: Partially resolves https://github.com/bottlerocket-os/bottlerocket/issues/2209

    Description of changes: go get -u ... go mod tidy

    Testing: Builds fine. See https://github.com/bottlerocket-os/hotdog/pull/8#pullrequestreview-1050244162 for testing details.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

  • close opened files

    close opened files

    Description of changes: Hotdog opens a few files but failed to close them. Given the short-lived nature of hotdog this is unlikely to be a problem, but it should still be corrected.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

  • disable verbose output from the hotpatch

    disable verbose output from the hotpatch

    This commit modifies the hotpatch options so that does not inject output into stdout of the patched JVM.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

  • docs: add sequence diagram for container lifecycle

    docs: add sequence diagram for container lifecycle

    I thought it would be helpful to have a diagram explaining how hotdog works in the container lifecycle. This should be roughly accurate, but I'd appreciate feedback on clarity.

    rendered diagram

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Related tags
Feb 2, 2022
Gorsair hacks its way into remote docker containers that expose their APIs
Gorsair hacks its way into remote docker containers that expose their APIs

Gorsair Gorsair is a penetration testing tool for discovering and remotely accessing Docker APIs from vulnerable Docker containers. Once it has access

Dec 26, 2022
Scans and catches callbacks of systems that are impacted by Log4J Log4Shell vulnerability across specific headers.
Scans and catches callbacks of systems that are impacted by Log4J Log4Shell vulnerability across specific headers.

Log4ShellScanner Scans and catches callbacks of systems that are impacted by Log4J Log4Shell vulnerability across specific headers. Very Beta Warning!

Jun 17, 2022
Simple local scanner for vulnerable log4j instances

Simple local log4j vulnerability scanner (Written in Go because, you know, "write once, run anywhere.") This is a simple tool that can be used to find

Dec 21, 2022
Divd 2021 00038 log4j scanner

divd-2021-00038--log4j-scanner This scanner will recursively scan paths including archives for vulnerable log4j versions and org/apache/logging/log4j/

Nov 9, 2022
Log4j 2 (CVE-2021-44228) vulnerability scanner for Windows OS
Log4j 2 (CVE-2021-44228) vulnerability scanner for Windows OS

log4j-scanner Log4j 2 (CVE-2021-44228) vulnerability scanner for Windows OS. Example Usage Usage .\log4j-scanner.exe Terminal is used to output resul

Dec 13, 2021
Scanner to send specially crafted requests and catch callbacks of systems that are impacted by Log4J Log4Shell vulnerability (CVE-2021-44228)

scan4log4shell Scanner to send specially crafted requests and catch callbacks of systems that are impacted by Log4J Log4Shell vulnerability CVE-2021-4

Sep 17, 2022
Tool to check whether one of your applications is affected by a vulnerability in log4j: CVE-2021-44228
Tool to check whether one of your applications is affected by a vulnerability in log4j: CVE-2021-44228

log4shell.tools log4shell.tools is a tool allows you to run a test to check whether one of your applications is affected by a vulnerability in log4j:

Nov 2, 2022
Just simple log4j scanner With Golang
Just simple log4j scanner With Golang

Summary Yesterdy which is Decemeber 12, 2021. One of my friend send me a message on twitter that he want me to write a script that brute force list of

Dec 26, 2022
Scan all AWS EC2 instances in a region for potentially vulnerable log4j versions

ec2-log4j-scan Scan all AWS EC2 instances in a region for potentially vulnerable log4j versions. This is a clumsy but effective tool which takes outpu

Dec 28, 2021
Nov 9, 2022
Webserver Log4j Honeypot With Golang

Webserver Log4j Honeypot This honeypots runs fake Webserver waiting to be exploited. Payload classes are saved to payloads directory. Forked from http

Dec 17, 2021
Look for JAR files that vulnerable to Log4j RCE (CVE‐2021‐44228)
Look for JAR files that vulnerable to Log4j RCE (CVE‐2021‐44228)

Look4jar Look for JAR files that vulnerable to Log4j RCE (CVE‐2021‐44228) Objectives It differs from some other tools that scan for vulnerable remote

Dec 25, 2022
A Log4J Version 2 Detector written in golang

Installation From source: go install github.com/juergenhoetzel/log4j2go/cmd/log4

Dec 20, 2021
Yet another log4j vulnerability scanner

k-amon-k - Yet another log4j scanner Quick-n-Dirty installation Assuming you hav

Oct 12, 2022
Log4j-scanner tools - Support for multiple scan method

Log4j-scanner URL mode (fuzzing url with header, payload) go run . url -h Usage

Sep 7, 2022
Collects REST Api calls for log4j reports

log4j-collector This is a simple log4j collector that will collect logs from a H

Dec 20, 2021
Application trying to detect processes vulnerable to log4j JNDI exploit

Log4j JNDI Jar Detector Purpose This application is able to detect jars used by

Jan 25, 2022
Detect and fix log4j log4shell vulnerability (CVE-2021-44228)

log4fix This tool is to detect and fix the log4j log4shell vulnerability (CVE-2021-44228) by looking and removing the JndiLookup class from .jar/.war/

Sep 22, 2022