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

sshd.config.params does not correctly parse the config file #1053

Closed
mbainter opened this issue Jan 19, 2024 · 1 comment
Closed

sshd.config.params does not correctly parse the config file #1053

mbainter opened this issue Jan 19, 2024 · 1 comment

Comments

@mbainter
Copy link

mbainter commented Jan 19, 2024

Describe the bug

You can have directives that apply contextually in the sshd config. The way cnspec parses this file can result in false positives or false negatives.

To Reproduce
Steps to reproduce the behavior:

  1. In the sshd_config file comment out the PermitRootLogin line
  2. At the end of the file add this:
    Match Group games
    PermitRootLogin no
  3. run cnspec shell, and query with: sshd.config.params[PermitRootLogin]
  4. Observe the output being:
    sshd.config.params[PermitRootLogin]: "no"

Expected behavior
It should report the configuration as empty, or better yet - the default of prohibit-password, like you'd get from sshd -T:

$ sudo sshd -f /etc/ssh/sshd_config -T | grep -i PermitRootLogin
permitrootlogin without-password

Another problem here is that if you uncomment the main configuration option you get this:

cnspec> sshd.config.params["PermitRootLogin"]
sshd.config.params[PermitRootLogin]: "no,no"

So if you have a test for =="no" like linux-security does, then it fails even though it should pass.

Desktop (please complete the following information):

  • OS: Linux/PopOS
  • OS Version: 22.x
@arlimus
Copy link
Member

arlimus commented Feb 2, 2024

Closing this in favor of the other issue you opened @mbainter in mondoohq/cnspec-policies#340

The changes will be done to providers in the cnquery repo and to the policy in the cnspec-policies repo, which is why I thought the above issue nails it :D

@arlimus arlimus closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants