Skip to content
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

Enhancement request: OAuth with Github to scan repos for Access Keys #10

Closed
mikeatlas opened this issue Sep 2, 2015 · 14 comments
Closed

Comments

@mikeatlas
Copy link

This is even something I'd consider building myself / adding to the project. Even secure keys on AWS can be insecure and exposed on a public github repo (even in deleted commit histories). Any interest?

@mikeatlas
Copy link
Author

There's also the potential to actively scan https://api.github.com/events while running (or as part of a premium service) for leaked keys.

@matthewdfuller
Copy link
Contributor

This is a really awesome idea. I'm trying to think through some logistics, but I imagine by using OAuth, we could just scan the user's public repos (or even private for a less severe warning) for known keys from their accounts. Hitting /events may be a bit resource intensive (although I have seen scripts out there that do something similar).

@mikeatlas
Copy link
Author

It's actually real-world, not pointing fingers but I've indirectly been bit by this problem twice now (users pushing their .bashrc or .zshrc profiles and config settings to their public repos).

@mikeatlas
Copy link
Author

Well, even hitting private repos (organizations can have 100s of repos, 1000s of files, 1000s of commits, plus 100s of users with public non-org repos multiplied by N commits...) with all git history commits to scan.... it's definitely intensive even at a small scale.

@mikeatlas
Copy link
Author

@matthewdfuller
Copy link
Contributor

Agreed, it's well beyond the scale of the existing scans, so I'm going to have to think on this one in order to fit it into the setup of the existing plugins. Perhaps GitHub offers a search API which could be hit directly on behalf of a user and include history, deleted files, etc. There was a hacker news thread once on GitHub searches for locating all sorts of things (SSH keys, AWS access keys, etc.). Will try to find it.

@mikeatlas
Copy link
Author

I recall that HN posting as well but can't find that repo quickly either. https://github.com/michenriksen/gitrob maybe?

@mikeatlas
Copy link
Author

yeah I think this is it it... gluing these two projects together would be magical - the output of potential sensitive keys from cloudsploit-scan is compared with output of gitrob scan.

@mikeatlas
Copy link
Author

Played around with gitrob internally. It's a nice tool but the author has not accepted PRs or bugfixes in nearly 7-8 months. Consider abandonware, I'd recommend you fork and salvage useful bits for iterating Github repos and source code and ditch the rest rather than try to integrate. It comes with a large singleton (for the most part) class that could be picked apart without a lot of struggles.

Gitrob also flags a lot of odd false-positives, combining this code with CloudSploit might really want to focus on using the iteration + oauth features from gitrob and narrow them down to look for AWS-specific matches.

@mikeatlas
Copy link
Author

I also wrapped it in a Dockerized container if you want to try it out with potentially less setup:

https://github.com/weftio/weft-gitrob

@matthewdfuller
Copy link
Contributor

Thanks for locating these projects, they'll be useful in doing something similar here. I took a look at we could do a combination of Oauth and GitHub search: https://developer.github.com/v3/search/

The only issue is, it's rate limited to 30 searches per minute, so accounts with large numbers of keys may take awhile to complete.

Also, AWS does not allow you to retrieve the secrets, so we may wind up with a lot of false positives (user hard-coded the access key, but not the secret).

@mikeatlas
Copy link
Author

Well, general good practice policiies are that all keys (including access keys) are considered secrets and belong in the .env file that that file is in .gitignore always, and they're kept out of source code.

I wonder... with the IAM SDK, could you just use these two:

http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/Types/ListUsersRequest.html combined with
http://docs.aws.amazon.com/sdkforruby/api/Aws/IAM/Client.html#list_access_keys-instance_method

Wouldn't matter if the secret keys were in github or not, but usually they're either both there, or neither of them are there.

@tleyden
Copy link

tleyden commented Jul 27, 2017

I've been working on a project called keynuker that is really similar to what @mikeatlas described. It uses the github events API and pretty much the exact AWS SDK calls described.

@mikeatlas
Copy link
Author

Revivalist @tleyden takes a post from 2yr ago and turns it into a project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants