Github Analyzer
Audits a GitHub organization for potential security issues. The tool is currently in pre-alpha stage and only supports limited functionality, however we will be actively adding checks in the upcoming months, and welcome feature requests or contributions! Once the analysis is complete, a static HTML with the summary of the results is rendered in localhost:3000 as shown below:
Available Checks
Name | Category | Severity | Resource Affected |
---|---|---|---|
Application restrictions disabled | Least Privilege | High | Organization |
Insecure Webhook payload URL | Information Disclosure | High | Webhook |
Advanced security disabled for new repositories | Tooling and Automation Configuration | Medium | Organization |
Secret scanning disabled for new repositories | Tooling and Automation Configuration | Medium | Organization |
Organization 2FA disabled | Authentication | Medium | Organization |
Users without 2FA configured | Authentication | Low | User Account |
Permissions overview for users | Least Privilege | Informational | User Account |
OAuth application summary | Least Privilege | Informational | Organization |
Sample Output
For each issue identified, a JSON with associated information will be generated. A sample output snippet is as follows:
...
{
"id": "CONFIG_AS_1",
"name": "Secret scanning disabled for new repositories",
"severity": 3,
"category": "Information disclosure to untrusted parties",
"tags": [
"GitHub Advanced Security feature"
],
"description": "Secret scanning disabled for org testorg",
"resource": [
{
"id": "testorg",
"kind": "Organization"
}
],
"cwes": [
319
],
"remediation": "Pleasee see https://docs.github.com/en/[email protected]/code-security/secret-scanning/configuring-secret-scanning-for-your-repositories for how to enable secret scanning in your repositories"
},
{
"id": "AUTH_2FA_2",
"name": "Users without 2FA configured",
"severity": 2,
"category": "Authentication",
"description": "The following collaborators have not enabled 2FA: testuser1, testuser2",
"resource": [
{
"id": "testuser1",
"kind": "UserAccount"
},
{
"id": "testuser2",
"kind": "UserAccount"
}
],
"cwes": [
308
],
"remediation": "Please see https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication for steps on how to configure 2FA for individual accounts"
}
...
How to run
You can see available options via the --help
flag.
Running locally
- Install with:
go install -v github.com/crashappsec/github-analyzer/cmd/[email protected]
- Run with:
$GOPATH/bin/github-analyzer \ --organization <your org name> \ --token "$GH_SECURITY_AUDITOR_TOKEN"
Running using Docker
-
After cloning the repo, build the container using:
docker compose build --no-cache
-
Run
docker compose run \ --rm --service-ports \ github-analyzer \ --organization <your org name> \ --output output \ --token "$GH_SECURITY_AUDITOR_TOKEN"
Permissions
For API-based based checks, you need to pass in GitHub Token (either personal access token (PAT) or token derived from GitHub app installation) with the appropriate permissions. Example usage:
github-analyzer \
--organization <your org name> \
--token "$GH_SECURITY_AUDITOR_TOKEN"
See our wiki for instructions on setting up a token to be used with the github-analyzer.
For experimental scraping-based checks, you need to pass in your username and password, as well your two factor authentication one-time-password, as needed. Example usage:
github-analyzer \
--organization crashappsec \
--token "$GH_SECURITY_AUDITOR_TOKEN" \
--userPermissionStats \
--enableScraping \
--username "$GH_SECURITY_AUDITOR_USERNAME" \
--password "$GH_SECURITY_AUDITOR_PASSWORD" \
--otpSeed "$GH_SECURITY_AUDITOR_OTP_SEED"
See our wiki for instructions on setting up a token to be used with the analyzer.
Credits
Project was originally ported from Mike de Libero's auditor with the author's permission.
[Question] Complete list of checks
Hi Is there a complete list of checks for organizations, repos, members, actions, runners, etc? I see there's a table in the README, but I think these are high level checks and there are sub-checks for those?
Thanks!
error if token does not have permissions
if token does not have permissions cli blows up with:
oauth permissions prototype (related to #19)
This PR adds scraping support and should be addressing #19 once complete however need to work out the OTP bits still.
probably a yubikey config/wrapper issue or need google otp? need to investigate
Filed https://github.com/google/go-github/issues/2483 to ask about the OTP issue
Added sample webhook auditor
This commit addresses #23 but does not actively check the SSL verification and headers using the ping URL. I've set up a test org for that github-security-auditor-test-org so @miki725 we could set up some tests using it and add the rest of the functionality. Moreover adds resource identifiers so that we can create fingerprints for each issue / affected resource and allow users to mark things as false positives in their local repos
Added zap logger and basic pkg restructure (fixes #5)
This PR is the first in a sequence of PRs to add functionality to the github security auditor, and only does basic restructuring of packages, splitting command line flags from and github package logic and adding zap for logging. More over, introduces an
issues
package for tracking security issues and statistics as return values of audits. State is overall wip still, so leaving this as a checkpoint / FYI primarilyThere are various TODOs which will be addressed in subsequent PRs such as:
Audit
interface for the different entities (e.g., org/pkg/repo)CI for tests/releases
this PR:
version.txt
so that CI automatically populates it both for binary distributions as well as viagoreleaser
Dockerfile
to create smallest possible image just based on alpine+binaryHandle null responses in case of TPS throttling
This PR does not pass a global backoff to all clients doing pagination but tries to have them run independently as much as possible and also handles a missed case where github's response could be nil after TPS errors
updated Readme and added permission checks (fixes #19)
Created a wrapper over go-github's scraper module, modifying some of the internals, and also pulled in the recommended changes from @miki725 which had been left out from https://github.com/crashappsec/github-security-auditor/issues/19.
This should now be successfully pulling oauth information if one follows the steps outlined in the Readme
adding pre-commit config
partially fixes https://github.com/crashappsec/github-security-auditor/issues/8, just the lint bits
as this will be open-source using more standard pre-commit flows rather than relying on docker for everything
some cleanups
Addressing some of the nits/asks of previous PRs and refactoring some of the pagination code. Will probably need to use interfaces for pagination as generics don't allow access to nested types
Parity with original repo
Added the rest of the functionality of the original repo. This is still untouched code for the most part, and will be refactoring to add a generic handler for pagination w/ backoff across all clients, as well as a passing context with cancel as needed.
Will also need to change error handling and add tests, then we will be in a good place to start adding functionality
Check dependabot settings in forked repos
As per https://github.blog/changelog/2022-11-07-dependabot-pull-requests-off-by-default-for-forks/, dependabot PRs will be off by default for forked repositories, enable a warn-level in case this is not explicitly enabled
allow to output report json to stdout
currently it goes to
--output
directory however in some cases it might be easier to go to stdout or specific file to enable flows like:Add support for text and HTML reports - without webserver
Thank you for creating this tool.
I would like to run the analyzer, and upon completion, have a text and/or html report of the findings. I do not want the webserver running as I'd like to run this as a GitHub Action. Upon writing the report, the analyzer should exit(0).
Check pat policy settings for org
Check https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization settings
Check commits from personal emails
Often users commit into an enterprise repo but their git is locally configured with their personal email. We could check for last commits of users in the org and verify they are using an enterprise email account. This would allow tighter control of contributors if such policy is a thing that would be of interest to the org