Commit 2d24c49
committed
b645f66 fix: [#277] remove public MySQL port exposure for security (Jose Celano)
Pull request description:
## Summary
Fixes a security vulnerability where MySQL port 3306 was publicly accessible from outside the VM, allowing anyone on the network to connect to the database.
## Problem
The MySQL service in the Docker Compose template exposed port 3306 to all network interfaces:
```yaml
ports:
- "3306:3306"
```
This allowed external connections to the database:
```bash
$ mysql -h <VM_IP> -P 3306 -u tracker_user -p -e "SELECT 1;"
+---+
| 1 |
+---+
| 1 |
+---+
```
## Solution
Removed the `ports` section from the MySQL service. The database remains accessible to the Tracker container through Docker's internal `database_network`, and the healthcheck still works because `mysqladmin ping` runs inside the container.
## Changes
- Removed `ports: - "3306:3306"` from MySQL service in `docker-compose.yml.tera`
- Added security comment explaining why port is not exposed
- Updated unit test to verify port is NOT exposed
## Verification
Tested by deploying a MySQL environment and confirming:
- ✅ `nc -zv <VM_IP> 3306` times out (port not accessible externally)
- ✅ All containers report healthy status including MySQL
- ✅ Tracker can still connect to MySQL via internal Docker network
## Related
Closes #277
---
**Issue Specification**: [docs/issues/277-mysql-port-publicly-exposed.md](docs/issues/277-mysql-port-publicly-exposed.md)
ACKs for top commit:
josecelano:
ACK b645f66
Tree-SHA512: 12e23b9a0769e7afe51b4e8151739e856e35a5cbcf7707e77f6f3c6b312ca87a1ad958190540baa77623aa1f6b1009c2bda094936af9720bea3d740d9874382c
2 files changed
Lines changed: 8 additions & 5 deletions
File tree
- src/infrastructure/templating/docker_compose/template/renderer
- templates/docker-compose
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
| 304 | + | |
305 | 305 | | |
306 | | - | |
307 | | - | |
| 306 | + | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
0 commit comments