Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

server: fail if HOME variable has a newline #6450

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

haircommander
Copy link
Member

@haircommander haircommander commented Dec 14, 2022

Signed-off-by: Peter Hunt~ pehunt@redhat.com

What type of PR is this?

/kind deprecation

What this PR does / why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix CVE-2022-4318 by failing to create container if it's passed a HOME environment variable with a newline

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/deprecation dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 14, 2022
@openshift-ci openshift-ci bot requested review from klihub and wgahnagl December 14, 2022 16:52
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 14, 2022
@codecov
Copy link

codecov bot commented Dec 14, 2022

Codecov Report

Merging #6450 (41dca27) into main (5d04dd4) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6450      +/-   ##
==========================================
- Coverage   43.58%   43.57%   -0.01%     
==========================================
  Files         123      123              
  Lines       14390    14392       +2     
==========================================
  Hits         6272     6272              
- Misses       7438     7440       +2     
  Partials      680      680              

@sohankunkerkar
Copy link
Member

/retest

@haircommander haircommander added this to the 1.26 milestone Dec 14, 2022
to prevent CVE-2022-4318

Signed-off-by: Peter Hunt~ <pehunt@redhat.com>
@sohankunkerkar
Copy link
Member

/retest

@haircommander haircommander changed the title WIP server: stop using HOME to set homedir server: fail if HOME variable has a newline Dec 15, 2022
@openshift-ci openshift-ci bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 15, 2022
@haircommander
Copy link
Member Author

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 15, 2022

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/ci-e2e-conmonrs, ci/prow/ci-rhel-integration

In response to this:

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

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.

@haircommander
Copy link
Member Author

@cri-o/cri-o-maintainers PTAL

@haircommander
Copy link
Member Author

@umohnani8 @mrunalp @kolyshkin PTAL

@haircommander
Copy link
Member Author

@@ -201,6 +201,9 @@ func setupContainerUser(ctx context.Context, specgen *generate.Generator, rootfs
for _, env := range specgen.Config.Process.Env {
if strings.HasPrefix(env, "HOME=") {
homedir = strings.TrimPrefix(env, "HOME=")
if idx := strings.Index(homedir, `\n`); idx > -1 {
return fmt.Errorf("invalid HOME environment; newline not allowed")
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of failing, can we continue by dropping \n from the variable?

Copy link
Member Author

@haircommander haircommander Dec 16, 2022

Choose a reason for hiding this comment

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

if the value is set to a path with a newline because the path genuinely has a newline, then the HOME won't be set correctly and the container will fail more nefariously. I think it'd be better to fail quickly and notify the user why, rather than let the homedir be set wrong

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh ok, makes sense. Thanks.

Copy link
Member

@mrunalp mrunalp left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2022
@sohankunkerkar
Copy link
Member

LGTM

@sohankunkerkar
Copy link
Member

/test e2e-gcp-ovn

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 19, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haircommander, mrunalp, sohankunkerkar

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:
  • OWNERS [haircommander,mrunalp]

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

@haircommander
Copy link
Member Author

/override ci/prow/ci-rhel-integration

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 19, 2022

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/ci-rhel-integration

In response to this:

/override ci/prow/ci-rhel-integration

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.

@haircommander
Copy link
Member Author

/override ci/prow/e2e-gcp-ovn

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 19, 2022

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/e2e-gcp-ovn

In response to this:

/override ci/prow/e2e-gcp-ovn

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.

@sohankunkerkar
Copy link
Member

/retest

@haircommander
Copy link
Member Author

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 20, 2022

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/ci-e2e-conmonrs, ci/prow/ci-rhel-integration

In response to this:

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

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.

@haircommander
Copy link
Member Author

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 20, 2022

@haircommander: Overrode contexts on behalf of haircommander: ci/prow/ci-e2e-conmonrs, ci/prow/ci-rhel-integration

In response to this:

/override ci/prow/ci-rhel-integration
/override ci/prow/ci-e2e-conmonrs

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.

@openshift-merge-robot openshift-merge-robot merged commit 3e342bf into cri-o:main Dec 20, 2022
@haircommander
Copy link
Member Author

/cherry-pick release-1.25

@openshift-cherrypick-robot

@haircommander: new pull request created: #6524

In response to this:

/cherry-pick release-1.25

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/deprecation lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants