liveBook · Manning

Container breakout

As explained in Learn Docker in a Month of Lunches, Second Edition

A container breakout is an escape from an application's intended container isolation that allows code or commands to execute against the container or its host context.

A container breakout occurs when compromised application code gains enough access to run arbitrary commands inside its container, changing application behavior or expanding the attack. A large base image can make this easier by including compilers and other build tools that an attacker can reuse. section 17.2

Reduce the available attack surface by:

  • Choosing a base image with everything required to run the application, but without unnecessary application-building tools such as a Java SDK. section 17.2
  • Using golden images maintained by a team to standardize appropriate organizational base images. section 17.2
  • Remembering that interpreted runtimes such as Node.js and Python may be required because the runtime also serves as the build tool. section 17.2

Simulate a breakout in a Java API container

Build and run the truth-app image, call its API, then enter the container with docker container exec. Compile and run the included FileUpdateTest.java using javac and java, exit, and call the API again. The response changes from true to false, demonstrating how bundled build tooling can enable arbitrary code execution inside the application container.

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates a simulated breakout through container shell access and Java compilation, then stops short of describing host escape mechanics.
Examples
Uses a Java REST API, an included test file, Docker exec, javac, java, and before-and-after curl requests.
What you can do after
Apply base-image minimization to reduce executable tooling available after an application-container compromise.
How it connects
Connects container breakout with base images, container isolation, arbitrary code execution, and application security.

Also explained in

Compare how 2 books explain container breakout →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.