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

USHIFT-1050: Set textrel_shlib_t SELinux context on hadolint static executable #1655

Merged
merged 2 commits into from Apr 11, 2023

Conversation

ggiguash
Copy link
Contributor

@ggiguash ggiguash commented Apr 11, 2023

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 11, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 11, 2023

@ggiguash: This pull request references USHIFT-1050 which is a valid jira issue.

In response to this:

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 11, 2023

@ggiguash: This pull request references USHIFT-1050 which is a valid jira issue.

In response to this:

  • Set textrel_shlib_t SELinux context to prevent hadolint crash.
  • Optimize the script to explicitly declare tmp variable in the global scope and rename it to WORK_DIR

Closes USHIFT-1050

Context
hadolint executable is statically linked and it causes the following errors on some systems when SELinux is enabled.

Apr 11 06:30:57 microshift-dev-rhel92 setroubleshoot[32487]: SELinux is preventing /home/microshift/microshift/hadolint-Linux-x86_64 from execmod access on the file /home/microshift/microshift/_output/bin/hadolint.#012#012***** Plugin allow_execmod (53.1 confidence) suggests ****************#12#012If this issue occurred during normal system operation.#012Then this alert could be a serious issue and your system could be compromised. Setroubleshoot examined '/home/microshift/microshift/_output/bin/hadolint' to make sure it was built correctly, but can not determine if this application has been compromised.#012Do#012contact your security administrator and report this issue#012#012 Plugin catchall_boolean (42.6 confidence) suggests *************#12#012If you want to allow all unconfined executables to use libraries requiring text relocation that are not labeled textrel_shlib_t#012Then you must tell SELinux about this by enabling the 'selinuxuser_execmod' boolean.#12#012Do#012setsebool -P selinuxuser_execmod 1#012#012 Plugin catchall (5.76 confidence) suggests **************************#12#012If you believe that hadolint-Linux-x86_64 should be allowed execmod access on the hadolint file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#12# ausearch -c 'hadolint-Linux-' --raw | audit2allow -M my-hadolintLinux#012# semodule -X 300 -i my-hadolintLinux.pp#012

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ggiguash
Copy link
Contributor Author

/cc @chiragkyal
/cc @pmtk
/cc @dhellmann

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2023
@chiragkyal
Copy link
Member

It's LGTM for me. Let's have someone more to review.

# that are not labeled textrel_shlib_t, then you must tell SELinux about this by enabling the
# 'selinuxuser_execmod' boolean.
if selinuxenabled ; then
chcon -t textrel_shlib_t "${DEST_DIR}/${filename}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we only need to do this for hadolint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because, it's the "only" statically linked binary we have and loader / SELinux treat it differently.

@dhellmann
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 11, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhellmann, ggiguash

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 11, 2023

@ggiguash: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 92483e3 into openshift:main Apr 11, 2023
12 checks passed
@ggiguash ggiguash deleted the add_selinux_context branch April 13, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants