-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Python: Promote py/pam-auth-bypass
#9108
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0c53444
Python: Format .qhelp file
RasmusWL c84f693
Python: Adjust PamAuthorization examples
RasmusWL 7e87e18
Python: Adjust name/description/select of `PamAuthorization.ql`
RasmusWL f68b281
Python: Add change-note
RasmusWL c890f9c
Python: Fix change-note
RasmusWL 0956d50
Python: Actually promote `py/pam-auth-bypass`
RasmusWL 044829c
Python: Add `@security-severity` to `py/pam-auth-bypass`
RasmusWL b54de13
Python: Apply suggestions from code review
RasmusWL 6611e5b
Merge branch 'main' into promote-pam
RasmusWL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| libpam = CDLL(find_library("pam")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's... Quite the formatting. 😮 |
||
|
|
||
| pam_authenticate = libpam.pam_authenticate | ||
| pam_authenticate.restype = c_int | ||
| pam_authenticate.argtypes = [PamHandle, c_int] | ||
|
|
||
| def authenticate(username, password, service='login'): | ||
| def my_conv(n_messages, messages, p_response, app_data): | ||
| """ | ||
| Simple conversation function that responds to any prompt where the echo is off with the supplied password | ||
| """ | ||
| ... | ||
|
|
||
| handle = PamHandle() | ||
| conv = PamConv(my_conv, 0) | ||
| retval = pam_start(service, username, byref(conv), byref(handle)) | ||
|
|
||
| retval = pam_authenticate(handle, 0) | ||
| return retval == 0 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| libpam = CDLL(find_library("pam")) | ||
|
|
||
| pam_authenticate = libpam.pam_authenticate | ||
| pam_authenticate.restype = c_int | ||
| pam_authenticate.argtypes = [PamHandle, c_int] | ||
|
|
||
| pam_acct_mgmt = libpam.pam_acct_mgmt | ||
| pam_acct_mgmt.restype = c_int | ||
| pam_acct_mgmt.argtypes = [PamHandle, c_int] | ||
|
|
||
| def authenticate(username, password, service='login'): | ||
| def my_conv(n_messages, messages, p_response, app_data): | ||
| """ | ||
| Simple conversation function that responds to any prompt where the echo is off with the supplied password | ||
| """ | ||
| ... | ||
|
|
||
| handle = PamHandle() | ||
| conv = PamConv(my_conv, 0) | ||
| retval = pam_start(service, username, byref(conv), byref(handle)) | ||
|
|
||
| retval = pam_authenticate(handle, 0) | ||
| if retval == 0: | ||
| retval = pam_acct_mgmt(handle, 0) | ||
| return retval == 0 |
4 changes: 4 additions & 0 deletions
4
python/ql/src/change-notes/2022-05-10-promote-pam-authentication-bypass.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: newQuery | ||
| --- | ||
| * The query "PAM authorization bypass due to incorrect usage" (`py/pam-auth-bypass`) has been promoted from experimental to the main query pack. Its results will now appear by default. This query was originally [submitted as an experimental query by @porcupineyhairs](https://github.com/github/codeql/pull/8595). |
13 changes: 0 additions & 13 deletions
13
python/ql/src/experimental/Security/CWE-285/PamAuthorizationBad.py
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
python/ql/src/experimental/Security/CWE-285/PamAuthorizationGood.py
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
python/ql/test/experimental/query-tests/Security/CWE-285/PamAuthorization.expected
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
python/ql/test/experimental/query-tests/Security/CWE-285/PamAuthorization.qlref
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
python/ql/test/query-tests/Security/CWE-285-PamAuthorization/PamAuthorization.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| | pam_test.py:48:18:48:44 | ControlFlowNode for pam_authenticate() | This PAM authentication call may lead to an authorization bypass, since 'pam_acct_mgmt' is not called afterwards. | |
1 change: 1 addition & 0 deletions
1
python/ql/test/query-tests/Security/CWE-285-PamAuthorization/PamAuthorization.qlref
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Security/CWE-285/PamAuthorization.ql |
File renamed without changes.
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.
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.
I'm not allowed to add a comment in the appropriate place, but there's a use of
API::moduleImport("ctypes.util")on line 20 above that will need fixing.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.
indeed, that probably what the merge conflict is also about 👍