Unable to limit ECS containers to read only access to root filesystem

0

Hi i am trying to solve AWS Security Hub issue 'ECS containers should be limited to read-only access to root filesystem' and already did the suggested Action : Task Definition JSON updated with readonlyRootFilesystem:true.

  • But ECS Service failed to run due to ECS task needs to write into the appsettings.json file inside the root
  • Dotnet and sed command needed to read secret from SSM parameter store and put it in the app config file

The Application required write access to the root filesystem for write application config during build & write temp file during service running Do you have any recommendations on how to solve this ?

Amelia
asked 13 days ago79 views
2 Answers
3

Hello,

To address the AWS Security Hub issue regarding ECS containers having limited read-only access to the root filesystem while still allowing your application to write to specific files, you can follow these recommendations:

  • 1.Use Docker Volumes: Mount volumes to specific directories where your application needs to write data instead of granting write access to the entire root filesystem.

  • 2.Separate Writeable Directories: Identify and grant write access only to specific directories or files within the root filesystem that your application requires.

  • 3.SSM Parameter Store for Secrets: Grant read-only access to SSM parameters containing secrets and fetch them at runtime.

  • 4.Temporary Files: Utilize designated temporary directories like /tmp within the container for storing temporary files.

  • 5.Configuration Management: Dynamically update configuration files at runtime using configuration management tools instead of modifying them directly during build time.

  • 6.Least Privilege Principle: Follow the principle of least privilege by granting only the minimum necessary permissions to your application to ensure security while maintaining functionality.

profile picture
answered 13 days ago
0

Hello,

I would recommend setting readOnly inside the mount points of container definitions to false and test it if that helps to resolve the issue.

{
    "family": "my-task",
    "containerDefinitions": [
        {
            "name": "my-container",
            "image": "my-image",
            "essential": true,
            "mountPoints": [
                {
                    "sourceVolume": "my-volume",
                    "containerPath": "/app/config",
                    "readOnly": false
                }
            ],
            "readonlyRootFilesystem": true
        }
    ],
    "volumes": [
        {
            "name": "my-volume",
            "host": {
                "sourcePath": "/ecs/volumes/my-app-config"
            }
        }
    ]
}
profile picture
answered 13 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions