Description
cap_add: [ALL] grants every Linux capability to the service, including privileged kernel operations the application may never use.
Potential impact
If the application is compromised, those capabilities can give it access to host resources or other containers.
Remediation
Remove ALL from cap_add. Drop unused capabilities with cap_drop and document why the service needs each capability you keep.
Examples
Before
yaml
services:
webapp:
image: nginx:latest
cap_add:
- ALL
After
yaml
services:
webapp:
image: nginx:latest
cap_drop:
- ALL
The example drops every capability. Test Nginx startup and request handling, then restore only the capabilities it needs.