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

Pass parameters for shell function call using an array rather than (unquoted) string substitution #1608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ntninja
Copy link
Contributor

@ntninja ntninja commented Nov 1, 2018

Description of the issue/feature this PR addresses:
Modoboa assembles strings for shell commands using string substitution without quoting the parameters, leading, at least potentially (I haven't checked), to vulnerabilities (shell injection).

Current behavior before PR:
Assembling shell parameter lists was broken.

Desired behavior after PR is merged:
Assembling shell parameter lists should not be vulnerable to shell injection attacks.

@modoboa modoboa deleted a comment Nov 2, 2018
@modoboa modoboa deleted a comment Nov 2, 2018
@modoboa modoboa deleted a comment Nov 2, 2018
@codecov
Copy link

codecov bot commented Nov 2, 2018

Codecov Report

Merging #1608 into master will decrease coverage by 0.01%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #1608      +/-   ##
==========================================
- Coverage   86.29%   86.28%   -0.02%     
==========================================
  Files         143      143              
  Lines        7560     7561       +1     
==========================================
  Hits         6524     6524              
- Misses       1036     1037       +1

@ntninja
Copy link
Contributor Author

ntninja commented Nov 2, 2018

I fixed the dumb codestyle checker and the bug reported by the CI. Codecov is wrong on its claim however, as there is no coverage change because of this patch: https://codecov.io/gh/modoboa/modoboa/pull/1608/diff

@ntninja
Copy link
Contributor Author

ntninja commented Jan 13, 2019

Bump

cmd = "sudo -u %s %s" % (sudo_user, cmd)
kwargs["shell"] = True
cmd = ["sudo", "-u", sudo_user] + list(cmd)
kwargs["shell"] = False
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's a good idea to change this value since you did not modify commands to include absolute pathes. If you disable shell mode, PATH resolution won't be available, right?

@tonioo
Copy link
Member

tonioo commented Jan 21, 2019

@Alexander255 Could you add a unit test? I don't want your PR (which is useful) to decrease the global coverage ;)

@kryskool kryskool added the stale stale status label Dec 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants