# Security in Error Tracking

Who may do what with projects, issues and events (IAM), which credentials exist and what each may do, and what is recorded in the audit log.

## IAM actions

Every request through the API, the CLI, Terraform or the console is checked against your IAM
policies. A project's resource name is `rn:ews:de1:<organization id>:errors:project/<project id>`.
Issues, events, transactions, profiles, queries, release health, alert rules and connections are
all checked against their project.

(The table of IAM actions is generated on the web page.)
These are checked against the service, `rn:ews:de1:<organization id>:errors:*`, not a project:

- `errors:ListProjects` to list projects (the list then shows only the projects you may list) and
  `errors:CreateProject` to create one;
- `errors:ListReleases` to list releases;
- for an auth token, `errors:UploadSourceMaps` and `iam:CreateAccessKey`;
- through the API and the CLI, `errors:GetEvents` to read a trace, a transaction's profile, or one
  statement across projects; the answer then holds only the projects whose events you may read.

Connecting a CI environment also needs `ci:PutEnvironment` on the repository; connecting an app,
`deploy:ManageErrorsBinding` on the app; connecting a database, `rds:DescribeDBQueryInsights` on
the database. A connected database grants nothing: each reader's own
`rds:DescribeDBQueryInsights` on it decides whether its statements are shown (see
[Connect a database to a project](connect-a-database.md)).

A policy for someone who may read and triage one project's issues (replace _org-id_ and
_project-id_):

```json
{
  "Version": "2024-01-01",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["errors:ListProjects", "errors:ListIssues", "errors:GetEvents", "errors:UpdateIssue"],
      "Resource": "rn:ews:de1:org-id:errors:project/project-id"
    },
    {
      "Effect": "Allow",
      "Action": ["errors:ListProjects"],
      "Resource": "rn:ews:de1:org-id:errors:*"
    }
  ]
}
```

## Credentials

| Credential   | May                                                                       | Lives                                                                                                          |
| ------------ | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| DSN key      | Send events to its project. Never read anything; safe in a browser bundle | Until revoked                                                                                                  |
| Auth token   | Everything its owner may do in Error Tracking (`errors:*`), nothing else  | The access-key lifetime it was given                                                                           |
| Upload token | Upload source maps to one project, and the reads `sentry-cli` needs there | At most an hour; a build's token 30 minutes, revoked when the build ends; a CI run's revoked when the run ends |

A connected project has a service account, `errors-uploader-<slug>-…`, whose policy allows only
the upload to that project. It holds no lasting key: every build and CI job gets a key of its own.
Deleting the project removes it.

## Audit

Every change (creating, changing and deleting projects, keys, alert rules and connections,
triaging and deleting issues, rotating keys, creating tokens) is recorded in the audit log,
allowed or denied, once the request has passed validation. Most changes to a project look the
project up first: for a project id that does not exist (or is not a UUID) they answer `404` and
record nothing. Connecting a CI environment checks `ci:PutEnvironment` on the repository before it
looks for the project, so that decision is recorded either way. A CI job's token exchange is
recorded as an anonymous `errors:UploadSourceMaps` with the repository, environment and run.
Reads are recorded only when they are denied, at most once a minute per user and action.

## Missing or not yours

Reading a project, its usage, or one issue answers `404` both when it does not exist and when you
may not read it. Most other reads of a project (issues, events, transactions, alert rules) answer `404` when
it does not exist and `403` when you may not read it.

## Network exposure

The ingest at `https://errors.<domain>` accepts events from anywhere that holds a DSN key, browsers
included. The Sentry API on the same host answers only an authenticated request: a token, or an
access key in an `Authorization: EWS-ACCESS-KEY` header; it applies your IAM policies as the
Deutsche Cloud API does.

## Related

- [Upload source maps](upload-source-maps.md)
- [Connect an app](connect-an-app.md)
