# Security in Apps

The IAM actions that govern apps, the permissions each operation needs beyond its own, what is audited, how secrets reach a machine, and what is exposed to the internet.

## IAM actions

Apps are a regional service: an app's resource name is
`rn:ews:<region>:<organization id>:deploy:app/<app id>`, for example
`rn:ews:de1:org-EXAMPLE1234:deploy:app/3f1c2b4a-5d6e-4f70-8a91-b2c3d4e5f601`, and
`rn:ews:de1:org-EXAMPLE1234:deploy:*` covers every app. Listing apps, or looking one up by slug,
needs `deploy:DescribeApp` on that wildcard.

(The table of IAM actions is generated on the web page.)
## Permissions beyond the operation's own

| Operation                                                                                 | Also needs                                                                                                               |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Any write with `"redeploy": true`, **Redeploy now**                                       | `deploy:DeployApp`                                                                                                       |
| Roll back with the environment restored                                                   | `deploy:ManageEnv`; `secrets:GetSecretValue` on a secret the app does not use right now                                  |
| Bind a secret in the environment or a registry credential                                 | `secrets:GetSecretValue` on the secret; binding grants it to the `deploy` consumer                                       |
| Import a `.env` file                                                                      | `secrets:CreateSecret`, `secrets:RotateSecret`, `secrets:UseSecretSource`, `secrets:GetSecretValue`, as the plan needs   |
| Bind or rotate a database (`deploy:ManageDatabaseBinding`)                                | `rds:ModifyDBInstance` on the database; for a branch, `rds:GetDBBranchCredentials` as well                               |
| Bind a cache (`deploy:ManageCacheBinding`)                                                | `cache:ModifyCacheCluster` on the cache                                                                                  |
| Bind a Kafka cluster, RabbitMQ broker or Document Database (`deploy:ManageBrokerBinding`) | `secrets:GetSecretValue` on the password secret of the user you bind                                                     |
| Reveal a binding's password                                                               | `secrets:GetSecretValue` on the role's secret (the master password's for a `master` binding); recorded on its access log |
| See bound databases, caches and brokers on **Resources**                                  | that service's describe permission                                                                                       |
| Read a container's log lines on **Resources**                                             | `monitoring:FilterLogEvents`                                                                                             |
| Each push deploying a repository app                                                      | the person who pushed holds `deploy:DeployApp` on the app                                                                |

`GET /deploy/api/apps/{id}` returns the environment only to a caller with `deploy:ManageEnv`, and
the compose file only to one with `deploy:UpdateApp`; the response says when either was withheld.
The Deutsche Cloud Console shows which action is missing instead of hiding a panel.

The app's **Access** tab shows who may view the app, deploy it, manage its environment or
administer it. Granting from there needs `iam:AttachUserPolicy`; without it the tab still shows the
grants and names the missing action.

## Audit

Every write is recorded in the audit log, allowed or denied. Reading a build log
(`deploy:GetBuildLogs`) is a sensitive read: it is recorded too, and the ReadOnly policy does not
include it. See [Audit log](/docs/audit-log).

## Secrets and data protection

- A secret bound to an app is decrypted at deployment and handed to the machine, never stored on the
  app and never returned by the API. An environment export writes references and names, never a
  secret value.
- A secret created by a `.env` import is encrypted under your CMK.
- A database binding's password is a secret the binding reads at every rollout.
- The desired-versus-live comparison sends only keyed hashes of environment values off the machine;
  see [What runs on your machines](what-runs-on-your-machines.md).
- Build logs mask credentials in URLs.

## Network exposure

- Only the published service is reachable from outside, through the app's domains over HTTPS; a
  compose file may not publish a host port.
- Compose services reach each other on a private app network.
- A machine obtains certificates only for names its app's domains cover.
- A private database's public endpoint admits only the control plane, never an app's machine; a
  binding that would need it is refused.
- Compose files may not use `privileged`, extra capabilities, host namespaces, devices or host
  paths.

## Related

- [Deploy from GitHub Actions](deploy-from-github-actions.md), with a least-privilege CI policy
- [IAM](/docs/iam)
