Github insufficient permissions
Please make sure that you have checked the boxes:
- [x] Review the Quickstart guide
- [x] Search for both open and closed issues regarding the problem you are experiencing
- [x] For permissions issues (Access Denied and credential related errors), please refer to the requisite docs before submitting an issue: AWS, GCP, OpenStack, GitHub
Description of issue:
I am running security monkey to audit my github organization. I created the OAauth token as described here: https://github.com/Netflix/security_monkey/blob/develop/docs/github_setup.md
Additionally, I added the user to a team that has been given read only permissions on all repos in the organization. However, for multiple endpoint calls including the call to retrieve the repo's deploy keys, we receive an error. Do we need to enable additional permissions?
Hello @ldm810 !
Can you provide additional details on the error message you are seeing?
- Are you only seeing this on specific repositories or all repositories within the same organization?
- Is it only encountering errors on the deploy key APIs?
To verify that your token has the proper permissions, run the following cURL command:
curl -X GET \
https://api.github.com/repos/YOURORG/YOURREPO/keys \
-H 'Authorization: Bearer YOURTOKENHERE'
@mikegrima thanks for your response!
For background: the user I am using is on a team with read permissions on all repos in the organization. I created personal access token for another account that has more than read permissions on each repo and this api endpoint worked.
In response to your questions
- Are you only seeing this on specific repositories or all repositories within the same organization? This occurs for more than one repo in the organization
- Is it only encountering errors on the deploy key APIs? It works for other api endpoints
I get the following error when I try that endpoint:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/repos/keys/#list-deploy-keys"
}
It makes sense that I am unable to retrieve the deploy keys because from the UI, you cannot access the Settings tab (where the deploy keys are configured) if you have Read Only Permissions
I get the following error when I try that endpoint:
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/repos/keys/#list-deploy-keys"
}
Hello @ldm810 .
It looks like GitHub's documentation is not very clear here. https://help.github.com/articles/repository-permission-levels-for-an-organization/
You may need to have Admin permissions on the repo to perform the action. Once you have admin, then you can scope it down via the personal access token scopes.
Try to run that cURL command with an administrative user's token with the scopes defined here: https://github.com/Netflix/security_monkey/issues/github_setup.md#access-keys-and-permissions.
Let me know if that works.
Hi @mikegrima! I tried that with an administrative user's token and it works.
We would love to run this with just a read only account but it seems like this is a limitation on GitHub's end.
Seems like a more granular permission model is on the horizon: https://developer.github.com/early-access/platform-roadmap/
Yeah, unfortunately, this is a GitHub limitation.
GitHub currently looks at permissions on repos in two categories:
- Code Level
- Management Level
Read/Write are code level, whereas Admin and Owner are both code and management level.
We should definitely modify the docs to be a bit clearer here: https://github.com/Netflix/security_monkey/blob/develop/docs/github_setup.md
For example, instead of: An organization member that has the permissions to access the organization resources (member could be in a team with access to all repos)., it needs to be:
An organization member that has
Adminprivileges on all repositories within the organization, or anOwnerof the organization. Please note: these are powerful permissions, so please keep this account locked down.
Docs updated.