-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating policies to detect cve-2021-25742
- Loading branch information
1 parent
9dec8e8
commit 1244c25
Showing
4 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "allowedCustomSnippetAnnotations", | ||
"file": "allowedCustomSnippetAnnotations.rego", | ||
"policy_type": "k8s", | ||
"resource_type": "kubernetes_deployment", | ||
"template_args": { | ||
"name": "allowedCustomSnippetAnnotations", | ||
"prefix": "", | ||
"suffix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "CVE-2021-25742: Ingress-nginx with custom snippets allows retrieval of ingress-nginx serviceaccount token and secrets across all namespaces.", | ||
"category": "Configuration and Vulnerability Analysis", | ||
"reference_id": "AC_K8S_0051", | ||
"version": 1, | ||
"id": "AC_K8S_0051" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...policies/opa/rego/k8s/kubernetes_pod/allowedCustomSnippetAnnotationsWithWrongVersion.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[deployment.id] { | ||
deployment := input.kubernetes_deployment[_] | ||
image := deployment.config.spec.template.spec.containers[_].image | ||
|
||
contains(image, "ingress-nginx/controller") | ||
contains(image, "@sha") | ||
version := split(split(image, ":v")[1], "@") | ||
isVulnerableVersion(version) | ||
isAllowSnippetAnnotations(deployment.config.metadata.namespace) | ||
} | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[deployment.id] { | ||
deployment := input.kubernetes_deployment[_] | ||
image := deployment.config.spec.template.spec.containers[_].image | ||
|
||
contains(image, "ingress-nginx/controller") | ||
not contains(image, "@sha") | ||
version := split(image, ":v") | ||
isVulnerableVersion(version) | ||
isAllowSnippetAnnotations(deployment.metadata.namespace) | ||
} | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[deployment.id] { | ||
deployment := input.kubernetes_deployment[_] | ||
image := deployment.config.spec.template.spec.containers[_].image | ||
|
||
contains(image, "ingress-nginx/controller") | ||
contains(image, "@sha") | ||
version := split(split(image, ":v")[1], "@") | ||
isVulnerableVersion(version) | ||
isAllowSnippetAnnotations(deployment.config.metadata.namespace) | ||
} | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[deployment.id] { | ||
deployment := input.kubernetes_deployment[_] | ||
image := deployment.config.spec.template.spec.containers[_].image | ||
|
||
contains(image, "ingress-nginx/controller") | ||
not contains(image, "@sha") | ||
version := split(image, ":v") | ||
isVulnerableVersion(version) | ||
isAllowSnippetAnnotations(deployment.metadata.namespace) | ||
} | ||
|
||
isVulnerableVersion(ver) { | ||
ver[minus(count(ver), 1)] <= "0.49" | ||
} | ||
|
||
isVulnerableVersion(ver) { | ||
ver[minus(count(ver), 1)] == "1.0.0" | ||
} | ||
|
||
isVulnerableVersion(ver) { | ||
ver[0] <= "0.49" | ||
} | ||
|
||
isVulnerableVersion(ver) { | ||
ver[0] == "1.0.0" | ||
} | ||
|
||
isAllowSnippetAnnotations(namespace) { | ||
configmap := input.kubernetes_config_map[_] | ||
configmap.config.metadata.namespace == namespace | ||
configmap.config.data["allow-snippet-annotations"] == "true" | ||
} |