While containers have made it much easier to deploy software, they have also made it easier to deploy malicious software. Imagine that we have an internal company website, written in PHP and deployed in a Docker container. Given the layered nature of the Docker build system, this application is trusting that the images it is building from are secure. Take a look at the following Dockerfile to see just how easy it is to slip something malicious into the image:
FROM php:apache
COPY shell.php /var/www/html/shell.php
COPY index.php /var/www/html/index.php
shell.php is a shell written in PHP that will execute with the permissions of the web server. This means it will be able to read and write (but not overwrite) in the /var/www/html directory.
Be sure to either stop or delete this codespace when you are done by clicking the "Stop" button or the "Delete" button in the Codespaces tab of your repository.
0.0s
PS C:\Users\rxt1077\it230\labs\malicious> docker run -p 8080:80 malicious (2)
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Wed Jul 13 02:25:57.082000 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/8.1.8 configured -- resuming normal operations
[Wed Jul 13 02:25:57.082089 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
To see your webpage, do the following:
If you are using a Github codespace, you should be able to navigate to the "Ports" tab, change the visibility from private to public, and then under forwarded address, control-click the link, which will look something like https://silly-name-jjxwj676vgc5j75-8080.app.github.dev/ to open a new tab in your browser to see see the default web page. Note that may get a warning from Github that "You are about to access a development port served by someone elseβs codespace." If you do, you will need to click "Continue" to proceed to the page.
If you chose to use a Github codespace, donβt forget to stop or delete the codespace by clicking the "Stop" button or the "Delete" button in the Codespaces tab of your repository.