Live data from Hacker News

What will happen when you commit secrets to a public Git repo?

twitter.com

41–50 of 68 posts

Re: What will happen when you commit secrets to a public Git repo?

#41

Earlier quoted context omitted.

As spydium suggests in a sibling comment, I was not referring to overwhelming Github infrastructure but to mass invalidation of guessed tokens.

If you can guess keys and secrets, you probably wouldn't use that power to invalidate them!

I suspect this is relying more on a "birthday paradox" approach. The goal wouldn't be to invalidate a particular secret, but rather that with a relatively small number of randomly generated secrets, you would be taking advantage of this setup to invalidate at least some.

Re: What will happen when you commit secrets to a public Git repo?

#42

Cool experiment! I PM the secret scanning team at GitHub and wanted to mention what GitHub did behind the scenes here. GitHub scans every commit to a public repo for secrets one of our secret scanning partners may have issued. We forward those candidate secrets to the issuing partner, and they take action. In some cases they auto-revoke the secret (AWS normally does this, I believe), in some cases they notify the use…

Do you also scan when a private repo is changed to public?

Re: What will happen when you commit secrets to a public Git repo?

#43
post #33

Cool experiment! I PM the secret scanning team at GitHub and wanted to mention what GitHub did behind the scenes here. GitHub scans every commit to a public repo for secrets one of our secret scanning partners may have issued. We forward those candidate secrets to the issuing partner, and they take action. In some cases they auto-revoke the secret (AWS normally does this, I believe), in some cases they notify the use…

Why secret scanning is enabled only for public repos but not for private ones?

Private repos need a different approach, but committing secrets to them can still be a problem.

If a secret is committed to a private repo then anyone with read access to that repo could use it. That might give those users more permissions than they're supposed to have. It's particularly a problem in large organisations, where thousands of developers may have access to a private repo, but should not necessarily have direct access to production infrastructure.

That said, the risk tradeoff when a secret is found in a private repo is different to when one is found in a public repo. If it's a personal private repo that no-one else has access to, the risk may be limited. If it's a corporate repo with hundreds of contributors, someone almost certainly wants to be aware of it. Even then, each organisation will want to respond in different ways, perhaps depending on who has access to the repo, and what access the leaked secret granted.

I'd be remiss not to say that GitHub has a beta offering for private repo secret scanning that we launched in May. It's a paid feature, targeted at large, security-conscious organisations, that scans your git history and each new commit for secrets and displays them in the GitHub UI.

Re: What will happen when you commit secrets to a public Git repo?

#44
post #33

Earlier quoted context omitted.

Why secret scanning is enabled only for public repos but not for private ones?

Because it should be OK to commit secrets to private repos - that's why they're _private_, after all, right?

No, that's not not why.

If you have secrets, encrypt them.

Private repos can be turned public, intentionally or by mistake. Repos can be exported to give software to third parties. Also, git users clone repos, which means that those secrets are copied every where. Can you make sure those stay private too? Do you make your developers encrypt their laptops or delete repos from them before they leave their house or office?

Re: What will happen when you commit secrets to a public Git repo?

#45
post #29

Earlier quoted context omitted.

I think they meant it would autoinvalidate the tokens which might be valid. I think the math on an AWS secret and access key would be ridiculous to brute force.. but other types of keys might be an interesting attack vector.

what about the birthday paradox however? i.e. the attacker doesn’t need to brute force a specific key, but just any key... I guess for AWS the search space is still huge enough for it not to be a problem still (but didn’t do the math)

seems like you could just log in directly at that rate

Re: What will happen when you commit secrets to a public Git repo?

#46
post #29

Earlier quoted context omitted.

I think they meant it would autoinvalidate the tokens which might be valid. I think the math on an AWS secret and access key would be ridiculous to brute force.. but other types of keys might be an interesting attack vector.

what about the birthday paradox however? i.e. the attacker doesn’t need to brute force a specific key, but just any key... I guess for AWS the search space is still huge enough for it not to be a problem still (but didn’t do the math)

I believe AWS secrets are 240 bits. That is a pretty massive space. I don't know how many active secrets are out there, but I think someone would need to get very lucky to collide before the attack was noticed and stopped.

Other partner's secrets may be more susceptible.

Edit: I did not consider the paired access key which is another 70 or so bits. I think you'd need to collide on both to make someone have a bad day.

Re: What will happen when you commit secrets to a public Git repo?

#47

Cool experiment! I PM the secret scanning team at GitHub and wanted to mention what GitHub did behind the scenes here. GitHub scans every commit to a public repo for secrets one of our secret scanning partners may have issued. We forward those candidate secrets to the issuing partner, and they take action. In some cases they auto-revoke the secret (AWS normally does this, I believe), in some cases they notify the use…

Do you also scan when a private repo is changed to public?

I think so, and we 100% should do, but I just did a test and the secret I committed was still working a full minute after I converted the repo. Could be that the scan was in a queue, could be that it didn't trigger.

I'll dig into it and make sure this is working and is fast - it's a critical time to do a full scan of the repo's git history.

Re: What will happen when you commit secrets to a public Git repo?

#48
post #24

Just use a fucking blog, man. I'm so sick of threads like this. Edit: I'm sorry, this came off as way more aggressive than I intended. I get why people use twitter to share stuff like this, but it's much harder to archive, find or reference in the future, not to mention it being much less readable than a simple webpage. To anyone reading this, please consider publishing your findings on a blog as well as on twitter.

Hey, OP here. I agree that a blog post would be more readable. In this particular case I just didn't expect that it will catch fire. If I would then I would spend more time on the form. I won't make that mistake again (i.e. in the future I will use a blog post as main driver of such twitter thread).

Thank you!

Re: What will happen when you commit secrets to a public Git repo?

#49
post #41

Earlier quoted context omitted.

If you can guess keys and secrets, you probably wouldn't use that power to invalidate them!

I suspect this is relying more on a "birthday paradox" approach. The goal wouldn't be to invalidate a particular secret, but rather that with a relatively small number of randomly generated secrets, you would be taking advantage of this setup to invalidate at least some.

The point still stands: If you could do that, you would use them, not invalidate them.

Re: What will happen when you commit secrets to a public Git repo?

#50
post #19

Just use a fucking blog, man. I'm so sick of threads like this. Edit: I'm sorry, this came off as way more aggressive than I intended. I get why people use twitter to share stuff like this, but it's much harder to archive, find or reference in the future, not to mention it being much less readable than a simple webpage. To anyone reading this, please consider publishing your findings on a blog as well as on twitter.

Or post it on Reddit or Medium or whatever if you can't be bothered with a blog. Twitter "threads" need to die.

> Twitter "threads" need to die.

I would even remove "threads". Sick of all the hate and fakedom.

Post reply on HN