/ Inspec などを使ってサーバーの状態をテストする • tfsec や Conftest などを利用してインフラコードのテストをする control 'sshd-21' do title 'Set SSH Protocol to 2' desc 'A detailed description' impact 1.0 describe sshd_config do its('Protocol') { should cmp 2 } end end package main deny[msg] { input.kind == "Deployment" not input.spec.template.spec.securityContext.runAsNonRoot msg := "Containers must not run as root" }
e.g. S3 バケットのパブリックアクセス、ファイアウォールの全開放など インフラコードの脆弱性検出 • tfsec … https://aquasecurity.github.io/tfsec • cfsec … https://aquasecurity.github.io/cfsec • kics … https://docs.kics.io/latest/ • conftest … https://www.conftest.dev/ • Shisho… https://shisho.dev/ $ tfsec … Result #6 HIGH Public access block does not ignore public ACLs ────────────────────────────────────────────────────────────────────── ─ s3_bucket.tf Lines 9-13 ───────┬────────────────────────────────────────────────────────────── ─ 9 │ resource "aws_s3_bucket_public_access_block" "bad_example" { 10 │ bucket = aws_s3_bucket.example.id 11 │ 12 │ restrict_public_buckets = false 13 │ } ───────┴────────────────────────────────────────────────────────────── ─ ID aws-s3-ignore-public-acls Impact PUT calls with public ACLs specified can make objects public Resolution Enable ignoring the application of public ACLs in PUT calls …