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

update(query): Client Certificate Authentication Not Setup Properly #5360

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"category": "Access Control",
"descriptionText": "Client Certificate Authentication should be Setup with a .pem file",
"descriptionText": "Client Certificate Authentication should be Setup with a .pem or .crt file",
"descriptionUrl": "https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/",
"platform": "Kubernetes",
"descriptionID": "78c11e53"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ CxPolicy[result] {
cmd := command[_]
common_lib.inArray(container.command, cmd)
k8sLib.startWithFlag(container,"--client-ca-file")
not k8sLib.startAndEndWithFlag(container,"--client-ca-file", ".pem")
not k8sLib.startAndEndWithFlag(container,"--client-ca-file", ".crt")
not k8sLib.startAndEndWithFlag(container,"--client-ca-file", ".pem")

result := {
"documentId": input.document[i].id,
"searchKey": sprintf("metadata.name={{%s}}.%s.%s.name={{%s}}.command", [metadata.name, specInfo.path, types[x], container.name]),
"issueType": "IncorrectValue",
"keyExpectedValue": "Client Certification should have a .pem file",
"keyExpectedValue": "Client Certification should have a .pem or .crt file",
"keyActualValue": "Client Certification is not properly set",
"searchLine": common_lib.build_search_line(split(specInfo.path, "."), [types[x], j, "command"])
}
Expand Down Expand Up @@ -71,12 +72,13 @@ CxPolicy[result] {
doc :=input.document[i]
doc.kind == "KubeletConfiguration"
not endswith(doc.authentication.x509.clientCAFile, ".pem")
not endswith(doc.authentication.x509.clientCAFile, ".crt")

result := {
"documentId": doc.id,
"searchKey": "kind={{KubeletConfiguration}}",
"issueType": "IncorrectValue",
"keyExpectedValue": "Client Certification should have a .pem file",
"keyExpectedValue": "Client Certification should have a .pem or .crt file",
"keyActualValue": "Client Certification is not properly set",
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
command: ["kube-apiserver"]
args: ["--client-ca-file=/var/lib/ca.crt"]
restartPolicy: OnFailure
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
address: "192.168.0.8"
port: 20250
protectKernelDefaults: false
serializeImagePulls: false
authentication:
anonymous:
enabled: false
webhook:
enabled: true
x509:
clientCAFile: "/var/lib/kubernetes/ca.crt"
authorization:
evictionHard:
memory.available: "200Mi"
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 11,
"filename": "positive1.yaml"
"fileName": "positive1.yaml"
},
{
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 11,
"filename": "positive2.yaml"
"fileName": "positive2.yaml"
},
{
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 11,
"filename": "positive3.yaml"
"fileName": "positive3.yaml"
},
{
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 2,
"filename": "positive4.yaml"
"fileName": "positive4.yaml"
},
{
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 2,
"filename": "positive5.yaml"
"fileName": "positive5.yaml"
},
{
"queryName": "Client Certificate Authentication Not Setup Properly",
"severity": "HIGH",
"line": 2,
"filename": "positive6.yaml"
"fileName": "positive6.yaml"
}
]