# GitHub App permissions

Every permission the kosa8 GitHub App asks for, what each one is used for and what it is never used for, and the exact token kosa8 asks GitHub for in each operation. Everything on this page can be checked: on GitHub's own pages for the app and in kosa8's audit log.

## Two kinds of access

- **The installation** (Settings, GitHub, **Connect GitHub**): an owner or admin installs the kosa8 GitHub App on a GitHub account or organization and picks the repos it may see. This is what lets kosa8 clone, push, open pull requests, post check runs and register runners. kosa8 never uses the installation's full set of permissions at once: for each step it asks GitHub for a new **installation token** that names only that step's permission, for one repo where the step has one (see [the tokens]).

- **Your sign-in** (Sign in with GitHub, and the identity check while connecting): a short-lived user token from GitHub that tells kosa8 who you are. It gives no access to repos. kosa8 uses it in that one request (your profile, your verified email address, and which installations of the app you can manage) and does not store it.

## The permissions

Repository permissions. kosa8 asks for no organization permissions.

| Permission | Used for | Never used for |
|---|---|---|
| **Contents**: Read and write | Read: clone a repo into a sandbox or a pipeline, and read code for a function, template or job (one file or one folder at one commit). Write: push a branch with a sandbox's commit. Also lets the app receive `push` events, which start [Pipelines](https://docs.kosa8.com/guides/cloud-pipelines/). | Pushing to any branch outside `kosa8/*` other than the one branch a person named for that push; pushing tags; deleting branches (the git proxy reads every ref update before it reaches GitHub and refuses the whole push otherwise); editing files through the API; releases. |
| **Pull requests**: Read and write | Open a pull request (a draft unless you say otherwise) for a branch kosa8 pushed; read a pull request's head commit for an `@kosa8` comment; react 👀 and post or edit kosa8's one reply on a pull request conversation. Also lets the app receive `pull_request` events for Pipelines. | Approving, merging, closing or marking a pull request ready for review; requesting reviewers; editing anyone else's pull request or comment. |
| **Issues**: Read and write | Only `@kosa8` comments on issues: react 👀 to the comment and post one reply, then edit that reply as the work goes. GitHub also requires Issues to deliver the `issue_comment` event at all, for issues and pull requests alike. | Opening, editing, closing, labelling, assigning or locking issues; editing or deleting anyone else's comments. With `@kosa8` triggers off (the default), no Issues token is ever made. |
| **Checks**: Read and write | Post one check run per result: `kosa8/pipelines` for a pipeline, `kosa8` for an `@kosa8` trigger or a sandbox's pull request, or the name you give a one-call run (`github_check`), with a **Details** link back to kosa8. | Re-running or changing other apps' checks; making a check required (that is your branch protection, set by you). |
| **Commit statuses**: Read and write | A fallback only: when an installation has not accepted Checks, a result is posted as a commit status instead. While Checks is accepted, no kosa8 token names this permission. | Anything else. |
| **Administration**: Read and write | Only [GitHub Actions runners](https://docs.kosa8.com/guides/cloud-ci-runners/), only for repos an admin turned runners on for: register a just-in-time runner on the repo (`generate-jitconfig`) when a `runs-on: kosa8` job is queued, and remove a runner that failed before taking its job. GitHub offers no narrower permission for repository runners. | Repository settings, collaborators, teams, branch protection, rulesets, webhooks, deploy keys, renaming, archiving or deleting a repo. Repos, pull requests, pipelines and `@kosa8` comments never ask for it. |
| **Workflows**: Read and write | Only **Move my workflows to kosa8** (Settings, GitHub, Runners), when an admin presses **Open pull request**: kosa8 commits the changed `.github/workflows/*.yml` files (`runs-on: ubuntu-*` to a kosa8 label) to the branch `kosa8/runners` and opens a draft pull request. You review and merge it; kosa8 never merges it. One token, for that one repository, names `workflows: write` with `contents: write` and `pull_requests: write`, and is revoked right after. | Any other push: a sandbox's push, a pull request from a sandbox, pipelines and `@kosa8` never name it, so GitHub itself refuses any of those that touches `.github/workflows/`. An agent working through kosa8 cannot rewrite your CI. |
| **Actions**: Read-only | Only so GitHub delivers the `workflow_job` event, which tells kosa8 a `runs-on: kosa8` job is waiting. No kosa8 token names it. | Reading your workflow logs, artifacts, caches or secrets; re-running or cancelling workflows. |
| **Metadata**: Read-only | List the repos the installation can see and their branches, look up one repo, and check that an `@kosa8` commenter has write access. GitHub gives every app this permission. | Nothing beyond reading names, branches and permissions. |

Account permission, for signing in only:

| Permission | Used for | Never used for |
|---|---|---|
| **Email addresses**: Read-only | Sign in with GitHub: read your verified primary email address once, to find or create your kosa8 account. | Mailing lists or anything else; the user token is not stored. |

### Permissions kosa8 does not use

kosa8 needs nothing beyond the tables above. **Workflows** is used for one thing only, the runner pull request an admin opens; no sandbox, pipeline or `@kosa8` token names it, so a push from any of those that creates or changes a file under `.github/workflows/` is refused by GitHub. If GitHub's page for the app ever shows a permission that is not in the tables above, kosa8 does not use it: no token kosa8 asks for names it, and you can see that in the audit log.

## The token each operation asks for

An installation token is made by GitHub on kosa8's request and works for at most one hour. kosa8 names the permissions and, where the step has one repo, that repo; GitHub enforces both. kosa8 keeps no token: none is stored, logged or returned by any API call, and none is put in a sandbox (git in a sandbox goes through [kosa8's git proxy](https://docs.kosa8.com/guides/cloud-github/), which adds the token on kosa8's side). "Revoked" below means kosa8 calls GitHub's `DELETE /installation/token` as soon as the step ends, so the token stops working then instead of at its hour.

| Operation | Permission in the token | Repos | Revoked | Audit log |
|---|---|---|---|---|
| List repos (the repo picker, `GET /v1/github/repos`) | metadata: read | All repos of that installation (it is a list) | After the list is read | `github.token`, purpose `list` |
| Find one repo, its branches or a commit | metadata: read | That one repo | After the step | `github.token`, `lookup` |
| Clone into a sandbox or a pipeline job (each git request through the proxy) | contents: read | That one repo | When the response has streamed | `github.token` `clone`; `github.git` `op: upload` |
| Push a sandbox's commit (each git request through the proxy) | contents: write | That one repo | When the response has streamed | `github.token` `push`; `github.git` `op: receive` with the refs |
| Open the pull request | pull_requests: write | That one repo | After the call | `github.token` `pr`; `github.pr` |
| Read code for a function, template, job or a pipeline's `.kosa8/pipeline.yml` | contents: read | That one repo | After the read | `github.token`; `github.read` with the commit |
| Post a result on a commit | checks: write (or statuses: write as the fallback) | That one repo | After the call | `github.token`, `check` or `status` |
| `@kosa8`: check the commenter's access | metadata: read | That one repo | After the call | `github.token`, `trigger_permission` |
| `@kosa8`: read the pull request's head | pull_requests: read | That one repo | After the call | `github.token`, `trigger_pr` |
| `@kosa8`: 👀 and the one reply | pull_requests: write on a pull request; issues: write on an issue | That one repo | After each call | `github.token`, `trigger_reaction`, `trigger_comment` |
| Link an installation to your kosa8 organization | metadata: read | The installation (to confirm it can see repos) | After the call | `github.link` |
| Read a pull request to continue it (`GET /v1/github/repos/{owner}/{repo}/pulls/{n}`, or `repo: {name, pr}`) | metadata: read, pull_requests: read | That one repo | After the call | `github.token`, `pr_read` |
| Preview **Move my workflows to kosa8** | contents: read | That one repo | After the read | `github.token`, `runners_preview` |
| Open the **Move my workflows to kosa8** pull request | contents: write, pull_requests: write, workflows: write | That one repo | After the pull request is open | `github.token` `runners_pr`; `github.runners_pr` |
| Register a runner | administration: write | That one repo | After `generate-jitconfig` | `github.token`, `runner_register`; each job is in `GET /v1/ci/jobs` |
| Remove a runner that failed before taking its job | administration: write | That one repo | After the call | `github.token`, `runner_remove` |
| The Runners list (Settings, GitHub) | metadata: read | All repos of that installation (it is a list) | After the list is read | `github.token`, `list` |

Every token above is in **Settings, GitHub**, **Every token kosa8 used** (and `GET /v1/github/activity`, CSV with `format=csv`).

The sandbox itself never gets a token. For one clone or one push, the git command in the sandbox gets a *capability*: a random link that works only through kosa8's proxy, only for that sandbox, that repo and that direction (read or push), for at most 15 minutes, and is deleted when the command ends. While that one command runs, other code in the same sandbox could use the capability for the same repo and direction; it can never get the GitHub token behind it. [What if kosa8 were breached?](https://docs.kosa8.com/guides/cloud-github-breach/) walks through what that leaves.

## Webhook events

Every delivery is checked against its `X-Hub-Signature-256` HMAC before anything is read. Apart from linking a new installation, an event from an installation that is not linked to a kosa8 organization is ignored.

| Event | What kosa8 does with it |
|---|---|
| `installation`, `installation_repositories` | Sent to every app. Link a new installation to the kosa8 organization of the admin who made it; forget an uninstalled one; turn runners off for repos taken out of the installation. |
| `push` | Start the pipelines connected to that repo. Nothing runs unless a pipeline is connected. |
| `pull_request` | Start the pipelines connected to that repo, never for a pull request from a fork. |
| `issue_comment` | Look for `@kosa8 run` or `@kosa8 agent` in a new comment. Off until an admin [turns triggers on](https://docs.kosa8.com/guides/cloud-github-triggers/). |
| `workflow_job` | Start, track and end a runner for a `runs-on: kosa8` job, only for repos with runners turned on. |

Every other event is answered with "ignored" and nothing else happens.

## Check it yourself

1. **On GitHub**: your account or organization's **Settings**, **Applications** (or **GitHub Apps**), **Installed GitHub Apps**, kosa8, **Configure**. It lists the exact permissions the installation holds and the repos it can see. Choose **Only select repositories** if you want kosa8 to see fewer repos. Uninstalling there ends every token at once.

**Every token kosa8 asked for**: the [audit log](https://docs.kosa8.com/guides/audit/) in the web app, or

```
curl -s "https://api.kosa8.com/v1/audit?action=github.*&limit=50" -H "Authorization: Bearer $KOSA8_API_KEY"
```

2. Each `github.token` event has the repo, the permission string (for example `contents:write`), the purpose, the sandbox and who asked. `github.git` has every push's refs, including refused ones.

3. **What GitHub saw**: where your GitHub plan keeps an organization audit log of API and git activity (GitHub Enterprise Cloud, and its audit log streaming), requests made with the app's tokens are attributed to the app. Match their times and repos against kosa8's `github.token` events.

4. **In a sandbox**: run `env`, `cat .git/config` and `git remote -v` in a sandbox started from a repo. You will find the plain `https://github.com/owner/name.git` remote and no token.

5. **What a push may touch**: try `git push origin HEAD:main` from a sandbox's checkout through kosa8; the proxy answers `! [remote rejected] … (kosa8 pushes only to branches kosa8/*, not main)`.

## Recommended on your side

- Protect your default branch (require a pull request and a review). kosa8 never asks to be on a ruleset bypass list, so your protection applies to it like to anyone. Note that a person or API key with `sandboxes:write` may name a branch for one push; branch protection is what stops that branch being your default branch.

- Turn runners on only for the repos that need them, and leave `@kosa8` triggers off until you want them.

- Keep kosa8 API keys scoped: a key without `sandboxes:write` cannot push or open pull requests at all.

## See also

- [Work with your GitHub repos](https://docs.kosa8.com/guides/cloud-github/)

- [What if kosa8 were breached?](https://docs.kosa8.com/guides/cloud-github-breach/)

- [`@kosa8` in issues and pull requests](https://docs.kosa8.com/guides/cloud-github-triggers/)

- [GitHub Actions runners](https://docs.kosa8.com/guides/cloud-ci-runners/)

---
Source: https://docs.kosa8.com/guides/cloud-github-permissions/
