by danielodievich · 4y ago · 0 comments
I felt like a bit of a dope but it was neat to have it happen to me. Lesson learned for sure.
https://docs.github.com/en/code-security/secret-scanning/sec...
Moral of the story: make your keys regexable without likelihood of false positives!
We should have our systems and precommit hooks then alert us when those enter places they shouldn't and help us automate rotation.
Bonus: adding SRVCE_PRVT_{KEY} and SRVCE_PUB_{KEY}.
Also the “you” below is the generic you - not you personally.
Disclaimer: I work at AWS in Professional Services, all rants are my own.
Now with that out of the way, I hate the fact that there are way too many code samples floating around on the internet that have you explicitly put your access key and secret key in the initialization code for the AWS SDK.
s3 = boto3.resource(‘s3’,aws_accesskey_id=ccxx,aws_secret_access_key_id=cccc)
Even if you put the access keys in a separate config file in your repo, this is wrong, unnecessary, and can easily lead to checking credentials in.When all they have to do is
s3=boto3.resource(‘s3’)
All of the SDKs will automatically find your credentials locally in your .config file that is in your home directory when you run “aws configure”.
But really, you shouldn’t do that, you should use temporary access keys.
When you do get ready to run on AWS, the SDK will automatically get the credentials from the attached role.
Even when I’m integrating AWS with Azure DevOps, Microsoft provides a separate secure store that you can attach to your pipeline for your AWS credentials.
https://docs.github.com/en/enterprise-cloud@latest/code-secu...
https://docs.github.com/en/developers/overview/secret-scanni...
Your dev team would probably be able to give that a glance and estimate the work.
How long does it take to get the response vs external bots pulling the data? What mechanisms does GitHub have in place to stop bots who monitor repo changes? I ask, as I have been there and it is super scary how fast someone/bot pulls repo data changes, as in minutes, and the repo we had back then was not popular.
https://github.com/search?o=desc&q=secret&s=updated&type=Rep...
Mind you, your secrets need to have a distinctive format in order for this to work. Probably a distinctive prefix is enough.
An Unethical Life Pro-Tip (that the word is already out on anyway, so I don't feel too bad):
• The content of Github public repos is all continuously loaded (by Github themselves) as a public dataset into BigQuery — https://console.cloud.google.com/marketplace/details/github/....
• For about $500, you can use BigQuery to extract all matches of a particular regexp, from every file, in every commit, in every public Github repo.
Whether or not Github themselves use this to power their secret scanning, arbitrary third parties (benevolent or not) certainly can use it for such. And likely already do.
https://github.blog/changelog/2018-08-01-new-delay-public-ev...
Disclosure: I'm an ex-GitHub employee but was not involved in the secret scanning API.
Mind you, the Github dataset isn't the leak itself; the leak is the public repo that the user pushed their key to. The dataset just makes such searches scalable / cost-effective to third parties who aren't already indexing Github for some other reason.
Also I'd hope that Google is scanning BigQuery queries for that abuse signal.
It was taking too long to get a new temp demo license key and GitHub search with clever filters helped me track down a demo key that was recently uploaded to a test repo.
This is also why I use git-secrets in my repos.