Skip to content
🔐💥 KeyNuker - nuke AWS keys accidentally leaked to Github
Go Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd
docs
keynuker-go-common
scripts
testdata
.gitignore
LICENSE
README.adoc
aws_key_scanner.go
aws_key_scanner_test.go
bindata.go
end_to_end_integration_test.go
fetch_aws_keys.go
fetch_aws_keys_test.go
generate.sh
gh_common.go
gh_event_checkpoint.go
gh_leaked_key_event.go
gh_user_event_fetcher.go
gh_user_event_fetcher_test.go Add TestScanContentForCommits() (#42) Nov 5, 2017
github_event_stack.go
github_user_aggregator.go
github_user_aggregator_test.go
github_user_event_fetcher_mock.go
github_user_events_scanner.go Feature/memory efficiency (#41) Nov 5, 2017
github_user_events_scanner_test.go Feature/memory efficiency (#41) Nov 5, 2017
iamiface_i_a_m_a_p_i_mock_test.go
install.py
lookup_github_users_aws_keys.go Point to tleyden/couchdb fork of tleyden/couchdb to workaround go-kiv… Mar 5, 2018
lookup_github_users_aws_keys_test.go
mock_mailgun.go
nuke_leaked_aws_keys.go
nuke_leaked_aws_keys_test.go
openwhisk_status.go
openwhisk_status_test.go
package-lock.json
package.json
post_nuke_notifier.go Featue/implement checkpoints (#20) Oct 8, 2017
post_nuke_notifier_test.go
serverless.yml
utils_testing.go
write_doc.go
write_doc_test.go

README.adoc

reddit%2Faws%20upvotes 49 ff69b4 license Apache%202 blue

If you accidentally leak your AWS keys on GitHub, it won’t be long before attackers scrape this information and hijack your account for nefarious purposes.

KeyNuker scans public activity across all Github users in your Github organization(s) and proactively deletes any AWS keys that are accidentally leaked. It gets the list of AWS keys to scan by directly connecting to the AWS API.

🚁 System Overview

  • Polling loop to monitor all AWS keys for users of the AWS account

  • Polling loop to monitor Github activity of all users in your github organization(s)

  • Reactively nuke any AWS keys detected to have leaked to Github via the AWS API

Architecture

System Interaction w/ Timeline

Data Flow

🛠 Installing KeyNuker 🔐💥

KeyNuker is packaged as a series of Apache OpenWhisk actions, and can run anywhere that OpenWhisk can run.

Get the code:

$ go get -u -v -t github.com/tleyden/keynuker

Follow the steps in the Installation Instructions to setup OpenWhisk and set the required environment variables, and then run the installation script.

$ cd $GOPATH/src/github.com/tleyden/keynuker/
$ python install.py

After the installation script completes, you will have several OpenWhisk actions:

$ wsk action list
/yourusername_dev/github-user-events-scanner-nuker                     private sequence
/yourusername_dev/fetch-aws-keys-write-doc                             private sequence
etc ...

Features

  1. Never has access to AWS Secret Access Keys, only to AWS Access Key IDs.

  2. Noise-free because it scans actual AWS keys rather than taking a pattern matching approach that produces false positives

  3. Takes actions rather than sending alerts, since depending on people to respond to alerts might introduce a costly delay in reaction time

  4. Covers all public github activity of users in your github org(s), since they might leak AWS keys on their personal repos or even 3rd party repos

  5. Requires minimal IAM Permissions: iam:DeleteAccessKey, iam:ListAccessKeys, iam:ListUsers

  6. Ultra-low baseline running cost due to serverless architecture

  7. Lowest common denominator and requires zero effort or workflow change for users

⚪️ Roadmap / Goals

  1. Low-latency round trip between AWS keys leaking and being nuked. Currently uses polling approach, but the goal is to layer a webhook approach on top in order to lower the latency.

  2. Scale up to monitoring hundreds of AWS accounts and thousands of github organizations/repos/users.

  3. Cove as much of the Github API surface area as possible (gists, issue comments, etc)

  4. Pluggable architecture so that other cloud key providers (Google Cloud Platform, Azure, etc) and other leak sources (BitBucket, Jira, etc) can be added later.

🏁 Project status: Early alpha stage

The basic end-to-end functionality is working, except for notifications, but there are still a lot of places where AWS keys can leak to Github and go undetected:

  • Github Gists

  • Other Github API surface area that isn’t covered yet

📓 Documentation

Table 1. Documentation
Doc Link

README (this document)

README

Installation guide

Installation Instructions

Post-installation verification

Verify Installation

Developer guide

Developer guide

AWS Security Resources

AWS Security Resources

  • Git Secrets — Prevents you from committing secrets and credentials into git repositories

  • Git Hound —  Git plugin that helps prevent sensitive data from being committed into a repository by sniffing potential commits against PCRE regular expressions.

  • GitRob — Reconnaissance tool for GitHub organizations

  • pre-commit - A pre-commit framework, that includes the detect-aws-credentials plugin

  • TruffleHog — A tool that Searches Entire Commit History in Git Repositories for High Entropy Strings to Find Secrets Accidentally Committed to Version Control

  • BFG Repo cleaner - Removes large or troublesome blobs like git-filter-branch does

  • AWS_RISK_CREDENTIALS_EXPOSED CloudWatch Event

🔒 Security At Depth

Taking a security-at-depth approach, in addition to running KeyNuker you should also consider the following precautions:

  • Limit ec2 actions to only the regions that you use, eg ("StringEquals": {"ec2:Region": "us-east-1"})

  • Limit ec2 actions to only the instance types that you use, eg ("StringLikeIfExists": {"ec2:InstanceType": ["t1.*"]})

  • Use temporary AWS keys that require MFA

  • Minimize chance of AWS keys from ever leaking in the first place using tools such as Git Secrets which can be configured as a pre-commit hook.

You can’t perform that action at this time.