Skip to content

Commit 2f0428a

Browse files
authored
docs: add be-careful-with-repo-scope
1 parent aafa979 commit 2f0428a

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed

assets/css/custom.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
code {
2+
background: #f5f5f5;
3+
color: #c7254e;
4+
padding: 2px 4px;
5+
border-radius: 4px;
6+
font-size: 95%;
7+
}

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ listDateFormat = "02.01.2006"
1515
readMore = true
1616
rssFullContent = true
1717
favicon = "favicons/"
18+
customCss = ["css/custom.css"]
1819

1920
[[params.socialIcons]]
2021
icon = "fab fa-github"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
+++
2+
title = "Be careful using GitHub PAT with repo scope"
3+
date = 2025-06-26T15:38:30+08:00
4+
header_img = ""
5+
toc = false
6+
tags = ["GitHub","PAT"]
7+
categories = ["GitHub"]
8+
9+
+++
10+
11+
12+
Did you know that when you're using a Github personal access token (PAT) with the ```repo``` scope, it gives you more permissions than just accessing your repositories? If not, you should take a look into this blog post.
13+
14+
## What is a GitHub PAT?
15+
A classic GitHub PAT gives you the possibility to authenticate using a token against Github, and it's going to impersonate as your user account. Depending on the chosen scope, you can do multiple things with these token. For example read repository content, write to repository, etc. To create a classical personal access token, you have to go to your [developer settings of your personal account](https://github.com/settings/tokens?type=classic).
16+
![PAT creation](pat-creation.png)
17+
18+
19+
## What is the issue with the repo scope token?
20+
I was currently working for a customer and they wanted to migrate from GitHub Enterprise Server to GitHub Enterprise Cloud. Therefore we have tooling in place like the [GitHub Enterprise Importer (GEI)](https://docs.github.com/en/migrations/using-github-enterprise-importer). One downside of the tooling is, it will not migrate teams, users, repo permissions, etc. That was the reason I created some post-migration scripts to do the work and with this I noticed something weird. I only had a `repo` scope token accidentally but wanted to create a team for the organization. And guess what? It worked... 😵‍💫
21+
22+
I was confused and checked the scope of my token, looked like this
23+
24+
![repo scope](repo-scope.png)
25+
26+
Looks pretty clean here. No hints for additional permissions, right?
27+
28+
I played around a little bit and came to the conclusion that has to be a bug 💪. My PAT doesn't have `admin:org` scope, so that shouldn't work. Following this up I created a support ticket on GitHub just to get the confirmation `this is by design`. True to the motto: `"It is not a bug, it is a feature"`. What the hell! 🤯
29+
They pointed me to the [docs](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps#available-scopes) where it is outlined as well:
30+
31+
![repo scope docs](repo-scope-docs.png)
32+
33+
Well, this is some kind of misleading, isn't it? You have the `admin:org` scope for exactly this scenarios:
34+
35+
![org admin scope docs](org-admin-scope-docs.png)
36+
37+
But some of these resources are included by design in the `repo` scope, too. Why GitHub, WHY?!?!
38+
39+
40+
## Conclusion
41+
I think this is still a bug and should be fixed. Yes, this may cause some integrations to stop working but it will definitely increase security and predictability. It is more consistent to use the `org:admin` scope to handle organization resources instead the `repo` scope. Using the GitHub API with classic PAT shows some other strange behaviors but this is a topic for another blog post.
42+
43+
Next time you give a person or tool your "just" `repo` scope token keep in mind that it can be used to modify organization level resources likes teams, projects, etc. For sure you can use this on purpose to work with lower privileges than necessary 😁
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)