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

fix(NSS): Fix should_pre_check logic to identify sshd #419

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

denisonbarbosa
Copy link
Member

@denisonbarbosa denisonbarbosa commented Jul 5, 2024

The cmdline returned by calling proc.cmdline() has multiple strings that consist of the entire command, which means that, instead of having something like this: ["cmd", "arg1", "arg2, ..., "argn"] It looks like this: ["cmd arg1 arg2 ... argn"]

In order to better limit the options, as this precheck can be a security breach, we only allow the precheck if it comes from the common known sshd binary.

UDENG-3415

The cmdline returned by calling proc.cmdline() has multiple strings that
consist of the entire command, which means that, instead of having
something like this: ["cmd", "arg1", "arg2, ..., "argn"]
It looks like this: ["cmd arg1 arg2 ... argn"]

In order to better limit the options, as this precheck can be a security
breach, we only allow the precheck if it comes from the common known
sshd binary.
Copy link
Collaborator

@3v1n0 3v1n0 left a comment

Choose a reason for hiding this comment

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

LGTM, as discussed.

Mentioning it publicly too, for the record, I think we should also check for the current process PID (and not only on parent), to make this to work when nss is loaded directly by sshd (as it happens when you launch sshd not as a daemon), but it's likely just for debugging purposes for now.

However, note that will need it, when we will have an integration test that will launch sshd in a custom port and we'll try to login there...

So leaving it here as a remember us note for the future.

@denisonbarbosa
Copy link
Member Author

LGTM, as discussed.

Mentioning it publicly too, for the record, I think we should also check for the current process, to make this to work when nss is loaded directly by sshd (as it happens when you launch sshd not as a daemon), but it's likely just for debugging purposes for now.

However, note that will need it, when we will have an integration test that will launch sshd in a custom port and we'll try to login there...

So leaving it here as a remember us note for the future.

When the time comes for that, we can add the check for the current process locked under the integration-tests feature so that it doesn't go through to production, but it's not needed for now.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.47%. Comparing base (58191a2) to head (b727293).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
- Coverage   84.47%   84.47%   -0.01%     
==========================================
  Files          77       77              
  Lines        6713     6711       -2     
  Branches       75       75              
==========================================
- Hits         5671     5669       -2     
  Misses        730      730              
  Partials      312      312              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@denisonbarbosa denisonbarbosa marked this pull request as ready for review July 5, 2024 11:29
@denisonbarbosa denisonbarbosa requested a review from a team as a code owner July 5, 2024 11:29
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Phew! It wasn't a big conceptual issue afterall :)

@denisonbarbosa denisonbarbosa merged commit 3ee9245 into main Jul 5, 2024
6 checks passed
@denisonbarbosa denisonbarbosa deleted the fix-precheck-logic branch July 5, 2024 12:26
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

Successfully merging this pull request may close these issues.

None yet

4 participants