CPP: PAM Authorization Bypass#8775
Merged
Conversation
This PR is similar to my other PRs for [Python](#8595) and [Golang](github/codeql-go#709). This PR aims to detect instances were an initiated PAM Transaction invokes the `pam_authenticate` method but does not invoke a call to the pam_acct_mgmt` method. This is bad as a call to `pam_authenticate` only verifies the users credentials. It does not check if the user account is still is a valid state. If only a call to `pam_authenticate` is used to verify the user, a user with an expired account password would still be able to login. This can be prevented by calling the `pam_acct_mgmt` function after a `pam_authenticate` function.
geoffw0
reviewed
Apr 19, 2022
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
This query looks great. I appreciate the effort you've gone to providing tests, documentation and example code to support it.
A couple of real-world results: https://lgtm.com/query/6091759195696304116/
cpp/ql/src/experimental/Security/CWE/CWE-285/PamAuthorization.ql
Outdated
Show resolved
Hide resolved
2 tasks
geoffw0
reviewed
Apr 19, 2022
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
The failing checks are trivial - you need to correct the file names in the .qhelp and run the auto-formatter on the .ql file (let me know if you don't know how to do that).
cpp/ql/src/experimental/Security/CWE/CWE-285/PamAuthorization.qhelp
Outdated
Show resolved
Hide resolved
cpp/ql/src/experimental/Security/CWE/CWE-285/PamAuthorization.qhelp
Outdated
Show resolved
Hide resolved
Author
|
@geoffw0 Changes done! |
Contributor
|
Looks like this should've been merged. |
Contributor
|
Thanks again for the contribution! |
Author
|
@geoffw0 Thanks for the quick turnaround. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is similar to my other PRs for
Python and
Golang.
This PR aims to detect instances were an initiated PAM Transaction invokes the
pam_authenticatemethod but does not call thepam_acct_mgmtmethod. This is bad as a call topam_authenticateonly verifies the users credentials. It does not check if the user account is still is a valid state.If only a call to
pam_authenticateis used to verify the user, a user with an expired account password would still be able to login. This can be prevented by calling thepam_acct_mgmtfunction after apam_authenticatefunction.