T09 · Insecure Skill Coding Practices
- Location
docker-compose-generator.sh:10- Finding
Generated Services Use Insecure Credentials and Public Network Exposure
- Content
View full analysis
Vulnerability Details
File Location:
docker-compose-generator.sh, lines 10–22
Vulnerability Type: Hardcoded credentials and insecure service exposure
Risk Level: HighVulnerable Code:
yaml mysql: image: mysql:8 environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: app ports: - "3306:3306" volumes: - mysql_data:/var/lib/mysql redis: image: redis:7-alpine ports: - "6379:6379"Technical Analysis
The generated Docker Compose configuration assigns the predictable value
rootto the MySQL root password. It also publishes MySQL port 3306 and Redis port 6379 without restricting the host address, which normally binds them to all available host interfaces.Redis is generated without a password, ACL configuration, or other authentication requirement. Consequently, starting this configuration on a network-accessible host may expose an unauthenticated Redis instance and a MySQL administrative account protected only by a publicly known password.
Attack Path
- A user runs the generator and starts the resulting Compose stack.
- Docker publishes ports 3306 and 6379 on the host's available interfaces.
- An attacker with network access discovers either published port.
- The attacker connects to MySQL using the known root password
root, or connects to Redis without authentication. - Subject to the services' network configuration and database state, the attacker can read, alter, or delete stored data and use the privileges exposed by the corresponding database account.
Impact Assessment
Successful exploitation may provide administrative access to the generated MySQL database and unauthenticated access to Redis. The affected scope includes data stored by applications using these services, including its confidentiality, integrity, and availability. Exploitation does not directly grant host operating-system privileges based on the reviewe ...[truncated 85 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the hardcoded MySQL root password.
- Require the password to be supplied through a protected environment file, Docker secret, or external secret-management system.
- Validate that a strong password has been provided and fail securely if it is missing.
- Bind development-only ports to localhost, such as
127.0.0.1:3306:3306and127.0.0.1:6379:6379. - Do not publish database ports unless external access is explicitly requested.
- Configure Redis authentication and ACLs, using a securely generated secret.
- Place services on an internal Docker network and allow access only from containers that require it.
- Document that the generated configuration is intended for local development and must not be deployed unchanged in production.
