# AWS ECS - how are you keeping your containers secure?

**URL:** <https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453>\
**Category:** AWS Compute Discussion\
**Tags:** ec2, ecs, fargate\
**Created:** [November 8, 2023, 4:03am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453 "2023-11-08T04:03:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![daredeviloper](https://awshq.com/letter_avatar_proxy/v4/letter/d/8baadc/32.png) [@daredeviloper](https://awshq.com/u/daredeviloper)\
**Post date:** [November 8, 2023, 4:03am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/1 "2023-11-08T04:03:14Z")

</div>

So assuming it’s either Fargate or EC2

I understand AWS keeps the host OS secure

And the developers need to keep the container images secure?

If a container has an underlying Linux or windows OS… regardless what the containers are running on(host) , developers need to keep an eye on latest security updates and patches? Then rebuild the images?

If above is true what are best practices for automating this? Just rebuild nightly and deploy?

* * *

**Related discussions:**

- [ECS Agent v1.103.x on the AL2023 arm64 AMI doesnt load pause image](https://awshq.com/t/ecs-agent-v1-103-x-on-the-al2023-arm64-ami-doesnt-load-pause-image/21433)
- [TIFU by ignoring MySQL 8.0 EOL and blaming my Fargate bill spike on the wrong thing](https://awshq.com/t/tifu-by-ignoring-mysql-8-0-eol-and-blaming-my-fargate-bill-spike-on-the-wrong-thing/21555)
- [Can’t launch tasks in us-east-1 (ECS Fargate)](https://awshq.com/t/cant-launch-tasks-in-us-east-1-ecs-fargate/20644)
- [Why Fargate feels like a better fit than Lambda for Neo4j-backed APIs — am I thinking about this right?](https://awshq.com/t/why-fargate-feels-like-a-better-fit-than-lambda-for-neo4j-backed-apis-am-i-thinking-about-this-right/20540)
- [How is the AWS managed Airflow?](https://awshq.com/t/how-is-the-aws-managed-airflow/17035)

---

<div class="post-metadata">

**Author:** ![bretling](https://awshq.com/letter_avatar_proxy/v4/letter/b/a698b9/32.png) [@bretling](https://awshq.com/u/bretling)\
**Post date:** [November 8, 2023, 4:38am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/2 "2023-11-08T04:38:06Z")

</div>

All images are treated as immutable and aren’t modified after the build between environments. All changes, be they application, dependency, configuration, or OS updates are considered changes and go through the full CI/CD process, fully tested, and deployed up through the environments, with production being a blue/green deployment.

---

<div class="post-metadata">

**Author:** ![apparentorder](https://awshq.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@apparentorder](https://awshq.com/u/apparentorder)\
**Post date:** [November 8, 2023, 6:00am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/3 "2023-11-08T06:00:48Z")

</div>

Yes, all correct.

Generally, you need to be aware of all the software components you use and how & when to update them. Tools like Github’s [Dependabot](https://docs.github.com/en/code-security/dependabot) (notification of updated dependencies) and [Amazon Inspector](https://aws.amazon.com/de/inspector/) (vulnerability scanning) can help with that.

---

<div class="post-metadata">

**Author:** ![katatondzsentri](https://awshq.com/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@katatondzsentri](https://awshq.com/u/katatondzsentri)\
**Post date:** [November 8, 2023, 6:45am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/4 "2023-11-08T06:45:55Z")

</div>

You’ve got the right idea about the division of responsibility. With Fargate, AWS abstracts away the host OS, allowing developers to focus more on the container itself. For EC2 instances, developers are also responsible for the AMI’s security.

Indeed, developers need to be vigilant about their container images, ensuring they’re free of vulnerabilities. This often involves regularly scanning the images for security issues, keeping an eye on the updates and patches for the base OS, and updating dependencies.

Rebuilding images regularly is a good practice. Nightly might be overkill for some, depending on the rate of change and the critical nature of the updates. But it’s crucial to establish a cadence that aligns with your risk profile and operational dynamics.

For automating this process, consider the following:

Automated Scanning: Implement automated scanning of container images in the CI/CD pipeline. Tools like AWS Inspector or third-party solutions can be integrated to scan for vulnerabilities at every build.

Base Image Updates: Use a base image that is regularly updated by the community or maintainers. Some organizations use a minimal base image to reduce the attack surface.

Patch Management: Employ a patch management strategy that automatically applies the latest security patches to your images. You can use tools like AWS Systems Manager to automate patching on your EC2 instances.

Immutable Infrastructure: Treat your containers as immutable. Once a vulnerability is detected, don’t patch the container; rebuild and replace it.

Deployment Automation: Automate the deployment of updated containers using services like AWS CodeDeploy or ECS Blue/Green deployments to reduce downtime and risk during updates.

Remember, it’s not just about rebuilding and deploying regularly; it’s about doing it intelligently, based on the vulnerabilities detected, and ensuring that changes go through proper testing. Integrating security into your CI/CD pipeline will enable you to maintain a strong security posture while deploying at the speed required for your business.

---

<div class="post-metadata">

**Author:** ![smarzzz](https://awshq.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@smarzzz](https://awshq.com/u/smarzzz)\
**Post date:** [November 8, 2023, 6:53am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/5 "2023-11-08T06:53:40Z")

</div>

> [@bretling](#):
>
> All images are treated as immutable and aren’t modified after the build between environments. All changes, be they application, dependency, configuration, or OS updates are considered changes and go through the full …

Sure but you can still have issues like LOG4J with remote code execution, in your immutable container. How are you detecting that?

---

<div class="post-metadata">

**Author:** ![seamustheseagull](https://awshq.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@seamustheseagull](https://awshq.com/u/seamustheseagull)\
**Post date:** [November 8, 2023, 7:35am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/6 "2023-11-08T07:35:06Z")

</div>

> [@smarzzz](#):
>
> Sure but you can still have issues like LOG4J with remote code execution, in your immutable container. How are you detecting that?

Log4j is a code vulnerability issue, not an OS one. It should be picked up in the build pipeline.

---

<div class="post-metadata">

**Author:** ![smarzzz](https://awshq.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@smarzzz](https://awshq.com/u/smarzzz)\
**Post date:** [November 8, 2023, 8:06am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/7 "2023-11-08T08:06:20Z")

</div>

> [@seamustheseagull](#):
>
> Log4j is a code vulnerability issue, not an OS one. It should be picked up in the build pipeline.

A zero day cannot be picked up in the build pipeline. Some CVE’s are known after the fact.

How do you monitor you have those running, and if there is some anomaly in network traffic.

---

<div class="post-metadata">

**Author:** ![seamustheseagull](https://awshq.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@seamustheseagull](https://awshq.com/u/seamustheseagull)\
**Post date:** [November 8, 2023, 8:57am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/8 "2023-11-08T08:57:26Z")

</div>

> [@smarzzz](#):
>
> Sure but you can still have issues like LOG4J with remote code execution, in your immutable container. How are you detecting that?

If it’s zero day then nothing is going to pick it up.

Patching is only part of the solution, you still don’t expose containers directly to the internet, you use load balancers and security groups and WAFs.

---

<div class="post-metadata">

**Author:** ![smarzzz](https://awshq.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@smarzzz](https://awshq.com/u/smarzzz)\
**Post date:** [November 8, 2023, 8:59am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/9 "2023-11-08T08:59:57Z")

</div>

> [@seamustheseagull](#):
>
> If it’s zero day then nothing is going to pick it up. Patching is only part of the solution, you still don’t expose containers directly to the internet, you use load balancers and security groups and WAFs.

That’s an interesting approach’s when you use EKS (or any other k8s), any sane company would monitor workloads and network traffic with Datadog, Rapid7 and or netflow logs.

But when you move it to Fargate, the passive nature of a container becomes enough?

That’s not enterprise worthy IMO

---

<div class="post-metadata">

**Author:** ![seamustheseagull](https://awshq.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@seamustheseagull](https://awshq.com/u/seamustheseagull)\
**Post date:** [November 8, 2023, 9:07am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/10 "2023-11-08T09:07:19Z")

</div>

> [@smarzzz](#):
>
> That’s an interesting approach’s when you use EKS (or any other k8s), any sane company would monitor workloads and network traffic with Datadog, Rapid7 and or netflow logs. But when you move it to Fargate, the passive …

How would any of that catch a zero day exploit?

---

<div class="post-metadata">

**Author:** ![lessthan\_pi](https://awshq.com/letter_avatar_proxy/v4/letter/l/848f3c/32.png) [@lessthan\_pi](https://awshq.com/u/lessthan_pi)\
**Post date:** [November 8, 2023, 9:28am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/11 "2023-11-08T09:28:21Z")

</div>

> [@smarzzz](#):
>
> That’s an interesting approach’s when you use EKS (or any other k8s), any sane company would monitor workloads and network traffic with Datadog, Rapid7 and or netflow logs. But when you move it to Fargate, the passive …

Just monitor it like you’d monitor it. Nothing prevents you from doing that in ECS.

---

<div class="post-metadata">

**Author:** ![smarzzz](https://awshq.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@smarzzz](https://awshq.com/u/smarzzz)\
**Post date:** [November 8, 2023, 9:33am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/12 "2023-11-08T09:33:35Z")

</div>

> [@lessthan\_pi](#):
>
> Just monitor it like you’d monitor it. Nothing prevents you from doing that in ECS.

So sidecart rapid7 with every Fargate deployment..? 😉

---

<div class="post-metadata">

**Author:** ![lessthan\_pi](https://awshq.com/letter_avatar_proxy/v4/letter/l/848f3c/32.png) [@lessthan\_pi](https://awshq.com/u/lessthan_pi)\
**Post date:** [November 8, 2023, 9:34am UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/13 "2023-11-08T09:34:54Z")

</div>

> [@smarzzz](#):
>
> So sidecart rapid7 with every Fargate deployment..? 😉

Sounds like a shitty licensing model to me.

---

<div class="post-metadata">

**Author:** ![nathanpeck](https://awshq.com/letter_avatar_proxy/v4/letter/n/ebca7d/32.png) [@nathanpeck](https://awshq.com/u/nathanpeck)\
**Post date:** [November 8, 2023, 1:42pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/14 "2023-11-08T13:42:02Z")

</div>

We have a detailed guide on how to create more secure containers, located here: [https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/security-tasks-containers.html](https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/security-tasks-containers.html)

The two key points that are applicable to your question are:

- Create minimal or use distroless images
- Use Amazon ECR static vulnerability scanning

---

<div class="post-metadata">

**Author:** ![trevorstr](https://awshq.com/letter_avatar_proxy/v4/letter/t/5f9b8f/32.png) [@trevorstr](https://awshq.com/u/trevorstr)\
**Post date:** [November 8, 2023, 2:57pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/15 "2023-11-08T14:57:13Z")

</div>

One thing you’ll need to do is perform container image vulnerability scans. Tools like Trivy help accomplish this, by looking up package metadata against vulnerability databases. Include this container image scanning step after the container image is built, in your CI/CD pipelines.

---

<div class="post-metadata">

**Author:** ![akaender](https://awshq.com/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@akaender](https://awshq.com/u/akaender)\
**Post date:** [November 8, 2023, 3:59pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/16 "2023-11-08T15:59:57Z")

</div>

> [@smarzzz](#):
>
> So sidecart rapid7 with every Fargate deployment..? 😉

I’m not familiar with rapid7 but have used similar tools. Isn’t this the use-case for a [rapid7 network sensor](https://docs.rapid7.com/sensor/network-sensor-for-aws-requirements) on an ec2 that is the target for vpc traffic mirroring from ECS?

When using Fargate for tasks there’s a little extra work needed to keep the ENI’s in sync as tasks are redeployed and eni’s change but it’s fairly trivial to automate with eventbridge events.

---

<div class="post-metadata">

**Author:** ![smarzzz](https://awshq.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@smarzzz](https://awshq.com/u/smarzzz)\
**Post date:** [November 8, 2023, 4:07pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/17 "2023-11-08T16:07:20Z")

</div>

> [@akaender](#):
>
> I’m not familiar with rapid7 but have used similar tools. Isn’t this the use-case for a [rapid7 network sensor](https://docs.rapid7.com/sensor/network-sensor-for-aws-requirements) on an ec2 that is the target for vpc …

That can absolutely be one way of monitoring it. I’m asking here how other people are currently doing it and am downvoted into oblivion because containers are immutable

---

<div class="post-metadata">

**Author:** ![RabiesTingles](https://awshq.com/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@RabiesTingles](https://awshq.com/u/RabiesTingles)\
**Post date:** [November 8, 2023, 4:28pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/18 "2023-11-08T16:28:46Z")

</div>

> [@nathanpeck](#):
>
> We have a detailed guide on how to create more secure containers, located here: …

Add support for vuln scanning on Amazon Linux 2023! It’s a glaring oversight.

---

<div class="post-metadata">

**Author:** ![AntDracula](https://awshq.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@AntDracula](https://awshq.com/u/AntDracula)\
**Post date:** [November 8, 2023, 4:56pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/19 "2023-11-08T16:56:31Z")

</div>

> [@nathanpeck](#):
>
> We have a detailed guide on how to create more secure containers, located here: …

How would you compare this solution, to using AWS inspector?

---

<div class="post-metadata">

**Author:** ![nathanpeck](https://awshq.com/letter_avatar_proxy/v4/letter/n/ebca7d/32.png) [@nathanpeck](https://awshq.com/u/nathanpeck)\
**Post date:** [November 8, 2023, 5:03pm UTC](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453/20 "2023-11-08T17:03:54Z")

</div>

> [@AntDracula](#):
>
> How would you compare this solution, to using AWS inspector?

Inspector is a layer on top of ECR vulnerability scanning. It unifies various scanning capabilities and signals from a variety of sources in your AWS account.

[Next page](https://awshq.com/t/aws-ecs-how-are-you-keeping-your-containers-secure/17453.md?page=2)
