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

feat(etcd): add checks for Kubernetes etcd #3294

Merged
merged 24 commits into from
Feb 22, 2024
Merged

Conversation

MrCloudSec
Copy link
Member

@MrCloudSec MrCloudSec commented Jan 17, 2024

Description

Add all checks for Kubernetes etcd and one left for scheduler:

[etcd_client_cert_auth] Ensure that the --client-cert-auth argument is set to true for etcd - etcd [high]
[etcd_no_auto_tls] Ensure that the --auto-tls argument is not set to true for etcd - etcd [high]
[etcd_no_peer_auto_tls] Ensure that the --peer-auto-tls argument is not set to true for etcd - etcd [high]
[etcd_peer_client_cert_auth] Ensure that the --peer-client-cert-auth argument is set to true for etcd - etcd [high]
[etcd_peer_tls_config] Ensure that the --peer-cert-file and --peer-key-file arguments are set as appropriate for etcd - etcd [high]
[etcd_tls_encryption] Ensure that the --cert-file and --key-file arguments are set as appropriate for etcd - etcd [high]
[etcd_unique_ca] Ensure that a unique Certificate Authority is used for etcd - etcd [high]
[scheduler_bind_address] Ensure that the --bind-address argument is set to 127.0.0.1 for the Scheduler - scheduler [medium]

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@MrCloudSec MrCloudSec requested a review from a team January 17, 2024 13:15
@MrCloudSec MrCloudSec added prowler-4.0 provider/kubernetes Issues/PRs related with the Kubernetes provider labels Jan 17, 2024
Copy link
Member

@jfagoagas jfagoagas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Reviewed with comments about some broken links in the metadata files and the way to check the commands within the pod's containers.

"ResourceType": "EtcdService",
"Description": "This check ensures that client authentication is enabled for the etcd service, which is a key-value store used by Kubernetes for persistent storage of all REST API objects. Enabling client authentication helps in securing access to etcd.",
"Risk": "If --client-cert-auth is not set to true, etcd service may be accessible by unauthenticated clients, posing a significant security risk.",
"RelatedUrl": "https://coreos.com/etcd/docs/latest/op-guide/security.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken link.

},
"Recommendation": {
"Text": "Enable client certificate authentication for the etcd service for improved security.",
"Url": "https://coreos.com/etcd/docs/latest/op-guide/security.html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken link.

"ResourceType": "EtcdService",
"Description": "This check ensures that etcd does not use self-signed certificates for TLS, which are less secure than certificates from a trusted authority. Avoiding self-signed certificates enhances the security of etcd.",
"Risk": "Using --auto-tls=true may result in the use of self-signed certificates, reducing the overall security of the etcd service.",
"RelatedUrl": "https://coreos.com/etcd/docs/latest/op-guide/security.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken link.

},
"Recommendation": {
"Text": "Ensure etcd is not using self-signed certificates for TLS.",
"Url": "https://coreos.com/etcd/docs/latest/op-guide/security.html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken link.

for container in pod.containers.values():
for command in container.command:
if command.startswith("--trusted-ca-file"):
etcd_ca_file = command.split("=")[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here you should get all the CA files configured in each container, not just one because they can be different.

@jfagoagas
Copy link
Member

The controller manager check included in this PR is expected right? If so, add it to the PR body.

@jfagoagas jfagoagas self-requested a review February 22, 2024 15:53
Comment on lines 16 to 18
if "--auto-tls=" in str(container.command) and "--auto-tls=true" in str(
container.command
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if "--auto-tls=" in str(container.command) and "--auto-tls=true" in str(
container.command
):
if "--auto-tls=true" in str(container.command):

for container in pod.containers.values():
if "--peer-cert-file" not in str(
container.command
) or "--peer-key-file" not in str(container.command):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OR or AND?

f"Etcd has client certificate authentication enabled in pod {pod.name}."
)
for container in pod.containers.values():
if "--client-cert-auth=true" not in str(container.command):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include --client-cert-auth

report.status = "PASS"
report.status_extended = f"Etcd is configured for peer client certificate authentication in pod {pod.name}."
for container in pod.containers.values():
if "--peer-client-cert-auth=true" not in str(container.command):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include --peer-client-cert-auth

@jfagoagas jfagoagas self-requested a review February 22, 2024 16:40
@MrCloudSec MrCloudSec merged commit 07b9354 into prowler-4.0-dev Feb 22, 2024
3 of 6 checks passed
@MrCloudSec MrCloudSec deleted the etcd-checks branch February 22, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/kubernetes Issues/PRs related with the Kubernetes provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants