Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added policy to check immutable tags for ecr #1076

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
13 changes: 13 additions & 0 deletions avd_docs/aws/ecr/AVD-AWS-0192/docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Ensures ECR repository image tags cannot be overwritten

### Impact
<!-- Add Impact here -->

<!-- DO NOT CHANGE -->
{{ remediationActions }}

### Links
- https://sysdig.com/blog/toctou-tag-mutability/


1 change: 1 addition & 0 deletions avd_docs/kubernetes/general/AVD-KSV-0108/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Services with external IP addresses allows direct access from the internet and m
### Impact
Kubernetes API server in all versions allow an attacker who is able to create a ClusterIP service and set the spec.externalIPs field, to intercept traffic to that IP address. Additionally, an attacker who is able to patch the status (which is considered a privileged operation and should not typically be granted to users) of a LoadBalancer service can set the status.loadBalancer.ingress.ip to similar effect.
https://www.cvedetails.com/cve/CVE-2020-8554/

SanaaYousaf marked this conversation as resolved.
Show resolved Hide resolved
<!-- DO NOT CHANGE -->
{{ remediationActions }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# METADATA
# title: "ECR Repository Tag Immutability"
# description: "Ensures ECR repository image tags cannot be overwritten"
# scope: package
# schemas:
# - input: schema.input
# related_resources:
# - https://sysdig.com/blog/toctou-tag-mutability/
# custom:
# avd_id: AVD-AWS-0192
# provider: aws
# service: ecr
# severity: HIGH
# short_code: enforce-immutable-repository
# recommended_action: "Update ECR registry configurations to ensure image tag mutability is set to immutable."
# input:
# selector:
# - type: cloud
package builtin.aws.ecr.aws0192

deny[res] {
repo := input.aws.ecr.repositories[_]
not repo.imagetagsimmutable.value
res := result.new("Repository tags are mutable.", repo.imagetagsimmutable)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package builtin.aws.ecr.aws0192

test_detects_when_mutable {
r := deny with input as {"aws": {"ecr": {"repositories": [{"imagetagsimmutable": {"value": false}}]}}}
count(r) == 1
}

test_when_immutable {
r := deny with input as {"aws": {"ecr": {"repositories": [{"imagetagsimmutable": {"value": true}}]}}}
count(r) == 0
}