# Security in Load balancing

Who may do what with a load balancer (IAM), what is audited, where certificate keys are kept, and how targets can tell your load balancer's traffic apart.

## IAM actions

Every request, from the API, the CLI, Terraform or the console, is checked against your IAM
policies. A load balancer's resource name is
`rn:ews:<region>:<organization id>:lb:load-balancer/<load balancer id>`.

(The table of IAM actions is generated on the web page.)
- Adding and removing are separate actions for targets (`lb:AddTarget`, `lb:RemoveTarget`),
  services (`lb:AddService`, `lb:DeleteService`) and rules (`lb:AddRule`, `lb:RemoveRule`). Someone
  can be allowed to take a broken backend out of rotation without being allowed to add one.
- Renewing a certificate now needs `lb:UpdateService`.
- Attaching a web ACL needs `lb:SetWebAcl` and `waf:GetWebAcl` on the ACL. The console's list of
  ACLs also needs `waf:ListWebAcls`.
- The console's pages of a load balancer need `lb:DescribeLoadBalancers` on it; without it they
  answer 404, so they do not tell whether the id exists.
- A load balancer another service owns (a database's, cache's, broker's or MySQL cluster's
  endpoint, or a Kubernetes Service's) is refused with `409` for every change here except renewing
  a certificate, whatever your permissions.

## Audit

Creating and deleting load balancers, adding and removing targets, services and rules, changing a
service, renewing a certificate and setting the web ACL are recorded in the audit log, allowed or
denied. Reads are not recorded when allowed. See [Audit log](/docs/audit-log).

## Certificates and keys

- `lb11`–`lb31`: an uploaded private key is handed to the provider and not stored by Deutsche Cloud.
- `application` and `dedicated`: the private key of an uploaded certificate (and, on
  `application`, of one Deutsche Cloud issues) is stored sealed under the KMS master key and opened
  only to configure the fleet.
- The API never returns a private key in the clear. On `lb11`–`lb31` it does not return an
  uploaded certificate either; on `application` and `dedicated`, reading the load balancer returns
  each https service's certificate (`certificatePem`).
- The console's **Add service** form does not keep the private key in its saved draft.

## Traffic to your targets

- An `https` service sends plain HTTP to the targets; there is no re-encryption. For TLS to the
  targets, use a `tcp` service and end TLS on them (`lb11`–`lb31` and `dedicated`; `application`
  has no `tcp`).
- `application` load balancers share their source addresses with other organizations' load
  balancers. Every request carries `X-EWS-LB-Token` with your load balancer's origin token (on its
  **Overview** tab, **Origin token**); check it on your targets to accept your load balancer's
  traffic only. `dedicated` http and https services send the header too (the token is the load
  balancer's `originToken` in the API).
- `application` and public `dedicated` load balancers refuse targets at private, reserved or
  platform addresses.

## Related

- [Protect an application load balancer with a web ACL](protect-with-a-web-acl.md)
- [Use your own certificate](upload-a-certificate.md)
