Heroku Security Notification
status.heroku.com
status.heroku.com
There are countless SaaS applications asking for full-repo access to Github (all the source code, with write access).
- Productboard
- Bugsnag
- Sentry
- Skylight
- Percy
- CodeTree
- Databox
There are heaps of others, these are just some on top the of my mind. A ticking supply chain attack waiting to happen, since these companies make themselves into alluring hacking targets.
Most of them need access only to issues (a few need read access to code or recent commits, almost none need write).
Solution:
- Let customers give granular access (only issues, only read to source code, etc) when the integration is setup. This is possible with Github's APIs.
- Try to use push instead of pull where possible, i.e. provide a CLI tool to use with Github actions or use Github's webhooks.
Sentry does not request write access to source code. It requests read/write access to issues and read access to source code. You can also see this on the documentation for the GitHub enterprise integration which lists the exact permissions required: https://docs.sentry.io/product/integrations/source-code-mgmt...
It would still be better if I didn't have to give read access to source code, but could still use the issues integration. But I agree it's not as a bad as write access to source code.
Or maybe worse, integrations asking for access to anything my account has access to, when I only want to grant it to one repo or organization, or only to public repos and not private ones.
Whenever I've reached out to inquire/complain about this, I've been told that github does not give them granular enough auth settings to ask for less than this.
Is this true? I don't know. When I've tried looking at the relevant github docs myself, i quickly get confused.
Does anyone understand the github auth architecture -- does it need to be fixed to allow more granular access, or are integrations just not using it properly? Like... who should I be complaining to?
GitHub has 'OAuth Apps' and 'GitHub Apps' [0]. The former's scopes do not permit such granularity (eg the `repo` scope gives access to all repos of the account [1]).
The latter is much more granular, allowing the user to select specific repos to grant permission [2]. The 'GitHub App' owner can see their installations and also determine if the user chose access for all repos or on a per repo basis.
Netlify does such granular installation and will prompt you if you don't see your repo listed in their dashboard to check permissions.
[0] https://docs.github.com/en/developers/apps/getting-started-w...
[1] https://docs.github.com/en/developers/apps/building-oauth-ap...
[2] https://docs.github.com/en/developers/apps/managing-github-a...
Which makes sense... but then so many companies don't do that.
I don't totally understand why they offer these two mechanisms of integration -- or why the granularity of access would need to be different between them. Why not let "OAuth apps" be authorized per-repo -- if you are going to have "OAuth apps" existing as a thing still? And they don't seem to be deprecated in favor of newer "github apps", right?
I imagine for legacy support or business reasons they maintain the OAuth API, but I too wish they add granular repo support to the OAuth API and existing tokens were migrated to an all repos scope, while new tokens were encouraged to be per repo scoping.
I have respect for the Heroku/Salesforce Security team for willing to ask users to perform this action. Many companies would be too worried about losing customers or having users not reconnect it afterwards.
My thoughts are with the team working on responding to this incident on Easter Friday.
For checking your Github audit logs, you can go directly here (replace ORG_NAME with your own): https://github.com/organizations/<ORG_NAME>/settings/audit-l...
Or from: Organization > Settings > Archive > Logs > Audit Log
I hope we get some more clarity on the extent of this incident soon. We'll rotate our keys anyway but I really hope the attackers did not have access to the ENV vars that are commonly set on Heroku directly.
I had to remove them one by one.
It's very possible (likely) this is all fine, but done in a way that feels strange/fishy. I haven't even gotten an email from travis. They must be in fire-extinguishing mode.
I see he now has access to three travis-ci organisations on GitHub.
In general, it's good practice not to check anything sensitive into source code for precisely this reason (if your code is compromised you don't want your secrets to be as well). So it'd also be good practice to add something like gitleaks into your CI/CD pipeline for the future.
Sounds like the best course of action for someone like me would be to just to log in, find any button that says "delete everything" and use it. So confusing.
Yet that isn’t even close to the best course of action. If your GitHub account was compromised and you had secrets in private repos, deleting everything in your Heroku account isn’t going to do anything to help.
Hope it can help some of the organizations dealing with this right now!
https://blog.gitguardian.com/a-practical-guide-to-prioritize...
It'd be great if Github could allow read/write permission grants on a per-repo basis. Maybe they do already!.. in which case I'd much rather have and setup that granular detail than have a token that goes across all my public/private repos...
Edit: I do see in my Github's integration page that the Heroku connection was used within the past week... but it doesn't show how exactly it was used. Until Github can provide specific details, is it safe to assume that all repos, public and private, could have been cloned?
They totally do. Shopify's Github integration works this way, and it is fantastic!
I noticed that some members of my team were committing changes to our enterprise repositories with poorly-configured clients, so it was impossible to tell who made the commit or performed the push.
I understand that git itself doesn't have any protections against this, but GitHub knows who pushed it; why isn't that metadata available?
https://docs.github.com/en/enterprise-server@3.2/admin/monit...
(Updated for clarification: user identity is available via the API, but only the identity embedded in git itself, not the GitHub authenticated user.)
https://github.blog/2022-04-15-security-alert-stolen-oauth-u...
Yesterday I got a notification that someone tried logging into that Gmail account. The password was hard coded in the code…
This email was a one off that outside this code exists nowhere else.
Someone who misses the memo on this one, isn't so good at git, and/or is on a smaller project could really be bad news.
Credentials and other secrets, like API keys, should never be hard-coded in the source code repo. Use some sort of secrets management or configuration for that kind of stuff.
If Heroku could confirm environment variables were safe I’d have a much better sleep tonight.
Based on the above information, my assumption is that the attacker gained access to code repos hosted on GitHub, but not access to live dynos or the Heroku dashboard (that happily shows ENV vars). We'll see if this information updates as the investigation progresses, though.
However, given 1) write access to a github repo, and 2) auto-deployments from github to production dynos (if enabled), an attacker could exfiltrate env vars (among many other nasty things). However, this would trigger events in your app's activity log (new commits + deploys) and should be quick to verify that it didn't happen.
If you manage your own key, you can store it in a password manager or use a USB hardware key to store it
You could also use object/blob storage or your local filesystem to store a config file and optionally apply encryption to that
I've been eyeing it recently and I'm thinking about launching my next project with it. Does anyone have any takeaways from using Render vs Heroku?
I was worried that Heroku would end up costing me a small fortune as demand scaled. Plus the platform seemed to have stagnated.
I contemplated switching to AWS, but didn’t want to deal with the extra hassle of it. By chance, I saw someone mention Render on here, checked it out, and couldn’t be happier.
It’s a bit harder to get up and running with Render than Heroku, but orders of magnitude easier than with AWS. And once you’re operational, it’s a cinch.
And way, way, way cheaper.
Additionally, spinning up the postgres instance was on a paid tier. I contacted support but it self-resolved eventually after I blew away the instance and rebuilt. However, it was queued up for like 8+ hours on the first pass.
Travis-CI was also compromised here and that may actually affect more people than the Heroku side of this.
- it's stored locally (so any developer machine access could compromise secrets)
- it's stored on the build/CI machines (that might run untrusted code in the form of dependencies--possibly from unrelated repos)
- it can end up in build artifacts
I'd like to discuss mitigations around this and similar incidents with other HN:ers:
- Knowledge sharing: resources, how-tos, tips - Discussing prevention, mitigation, etc - Moral support and venting
If there's already such a forum (I assume there is), please send me an invite :)
https://github.com/organizations/<ORG_NAME>/settings/audit-l...
... but the real question is what would malicious activity look like, exactly?
I've reached out to Heroku support to ask.
If you email GitHub support they can pull out detailed logs from oauth app interactions from their internal tools.
I would expect the GH security team to have relevant queries ready by now, maybe even do some proactive queries and start alerting anyone who had suspicious activity. (But this is just how I'd do it I have no special insight if they are doing this or something else).
I wonder if the hackers were kids who got bored around Easter holiday - meaning Heroku's security is shit - or if Heroku deliberately waited to announce this during Easter holiday to minimize the attention it gets - meaning they are as deceitful as all proper megacorps.
I haven't been able to trust their status page to accurately reflect what works and what doesn't for a long time. The only reliable signal is when their status page goes offline ;)
RE kids or misdirection: as with all things, it's probably somewhere in the middle -- a somewhat-sophisticated attacker and a slow, evolving investigation unfortunately coinciding with a holiday weekend. They say the report was received 3 days ago (on April 13) from GitHub after they noticed suspicious activity on April 9.