8 ms·
Behind GitHub’s new authentication token formats
- ramses0 6y agohttps://tools.ietf.org/html/rfc8959 https://tools.ietf.org/html/rfc8959 - "secret-token:E92FB7EB-D882-47A4-A265-A0B6135DC842%20foo"
- RyJones 6y agook, great, when will I be able to scope tokens to acting on only one repo, or only one org, or in any meaningful way?
- nathanaldensr 6y agoI completely agree. This change is interesting and all, but GitHub (Enterprise, in my case) tokens aren't granular enough. There's a lot more benefit to be had in fixing that issue.
- chatmasta 6y agoI definitely agree this is needed, but I have to imagine it's quite a complex change on GitHub's side. It probably entails changing a lot of their authentication architecture, in terms of what's stateless and stateful and what requires a trip to the DB to check (i.e., it's hard to encode a list of which resources you should have access to in a single token). I'm sure they're aware this is a problem though. Maybe this recent change sets the groundwork for fixing it.
- threeseed 6y agoGitHub for me is running out of excuses for why the fundamentals of their platform is so poor. And why compared to Gitlab they deliver improvements at such an anaemic pace. They act like a company with 15 employees let alone 1,500+. Everything from Security, Actions, Containers, Packages, Terraform, JIRA Integration etc is either completely broken or has major outstanding issues that haven't been fixed for years.
- chatmasta 6y agoPersonally, we use GitLab for all the internal repos at our company. We originally migrated because GitLab CI was free and GitHub didn't even have a CI solution at the time. We still use GitHub for our public repos since that's "where the community is." GitHub actions is great, although IMO a bit too prescriptive (I'd rather write a script that can run anywhere rather than spend time building up the mental model of the abstractions that are unique to GHA). But nothing beats GitLab CI + container registry; we put a lot of work into our CI pipeline and now we've got incremental builds with a Docker image for every service tagged per commit. And since GitLab Container Registry supports manifest v2, we can take advantage of BuildKit layer caching (I think GitHub registry supports this now too, but haven't played with it). That said, GitLab has its fair share of problems too. GitHub UI is way better, community/discussion features are better, and forking/public collaboration workflow is better. I'm glad there are two big players in the space, though; GitLab really lit a fire under GitHub to finally get them to start pushing new features.
- RyJones 6y agoThat the only method I have to scope tokens is to break the TOS for GitHub - by creating single-use accounts - is super lame.
- JamesSwift 6y agoWhat TOS does it violate? They explicitly recommend creating machine users in certain areas of their help docs.
- jpalomaki 6y agoThis one? ”you may not have more than one free Account” https://docs.github.com/en/github/site-policy/github-terms-of-service#b-account-terms https://docs.github.com/en/github/site-policy/github-terms-o... But there’s also later more detailed guidance: ”One person or legal entity may maintain no more than one free Account (if you choose to control a machine account as well, that's fine, but it can only be used for running a machine).”
- kroltan 6y agoPresumably then it would be non-violating to have many paid accounts? Sure is pricey for smaller operations but depending on the value it brings to have this more granular scoping it surely might be worth it? Doesn't remove their need to implement a more reasonable way of scoping tokens, though.
- ArchOversight 6y agoThis means that if you create a work account that is separate from your personal account (because you don't use personal credentials on work machines and vice-versa) then you are technically in violation of the TOS... Yet this is something I, and many others, do because we don't want to mix business with pleasure. In fact I absolutely refuse to do so because of security reasons.
- Arnavion 6y agoMany Microsoft employees also have separate personal and work accounts. I would be surprised if that was a violation.
- tptacek 6y agoI'm sure this is a valid complaint about Github, but it has nothing to do with the article, which is a bit annoying since there's some cleverness in that article (checksumming tokens, for instance) that we could be talking about stealing, rather than turning this thread into a generic referendum on whether Github is good.
- chatmasta 6y agoThe article is about GitHub's authentication tokens. It seems relevant to bring up a complaint about their scopes.
- tptacek 6y agoAnd yet it's not, because this is an article about token formats, and not about entire authorization schemes.
- threeseed 6y agoa) I don't see what is particularly clever about their token algorithm. b) Talking about fundamental flaws in their token implementation seems relevant in a discussion about their token implementation. c) Public discussions about flaws are often the best way to educate others and make the company aware of them.
- prepend 6y agoIt’s valid because GitHub is using cycles on format when the functionality is more important. I think these new formats are nice, but don’t care give how hard to use their token scheme is. Just some mention of other stuff coming would be nice. The problem I have is I’m not even sure if GitHub recognizes this as a problem (I have to grant access to every repo I can access to every script) and it’s been broken for years. Would be nice to know what they’re working on.
- threeseed 6y agoThis is what they are working on: https://github.blog/changelog/ https://github.blog/changelog/ It seems to me that its a PM centric process i.e. lots of end-user features rather than fixing the behind the scenes parts that are poorly designed and/or broken. We tried to workaround the inadequate token support by using their Terraform module for automation. Only for it to delete our repos losing years of issues because of a bug where renaming = deleting (3 year old issue that has never been prioritised).
- paxys 6y agoYou can already do that today. Create a Github App and add it only to a single repo.
- Serow225 6y agoI'd be happy to have a repo read-only scope to start with, it seems a little nutty that in the year 2021 the only repo scope available is read-write https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes https://docs.github.com/en/developers/apps/scopes-for-oauth-...
- mperham 6y agoThe key insight here is that random tokens should be self-describing, so you know their intended use and therefore can make decisions and take action when one is detected. If a script sees "ABC123" in a code commit, that's meaningless. If you see "secret-token:ABC123", now you can fail the commit with an error message: "Secret token detected in public commit, aborting."
- echelon 6y agoOne of the biggest learnings of our org was to prefix tokens with the entity type. It's helped immensely. entity-type:RANDOM_TOKEN * Helps in migrations, especially complex ones where you split up entity types. * Identities what tokens are so people can look them up if they see them in logs. * Polymorphic relationships can delegate to the appropriate owning service easily without additional bookkeeping. You can also encode other stuff in the token entropy, too, such as the author DC/region for active-active setups where you need to forward the request to the source of truth in the brief window where the other regions don't know about it yet.
- 11235813213455 6y agothat's how Stripe prefixes their IDs too, depending on what type of entity it is. Makes debugging, docs, .. easier
- fiddlerwoaroof 6y agoI’ve always thought that a Java-style reverse domain name format (or, perhaps, URLs) is a great way to encode IDs: com.foo.bar.Person:0000-11111-22222-33333 or whatever. That way, any code that logs IDs or transfers IDs across the network gets tracing “for free” and, when you see an ID in a bug report, you can use it to help focus the investigation.
- ljm 6y agoRuby/Rails has this in the form of GlobalID[1]. To be honest I haven't seen it used outside of whatever Rails itself automatically does, but the concept is there. [1]https://github.com/rails/globalid https://github.com/rails/globalid
- vsareto 6y ago>One other neat thing about _ is it will reliably select the whole token when you double click on it Shout out and kudos to whomever brought that up
- chatmasta 6y agoFrankly the fact that this doesn't happen with `-` in a `<code>` block should be considered a browser bug.
- williamdclt 6y agoWell it doesn't happen in IDEs either (by default, at least)
- chatmasta 6y agoI can see the argument for multi-line pre-formatted code blocks, but for inline `<code>` it would be nice if double clicking anywhere selected the whole thing.
- williamdclt 6y agoI'd rather consistent behaviour TBH, I'm not too happy that `-` is a non-word character but I'd rather it always behaves the same everywhere without having to think about context
- rgoulter 6y agoI wasn't quite aware of this because there are slight inconsistencies in some programs and between OSs. e.g. in powershell on Windows, Ctrl+Backspace deletes the word part, but in cmd shell, Ctrl+Backspace deletes until whitespace. The keybindings to delete word also vary on Windows vs MacOS (Alt+Backspace deletes a word on mac, but deletes the whole line on Windows. Windows uses Ctrl+Backspace for that). I was also confused since by-default Emacs doesn't treat `_` as a word character.
- 6y ago
- glsdfgkjsklfj 6y agoYou know a company do not take tech seriously when they use fancy quotation marks in code blocks.
- systemvoltage 6y agoSide rant: Github devs, if you're listening, please give us REST API. Not everyone knows GraphQL or has the motivation to do so. The industry standard is REST for public facing APIs, including companies such as Stripe (widely considered to be the gold standard for public API design and documentation). You can use GraphQL internally.
- minitech 6y agohttps://docs.github.com/en/rest https://docs.github.com/en/rest
- systemvoltage 6y agoI remember having to use GraphQL to delete a Docker image that was stuck in my private repo and there was no GUI to clear it. Wasted a couple of hours trying to send a GraphQL query which would have been a 2 minute jobbie using cURL. Github's public REST API didn't have this feature.
- bastardoperator 6y agoThey have a curl example in the docs https://docs.github.com/en/packages/learn-github-packages/deleting-and-restoring-a-package#deleting-a-version-of-a-repository-scoped-package-with-graphql https://docs.github.com/en/packages/learn-github-packages/de...
- azimuth11 6y agoA lot of REST APIs are just as hard to grok as GraphQL is as a whole. Companies often lack schemas and documentation, which GraphQL helps with out of the box.
- seoaeu 6y agoIt seems weird that in a blog post about a new format for tokens, there isn't a single example of what a GitHub token now looks like.
- abrookewood 6y agoFrom the opening paragraph: "old authentication token formats are hex-encoded 40 character strings"
- sneak 6y agodescription != example
- Wowfunhappy 6y agoDoes anyone know if these new tokens are backwards compatible with software that used the old tokens? By which I mean, I’m using a version of Git Tower from before they switched to a subscription model, and I’m wondering whether regenerating my tokens will make me unable to log in.
- sneak 6y agoI imagine they should be, they're still just strings. It's possible that Git Tower does some local validation that might complain, but I think they are in the same set of characters. You could always write a crack for the local validation, too.
- greysteil 6y agoThe reason we (GitHub) kept the new tokens to 40 characters, matching the length of our old tokens, was to make this change as backwards compatible as possible. We’ve never documented or committed to our tokens being 40 characters long, but they’ve been that way a long time and there may be software out there storing them in a fixed length database columns. If you use a service you’re worried the change may break I’d recommend minting a new token and trying it, perhaps on a new account on that service, before revoking your old one. (We do plan to increase the length of our tokens in future, but not before July 2021 at the earliest.)
- gkop 6y agoWould someone comment on this idea in context of JWTs? Not trolling, just curious as I use JWTs and embed this kind of metadata as a custom claim, which accomplishes some but far from all of what GitHub accomplishes here, but then I have no need for the easy scanning. So seeking wisdom from anyone who has thought carefully about whether or not to prefix their JWTs in this way.
- paxys 6y agoA big motivation for such token formats is to quickly and easily identity when they are shared somewhere they shouldn't be. JWTs aren't helpful in that regard, since they always present themselves as a base64 encoded blob.
- gkop 6y agoTotally, but JWT-like blobs can be detected (see sibling comment), and parsing attempted, so for the automated scanning use case, if I understand correctly, it can be done with perfect accuracy, just at a larger computation expense and worse security exposure due to the complexity of the scanning and the need to parse. The more interesting side to me is the benefit to humans, from the prefix technique.
- threeseed 6y agoThe question is why you couldn't just have "${prefix}-${JWT}" as your format. Then you can just strip the prefix before parsing. Which means don't need to worry about checksumming or entropy and you have the ability to embed large amounts of data as well as plenty of client support and libraries. Would be curious if this implementation is somehow more performant.
- benatkin 6y agoYeah, what GitHub is doing by including the checksum is reinventing JWT, with HS256 precisely. They could also make it easy to grep (see other comment) by having the payload always start with the same prefix - if it starts with `{"gh":"` the jwt will contain `.eyJnaCI6I` The subject doesn't need to be a user ID, and it sounds like they don't want that. It could be a session ID.
- Mandatum 6y agoI wonder why they went with 2 rather than 3 or 4 for company identifier. Stock ticker for instance would make sense. Not really practical.
- paxys 6y agoThis isn't meant to be a standard, just something they picked for themselves. And it doesn't even need to be a company identifier. Slack tokens are prefixed with "xox<token type>-", for example.
- chrismorgan 6y ago> Thus, we are adding a separator: _. An underscore is not a Base64 character which helps ensure that our tokens cannot be accidentally duplicated by randomly generated strings like SHAs. This is just a little bit misleading. Base64 isn’t a single neat and tidy thing: there are several alternatives for the encoding characters 62 and 63, padding, line break behaviour and one or two more things; see https://en.wikipedia.org/wiki/Base64#Variants_summary_table https://en.wikipedia.org/wiki/Base64#Variants_summary_table. When you’re talking about Base64 on the web, you’ll very commonly be talking about base64url, the URL- and filename-safe variant, rather than what’s most commonly called base64 and typically the default. But base64url is in widespread use, and has _ as character 63. Also “randomly generated strings like SHAs” aren’t typically doing Base64 anyway,but rather hexadecimal encoding.
- jridgewell 6y agoThe post isn't super clear, but I think they're describing base62 here. It says base62 later in text when talking about the checksum, and the "Our implementation for OAuth access tokens are now 178" section uses `a-zA-Z0-9` which is base62.
- alexc05 6y agoThat was a really well thought out article. I loved the use of underscore and the "it'll reliably double click" I liked that they looked to other companies out in the sold and acknowledged that they're learning from others. I didn't know what to expect when I opened the link, but I'm glad I read it!