Skip to content

sysctl-34 - fs.protected_hardlinks and fs.protected_symlinks can be nil #173

@msiebeneicher

Description

@msiebeneicher

The sysctl-34 checks are currently failing with the latest amzn linux 2 images from aws (used ami filter amzn2-ami-hvm-*-x86_64-gp2):

CIS-AMZN2.amazon-ebs.amz-ami:   ×  sysctl-34: Ensure links are protected (2 failed)
CIS-AMZN2.amazon-ebs.amz-ami:      ✔  Kernel Parameter fs.protected_fifos value is expected to eq 1 or eq 2 or eq nil
CIS-AMZN2.amazon-ebs.amz-ami:      ×  Kernel Parameter fs.protected_hardlinks value is expected to eq 1
CIS-AMZN2.amazon-ebs.amz-ami:
CIS-AMZN2.amazon-ebs.amz-ami:      expected: 1
CIS-AMZN2.amazon-ebs.amz-ami:           got: nil
CIS-AMZN2.amazon-ebs.amz-ami:
CIS-AMZN2.amazon-ebs.amz-ami:      (compared using ==)
CIS-AMZN2.amazon-ebs.amz-ami:
CIS-AMZN2.amazon-ebs.amz-ami:      ✔  Kernel Parameter fs.protected_regular value is expected to eq 2 or eq nil
CIS-AMZN2.amazon-ebs.amz-ami:      ×  Kernel Parameter fs.protected_symlinks value is expected to eq 1
CIS-AMZN2.amazon-ebs.amz-ami:
CIS-AMZN2.amazon-ebs.amz-ami:      expected: 1
CIS-AMZN2.amazon-ebs.amz-ami:           got: nil

The issue triggered by the following lines.

fs.protected_hardlinks:

its(:value) { should eq 1 }

fs.protected_symlinks:

its(:value) { should eq 1 }

A possible fix is similar like the already implemented exceptions for fs.protected_regular and fs.protected_fifos:

  describe kernel_parameter('fs.protected_hardlinks') do # include nil because amzn linux does not have this parameter
    its(:value) { should eq(1).or eq(nil) }
  end
  describe kernel_parameter('fs.protected_symlinks') do
    its(:value) { should eq(1).or eq(nil) } # include nil because amzn linux does not have this parameter
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions