-
Notifications
You must be signed in to change notification settings - Fork 134
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
security: use quote with command, shell and validate with variable #245
base: main
Are you sure you want to change the base?
Conversation
Changed test to use flagfile instead of user. |
This avoids issues if file names are not safepaths.
Skip quotation only if variable is checked. Add test suit to excercise some quote use cases.
Ensure systemd.unit contents is robust. This disables possibility to have something that needs to be quoted there. But as ansible lacks proper way to quote systemd unit files (see man systemd.syntax, rules are not shell rules), it is better to fail such configs. If you are trying to do that, you are doing it wrong anyway or have malicious intent. Also ensure similar issue with sysctl.conf. Issue can be seen with `tests_hostkeys_unsafe_path.yml`, when adding following to role params: sshd_install_service: true sshd_config_file: "{{ ansible_facts.env.TMPDIR }}/sshd.d/foo.conf" sshd_binary: "{{ ansible_facts.env.TMPDIR }}/sshd" __sshd_runtime_directory: "{{ ansible_facts.env.TMPDIR }}/run"
Decided to split test backup / restore from main commit and some commit message fixes. Also changed test as testing with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! Looks good. I just reran the centos CI.
The centos 8 fails reproducibly in your new test for some reason. Can you have a look for the reason? I see it fails on |
Please change the title to |
ping - can this be rebased? |
Enhancement:
Use
quote
always when usingcommand
plugin,shell
plugin, validate content as command to execute or system to configure.Reject bad content for
systemd.unit
andsysctl
config.Reason:
This improves security and robustness. At least TMPDIR can be defined outside in various ways.
This follows example in
tests/tests_all_options.yml
wherepkg_mgr
is quoted.When using
command
plugin, it could be possible to useargv
functionality and avoid quoting.Initial reason was single quotes in
'{{ sshd_test_hostkey.path }}/rsa_key'
intasks/install.yml
but not intasks/install_config.yml
andtasks/install_namespace.yml
.Result:
Included test passes. Care should be taken if test fails. It might leave
BADFLAG
user or related files behind.Issue Tracker Tickets (Jira or BZ if any): -