Skip to content

Restrict ptrace attach to privileged users#193

Open
schurzi wants to merge 3 commits into
masterfrom
yama_ptrace
Open

Restrict ptrace attach to privileged users#193
schurzi wants to merge 3 commits into
masterfrom
yama_ptrace

Conversation

@schurzi
Copy link
Copy Markdown
Contributor

@schurzi schurzi commented May 24, 2026

This pull request adds a new security control to the sysctl_spec.rb file to ensure that only privileged users can use ptrace to attach to processes. This helps prevent unprivileged users from interfering with or inspecting other processes, enhancing system security.

Security hardening:

  • Added a control (sysctl-35) to verify that the kernel.yama.ptrace_scope parameter is set to at least 2, restricting ptrace attach operations to privileged users.

@schurzi schurzi linked an issue May 24, 2026 that may be closed by this pull request
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Comment thread controls/sysctl_spec.rb Outdated
desc 'Ensure kernel.yama.ptrace_scope is set to at least 2 so unprivileged users cannot attach ptrace to arbitrary processes.'
only_if { !container_execution }
describe kernel_parameter('kernel.yama.ptrace_scope') do
its(:value) { should eq(2).or eq(3).or eq(nil) } # include nil because SuSE does not have this parameter
Copy link
Copy Markdown
Member

@rndmh3ro rndmh3ro May 26, 2026

Choose a reason for hiding this comment

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

Could we work with an only_if here?

  only_if { !container_execution && !os.suse? }

not sure about the syntax anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

very good point!

Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ptrace should be disabled or admin-only

2 participants