Container Filesystem is Writable

LOW

Service has writable root filesystem. Consider making it read-only for better security.

Rule Information

Language
Docker Compose
Category
Security
Author
Shivasurya
Shivasurya
Last Updated
2026-03-22
Tags
docker-composecomposefilesystemread-onlysecurityimmutabilitymalware-preventionhardeningbest-practice
CWE References

Interactive Playground

Experiment with the vulnerable code and security rule below. Edit the code to see how the rule detects different vulnerability patterns.

pathfinder scan --ruleset docker-compose/COMPOSE-SEC-006 --project .
1
2
3
4
rule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

About This Rule

Understanding the vulnerability and how it is detected

This rule detects services without `read_only: true` filesystem setting. While containers have writable filesystems by default for compatibility, making the root filesystem read-only significantly improves security by preventing attackers from modifying binaries, installing malware, or persisting backdoors within the container.

SECURITY BENEFITS OF READ-ONLY FILESYSTEMS:

1. **Prevents Malware Installation**: Attackers cannot write persistent backdoors or rootkits to the filesystem.

2. **Blocks Binary Modification**: Cannot replace legitimate binaries with trojanized versions.

3. **Immutable Infrastructure**: Enforces that containers are disposable and stateless.

4. **Reduces Attack Persistence**: Malware must remain in memory only, lost on container restart.

How to Fix

Recommended remediation steps

  • 1Review your Dockerfile to address the container filesystem is writable issue
  • 2Follow Docker official best practices for image building
  • 3Use docker build --check to validate Dockerfile syntax and best practices

References

External resources and documentation

Similar Rules

Explore related security rules for Docker Compose

Frequently Asked Questions

Common questions about Container Filesystem is Writable

Service has writable root filesystem. Consider making it read-only for better security.
Review the secure code example in the playground above and apply the recommended pattern to your Dockerfile or docker-compose.yml.

New feature

Get these findings posted directly on your GitHub pull requests

The Container Filesystem is Writable rule runs in CI and posts inline review comments on the exact lines — no dashboard, no SARIF viewer.

See how it works