📚 Project Documentation: Analysing Security Risks in Containerized Applications
📝 Project Overview
The project "Analysing Security Risks in Containerized Applications" focuses on identifying, exploiting, and mitigating security vulnerabilities in containerized environments. Using a vulnerable web application running inside Docker containers, we demonstrate how attackers can exploit various security flaws to achieve Remote Code Execution (RCE), extract secrets, and even escape the container to modify the host system. The project highlights security best practices to secure Docker-based applications from such exploits.
🧩 Repository Structure
The repository is structured into three branches:
hack1
hack2
hack3
Each branch contains a specific hacklet demonstrating a unique security vulnerability along with the corresponding exploit and mitigation steps.
👥 Group Members (DFS)
Name | Matriculation Number |
---|---|
David Martinz | 12103632 |
Florian Freising | 12114665 |
Stefan Klug | 12117697 |
📂 Directory Structure
.
├── app # Main application directory
│ ├── __init__.py # App initialization (Flask app factory)
│ ├── routes # Contains Flask route handlers (blueprints)
│ │ ├── auth.py # Authentication routes (login, register)
│ │ ├── messaging.py # Messaging routes (chats, file uploads)
│ │ └── __pycache__ # Compiled Python files (ignored by git)
│ └── uploads # Directory to store uploaded files
│ ├── etc # Directory for uploaded system files (exploit testing)
│ └── malicious.sh # Example malicious file uploaded by an attacker
├── docker-compose.yml # Docker Compose configuration for running the app
├── Dockerfile # Dockerfile to build the container image
├── host_etc # Host directory bind-mounted to the container (used in hacklet)
├── malicious.sh # Exploit script for CVE-2024-21626 (container breakout)
├── requirements.txt # Python dependencies for the app
├── run.py # Main entry point to run the Flask app
├── templates # HTML templates for the web app
│ ├── base.html # Base template (common layout for all pages)
│ ├── chats.html # Template for the chats page
│ ├── conversation.html# Template for conversation/chat window
│ ├── index.html # Homepage template
│ ├── login.html # Login page template
│ ├── macros.html # Reusable UI components (e.g., flash messages)
│ ├── register.html # Registration page template
│ └── send_file.html # Template for sending files
└── uploads # Directory to store user-uploaded files
├── malicious.sh # Uploaded malicious shell script
└── reverse_shell.sh # Reverse shell script uploaded by the attacker
🛠️ How to Run the Web App
-
Clone the repository:
git clone https://github.com/DFS-group/security-in-container-environments.git cd security-in-container-environments/messaging-app
-
Build and run the Docker container:
docker-compose up --build
-
Access the web app at:
http://localhost:5000
🛠️ Tools and Techniques Used
Tool | Purpose |
---|---|
Docker | Containerization |
Flask | Web application framework |
Bash Scripting | Exploit development |
🔎 Analysis and Findings
✅ Common Vulnerabilities Found:
- Insecure File Uploads
- Hardcoded Secrets
- Insecure Bind Mounts
- Running as Root User
🧩 Key Security Issues:
Vulnerability | Hacklet | Impact |
---|---|---|
Insecure File Upload | Hacklet 1 | Remote Code Execution (RCE) |
Hardcoded Secrets | Hacklet 2 | Credential Theft, Unauthorized Access |
Insecure Bind Mounts | Hacklet 3 | Host Filesystem Modification |
Running as Root User | Hacklet 1 & 3 | Privilege Escalation |
📢 Conclusion
This project highlights the importance of securing containerized environments by demonstrating real-world attacks and their mitigations. The identified vulnerabilities show how attackers can exploit common security misconfigurations to achieve RCE, extract sensitive information, or escape the container to modify the host system.