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

Test: Verify if secrets are encrypted #1971

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions RATIONALE.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,6 @@ closing watches for ConfigMaps marked as immutable.*"

#### *Check if Tiller is being used on the plaform*: [Tiller images](docs/LIST_OF_TESTS.md#tiller-images)
> *Tiller, found in Helm v2, has known security challenges. It requires administrative privileges and acts as a shared resource accessible to any authenticated user. Tiller can lead to privilege escalation as restricted users can impact other users. It is recommend to use Helm v3+ which does not contain Tiller for these reasons

#### *Check if secrets are encrypted on the plaform*: [Kubescape secret/etcd](docs/LIST_OF_TESTS.md#kubescape-secret-etcd)
> *Secret encryption is not enabled by default in kubernetes environment. As secrets contains sensitive information, it is recommended to encrypt these values. For encrypting secret in etcd, we are using encryption in rest, this will cause, that there will not be secret key value in plain text format anymore in etcd.
12 changes: 12 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1395,3 +1395,15 @@ Switch to using Helm v3+ and make sure not to pull any images with name tiller i
</b>


## [Kubescape secret/etcd](docs/LIST_OF_TESTS.md#kubescape-secret-etcd)

##### To run the Kubescape secret/etcd test, you can use the following command:
```
./cnf-testsuite platform:kubescape_secret_etc
```

<b>Remediation for failing this test: </b>

Check version of ETCDCTL in etcd pod, it should be v3.+

</b>
4 changes: 4 additions & 0 deletions embedded_files/points.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@
emoji: "🔓🔑"
tags: ["platform", "platform:security", "dynamic"]

- name: kubescape_secret_etcd
emoji: "🔓🔑"
tags: ["platform", "platform:security", "dynamic"]

- name: external_ips
emoji: "🔓🔑"
tags: [security, dynamic, workload, cert, normal]
Expand Down
19 changes: 19 additions & 0 deletions src/tasks/platform/security.cr
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,23 @@ namespace "platform" do
end
end
end

desc "Kubescape secret/etcd"
task "kubescape_secret_etcd", ["kubescape_scan"] do |t, args|
next if args.named["offline"]?

CNFManager::Task.task_runner(args, task: t, check_cnf_installed: false) do |args, config|
results_json = Kubescape.parse
test_json = Kubescape.test_by_test_name(results_json, "Secret/ETCD encryption enabled")
test_report = Kubescape.parse_test_report(test_json)

if test_report.failed_resources.size == 0
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Passed, "Secret/etcd encryption enabled")
else
test_report.failed_resources.map {|r| stdout_failure(r.alert_message) }
stdout_failure("Remediation: #{test_report.remediation}")
CNFManager::TestcaseResult.new(CNFManager::ResultStatus::Failed, "Secret/etcd encryption disabled")
end
end
end
end
Loading