GitHub commit search: “remove password”
github.com
github.com
If you leak a password to any public location, there is only one reasonable course of action: CHANGE IT!
Don't even bother rewriting the commit. Focus on changing that password right away, and while you're at it, figure out a better way to manage your secrets outside of your source code in the future. Mistakes happen, but they shouldn't be repeated.
If you leaked the password in the git repository, change it as @jvehent just commented.
The Azure Key Vault is a good solution that so far seems easy to work with (I've only just started using it though) and it can make the storage of secrets easier to secure but you still have the issue of storing the credentials to the key vault, so its difficult to fully get rid of the problem although you can definitely isolate access to your passwords that way and then have a more limited number of credentials to secure.
An AAD Application can act on behalf of a logged-in user (using OAuth2 or openid) with the correct delegated permissions. This means you can grant key/secret/certificate CRUD privileges to an AAD user or group, and then use OAuth to obtain a token granting access to the KeyVault resource. All activity is performed by the client (read: application) on behalf of the user (read: human) against the resource (read: key) without having to store any secrets at all.
I use the keyvault pretty extensively, and have really grown to like it.
I'm drafting a writeup and will post it to HN when that's ready. Other secrets managers I've seen posted to HN seem far too overcomplicated, at least for our company's needs. This is a step up from reading secrets from a plain text file, but not so complicated that you need a separate docker image running a service dealing out passwords to your webapps or similar.
EDIT: rationale for use, as requested:
Using this approach, you can better manage your secrets since you can actually commit the passwords file in your code base, and the API lends itself to easily switching between dev and production ids/secrets. You can track revisions to the secrets file, rolling back your commits rolls back the secrets as well. You can also include the deployment of secrets in your deployment script - typically, the encryption key for your vault is only generated and distributed to the production servers once, while secrets may be added, changed, and removed continuously during the development and product lifecycles.
Using a simple secrets manager like NeoSmart's SecureStore lets you embrace the benefits of deployment automation, revision control, and more, without sacrificing safety and security in the name of productivity or ease-of-use.
EDIT2: what the heck, just took 10 minutes off to write it up and publish it: https://news.ycombinator.com/item?id=13654005
I just did, though I may have gone overboard as it is more of a paragraph than a sentence. We developed SecureStore out of necessity, believe me, KISS all the way.
Your proposed solution, however, has its own share of problems for some deployment scenarios. Where do you get this file from? Assuming you are meant to place it by hand each time you deploy your application... what about autoscaling? What if you want unattended deployment of apps?
Deciding where to store your secrets is extra easy if you're in the cloud. In AWS you can use KMS to store it if it's 4kb or less. A cli command or API call can decrypt it for you. If it's larger, you can use a tool such as credstash which lets KMS manage the keys.
If you're in an environment that's using Chef, it can handle them. Ansible has a solution as well.
Or you can use something like Hashicorp Vault, though it requires setting up servers for that purpose.
Once you've decided on one of these tools, it's no problem to script the retrieval of a secret into your deployment mechanism. It will work fine for autoscaling or any other unattended deployment.
SecureStore is designed to be repo-friendly, it purposely avoids needless IV/payload regeneration, is based in plain text, and preserves element order to avoid driving source code managers crazy.
If your needs are more sophisticated this means keyservers where hardware security module (HSM) might by part of the equation.
The first thing you should be doing is making the password useless by changing it. Doing anything else is entirely irresponsible. Sure, remove the file in question after that... but you can't treat the old password as anything other than public knowledge at that point.
I would assume that the parameters sent to the webhook, an auth token or something of the sort would take care of the security bit. Obscuring the URL seems like security-by-obscurity no?
The real lesson is - don't put passwords in your code.
It's like someone responding to the suggestion to "use strong/unique passwords" with "but what if I don't have any authentication?"
Stuff happens, especially under pressure. But yeah, if that happens to you, there is no more reasonable course of action than changing it right away.
https://github.com/squared-one/omniauth-unsplash/commit/072b...
"... It's not really removing any password, is it? But hey, why not use the momentum ... wheeeeeeeeeeeeeeeeee!"
- protected $password = '12root34';
+ protected $password = '';
"I'm a bit disappointed now that putting 'protected' in front of the password doesn't protect it ;)" - acceptHandshake = params.pass == PASSWORD
+ acceptHandshake = true//params.pass == PASSWORDThere are just so many of those it's crazy:
remove .env
YOURFAVORITEAPI_SECRETKEY
YOURFAVORITEAPI_PASSWORD
Also replace "remove" with delete/rm/replace/etc.And replace "YOURFAVORITEAPI" with CircleCI, Travis, Mailchimp, Trello, Stripe, etc, etc.
Also, companies I contacted consider it the customer fault and basically don't care.
The interesting thing is that there is also an evil crawler that will automatically launch thousands of windows vms to mine bitcoins (that's all they do). Amazon told us that we have leaked our account id and secret but also they notice the other crawler has launched a lot of VMs and they did a refund to us. yes, we love amazon.
Lesson learned: you never put the account id and secret in your code, not only that you should not hardcode it, but there is no need to even read that from the environment etc.
Don't do something like this `new S3({accountKey: ..., accountSecret: ..}` instead you do `new S3()` and that's it. Every AWS SDKS is smart enough to find the keys in the environment following a series of steps:
- environment variables
- ~/.aws/credentials
- and when your code is run on ec2, lambda, etc. you should use IAM Roles.
So, in addition to not hardcoding an AWS secret, your code should not even pass the secret to the SDK.
Consider also enabling CloudTrail and have alerts on that.
There is also a way to not have ~/.aws/credentials in your machine and have another thing that requires MFA. I am not familiar how this work yet but we started to use it.
Reminds me of the water pipeline in Finding Nemo with the crabs above it.
- a key is made public, and we have to call a user or refund them (for retention purposes)
- a key is made public, and we revoked the key, potentially breaking the customers builds/deploys and potentially knocking a customers stuff out (if, for example, a key is disabled during a push to production).
Does that imply that they are not hashing secret keys, or did you also push the account key (allowing for a single auth test on their side)?
AWS_SECRET_KEY="FOOBAR"
and send a message to the committer's email (since you presumably used a correct/valid email in the git commit).However it should be pretty easy for them to set up a script to search github for this kind of stuff and automatically invalidate keys
If the token is XYZ and the script is searching https://github.com/search?utf8=%E2%9C%93&q=XYZ&type=Commits&...:
1. It's sharing the token with GitHub.
2. It's embedding the token as query-string parameter in a GET request, which is much more likely to be logged (than sending it as data in a POST request), and more likely to be available to less-privileged/less-trusted staff.
3. If the request is sent to a non-HTTPS endpoint, the query can be MITMd, revealing the token.
I'd be very wary of setting up a token-finding script, it feels like it adds more risk than it saves.
Annoyingly there is no way to turn it off even when you explicitly want to share an API key knowingly. But i'm more than fine with needing to "obfuscate" an API key or manage secrets correctly knowing it saves TONS of people.
It probably wasn't the best idea, but it was the only "secret" needed in the whole project and I didn't want to maintain a way of managing secrets in a public project for a pointless key.
In the end I did just that, and looking back it was the better choice, but at the time it was annoying.
I wonder why they'd want to invalidate that. :)
$key = "BAAD" + "F00D" + "CAFE" + "BABE";
2) Search if found keys are actual valid keys
3) Expire key, send explanatory email, issue new key
(I think that's what AWS does)
http://jordan-wright.com/blog/2014/12/30/why-deleting-sensit...
The top HN comment on the article details their experiences with getting hacked this way:
Edit: I had similar objections to "why not rework databases as an immutable diff history?" https://news.ycombinator.com/item?id=13581096
Removing the file, or the password and adding a comment, as well as changing the password where it's used is much less likely to end up with a re-added password later.
Of course, removing the file, adding it to .gitignore and changing the password makes it even harder as a contributor would have to work to add the password back, which is even less likely to happen.
It gets a little scary when it veers from professional security to individual personal privacy https://github.com/search?p=2&q=smtp.gmail.com+pass&ref=sear...
I notice in many instances Github showing an error.
We could not perform this search: Must include at least one user, organization, or repository
But if you change anything in the URL, it works again. Such as adding &p=2, which lucideer tried. But I got the error on his link. So I changed it to p=3, and it worked.
So I'm guessing Github has an autodetection for a particular global code search getting high hits (for something like this, I assume) that locks people out.
Seems more like a band-aid on a broken leg, though.
Writing passwords down on a piece of paper, and keeping that in your wallet or locked desk drawer is actually one of the more secure ways of storing passwords these days.
No risk of electronic compromise, and its highly unlikely that people who would steal your wallet or break into your home are also interested in your online accounts.
1. New guy gets hired.
2.You work for a large corporation and we'll you can't say you can trust everyone there.
3. Small company of 10 (company I work at for example) could be compromised by the weekly janitor.
4. Someone could break in and make it look like a robbery all while stealing your critical infrastructure.
I recently helped research a bit about internal security for our office and sticky notes are still a very common place for credentials to be compromised.
add password / add passwords
* https://github.com/search?utf8=%E2%9C%93&q=add+passwords&typ... * https://github.com/search?utf8=%E2%9C%93&q=add+password&type...
add secret / add secrets
* https://github.com/search?utf8=%E2%9C%93&q=add+secret&type=C... * https://github.com/search?utf8=%E2%9C%93&q=add+secrets&type=...
That people took the trouble to use PGP but then go and do something this silly?
search for code making connections to db
ruby https://github.com/search?q=DBI.connect&ref=searchresults&ty...
java https://github.com/search?p=2&q=DriverManager.getConnection%...
and so on...
That is, for example, if Gmail can ask "it looks like you forgot the attachment" why can't Git say "this is a public repo and you're about to commit and push passwords. Are you sure?"
It's going to be easier to fix the tool than it is to make humans be perfect.
Git would have to first decide whether a file is a textfile or binary file, a decision that can be done reasonably well heuristically but that is undecidable in the general case. Then it has to parse text files for a long, curated list of known keywords that are only used for storing API keys and are not (usually) used in normal code. I'm not sure if that's even feasable.
And then of course git has no concept of "public" and "private" repos, so the entire task can't be handled well by git.
That's all I'm trying to say
We keep expecting a cat to bark, and then we're shocked and disappointed that it doesn't. So let's stop asking and find / build a better tool.
We. Need. A. New. Tool.
p.s. But there are how many CSS pre-processors? And how many JS frameworks? Etc. Things we don't need. Go figure.
It might not catch everything all the time - since humans are pretty creative when it comes to fucking things up - but I bet it would be pretty effective. Certainly more effective than what we have now. Then if it can keep learning going forward, all the better, eh.
In comparison Gmail doesn't catch all cases either, if you say something like "here are" instead of I've attached it misses it.
Passwords, look for variables with the name password, passwd assigned strings.
Like Gmails attachment, it'll get stuff wrong, just make it easy to continue on.
if "PASSWORD=xxx" in text => prompt alert or ask confirm
Next step would be to take this list (search result), make a curated list of 100-1000 unencrypted password (text/line + files + infos of repo), and then hard code some rules to detect +80% of cases.
https://github.com/search?p=2&q=remove+password+oops&ref=sea...
On an internal VCS, this would still be a problem, but a bit less visible/exploitable...
Also, you can hide your crimes and not show off all your "TODO: put more stuff here" commits to the world.
That said I'd say putting secrets in a git repo is a pretty risky thing to do. By the nature of the tool that means that the secret ends up on the device(s) of every developer who checks out the codebase, so the security of the secrets is equal to the security of the worst secured device in question.
Storing and keeping secrets is a pretty risky thing in general. Think: small team, small app, everybody has the secrets anyways for deployment purposes. Sure, setting up vault is superior - but how much effort does that cost that could be invested in a better solution. Or a puppet repo that you use to provision your machines, shared in the ops team: small team, everbody has root - on each machine there might be an ssh key that gives away all your secrets. So better invest in solid FDE and maybe tie that to a TF device, a yubikey that is required to decrypt the disk etc. Not perfect by all means, but there's limited time to go around and you really should think about what threats you want/can defend against. (for example, for most projects, I'm not wasting any thought about defenses against a nation state actor, that's a threat that I won't be able to meaningfully counter anyways).
Unless you got super-corporate lockdown with the end point devices you have risks like "A user with access to the repo. installs software which turns out to be malware", "A user with access to the repo. leaves their laptop in a coffee shop unlocked", "A user with access to the repo. puts it on a USB key and loses the key". None of these are nation state level concerns, they're things that could impact the project purely by accident, or at the hands of low-skill attackers
The point is once you've allowed secrets to be in a distributed system like this you have very little control over what happens to them, which is why I'd recommend using a secrets management system where there's more control (e.g. vault from hashicorp) in almost all circumstances.
You lose your development history, but you ensure you won't get bitten by stuff like this.
https://github.com/search?&q=mysqli_connect+http&type=Code
https://github.com/search?q="rds.amazonaws.com"&type=Code
etc...
I wonder if GitHub blocked those searches "We could not perform this search Must include at least one user, organization, or repository"
Edit: If I click on PHP for the language in the sidebar they show up. But hmm, I wonder if maybe GitHub tries to block leaks like that from being searched.
shrug
(No, I didn't exploit this, I just enjoyed finding them)
http://stackoverflow.com/questions/1139762/ignore-files-that...
The other alternative I can think of is to hide sensitive values in environment variables
So yes, add the file to gitignore and git rm it, but also invalidate your keys and get new ones.
https://github.com/search?utf8=&q=id_rsa&type=Commits&ref=se...
https://github.com/weiss/original-bsd/commit/0e1066151c90a80...
"Add password" finds 792,000 results, of which at least some (on the first page) are actual passwords.
https://news.ycombinator.com/item?id=7411927
By just looking quickly, it seems that you can still find many recent live keys...
https://github.com/wrmsr/dotfiles/commit/a6597efe0421b6b0cc2...
I get it...you like github but you don't want to pay for private repos. That's when you use Gitlab or BitBucket and then this problem goes away.
Reminds me of the eye opening experience available at https://www.exploit-db.com/google-hacking-database/
Already had a couple of sassy individuals telling me my honeypot is shit via the tty logging.
What software are you using?
I use either `git-crypt` [1] or `ansible-vault` [2].
Advantage of this approach is it encrypts the values individually instead of per file. This way the secrets files are git/review friendly.
https://github.com/search?utf8=%E2%9C%93&q=remove+password+u...
Here I was trying to search for "remove password" just on repos for nicksagona (just happened to be one of the first users to display when you go to this thread's search).
That comes up with zero results. This leaves me wondering how I would run similar searches on repos that I'm involved with as a way of auditing to make sure none of them have compromised passwords that would need changed.
I would love to hear suggestions on how to do this.
E: Oh, and just to preempt this, even saying "i use only random passwords with no pattern" is useful information, as is having a ballpark password length.
Call me selfish, but if my password is known to be too tough to bother, so Eve moves on to someone else's weak password, great.
If the keys/passwords are already pushed to GitHub or other public hostin, they should also be revoked.
Just revoke the password/secret/whatever.
Squash merges are just bad. They destroy all the info that makes git handle branching and conflicts better than svn.
<commit-id>^ <commit-id>
is
<commit-id>^!
I use it all the time with:
git diff <commit-id>^!
Sure people should clean up their work, but as a fact not everybody does and it won't change tomorrow. You'll simply hear on the news: some Russian hacker are behind the attack or another bad excuse
https://adamlaycock.ca/blog/2016/05/23/Stop-Posting-Keys.htm...
One can do better by adding random lines/ logs in lot of files and sneakily remove password from one of them and then give a random commit name.
But then it all boils down to your mindset at that particular moment when you are commuting.
Just change the leaked passwords, don't try to hide the commits.
You could upload an example file... but please don't put real passwords in the example file.
jesus christ, how low can you stoop
https://github.com/checkr/supersecret/commit/6b9cdf366084318...
This could be a big thing. It's time to write: How to write code without expose you
Github, like SSH, uses an asymmetric authentication scheme. They even publish everyone's public keys. It's much more secure than passwords.