# Security in Git

Who may do what with your repositories, which credentials reach them, and what is recorded.

## IAM

Permissions are per repository: a policy can name one repository or all of them. A repository's
resource name is `rn:ews::<organization id>:git:repository/<repository id>`; Git is regionless, so
the region segment is empty. `rn:ews::<organization id>:git:*` covers every repository.

```json
{
  "Version": "2024-01-01",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["git:GetRepository", "git:PullRepository", "git:PushRepository"],
      "Resource": "rn:ews::org-EXAMPLE1234:git:repository/5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60"
    }
  ]
}
```

Some actions stand apart so a policy can deny them while allowing the rest:

- `git:PublishRepository`: making a repository public, at creation, import or later.
- `git:ConfigurePushMirror`: sending code to a remote outside Deutsche Cloud.
- `git:BypassSecretProtection`: pushing past secret scanning with a reason.
- `git:PushProtectedTag`: creating, moving or deleting a protected tag.

The repository's **Settings → Access** grants one of three levels, each a bundle of these actions:

| Level      | Grants                                                                                                                                  |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Read       | see the repository, its pull requests, issues and releases, and clone it                                                                |
| Push       | Read, plus push, open, review and merge pull requests, use the merge queue, publish releases, post commit statuses, upload SARIF        |
| Administer | Push, plus settings, branch and tag protection, security alerts, secret scanning bypass, deploy keys, webhooks, publishing and deleting |

(The table of IAM actions is generated on the web page.)
## Credentials

| Credential      | Reaches                                                     | Notes                                                                                                                 |
| --------------- | ----------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Access token    | HTTPS and the API, for the repositories its owner may reach | Shown once; optional expiry (1 to 365 days); can be narrowed to some repositories and to read only; `lastUsedAt` kept |
| Account SSH key | SSH, for the repositories its owner may reach               | No passwords over SSH                                                                                                 |
| Deploy key      | SSH, one repository                                         | Read-only unless created with write access; can never push a protected tag                                            |

A token never does more than its owner's own policies allow.

## Network exposure

- Repositories are served over HTTPS and SSH on the Git host. Verify the server's SSH host key
  fingerprint by hand before the first connection; it is shown as **Server fingerprint** under
  **Account → SSH keys**.
- A public repository can be cloned anonymously; anonymous requests are rate-limited per address
  and answered 429 with `Retry-After` past the limit. See
  [Public repositories](public-repositories.md).
- Webhooks reach only public `https://` addresses and follow no redirects; imports fetch only
  from `https://` sources.

## Audit

Every write is authorized and recorded in the [audit log](/docs/audit-log), including turning secret
push protection off for a repository. A push past secret scanning is also recorded as an alert,
with the person's name and reason. Webhook deliveries of a webhook with a secret are signed with
HMAC-SHA256 in `X-EWS-Signature-256`.

## Related

- [What runs on your machines](what-runs-on-your-machines.md)
- [Repository security features](security-features.md)
