# Security

> What an installation exposes on the network, where its secrets are kept, how to recover sign-in and how to clear a network list that locks everyone out, on a single host and on Kubernetes.

Source: https://docs.corfedo.ai/operate/security/

This page covers what the operator controls on the host or the cluster. Workspace administrators control sign-in, client access and network lists in **Settings**.

## Network exposure

**Single host**

| Port or address | Served by | Who needs it |
| --- | --- | --- |
| 443, or the `--port` you chose | Caddy, for the workspace address and, with the bundled account service, `auth.<workspace address>` | Browsers, coding agents, the CLI and SDKs |
| 80 | Caddy, with `--tls acme` only | Let's Encrypt, to issue and renew the certificate |

The installer listens on `127.0.0.1` for `.localhost` names and on every address otherwise. Choose another with `--bind`. PostgreSQL, the account service's database and the search engine are reachable only inside the installation's Docker network.

**Kubernetes**

The ingress is the only public entry. It sends each path of the workspace address to a role. The NetworkPolicies admit public requests only from the peers that `networkPolicy.ingressFrom` names, your ingress controller's pods or your load balancer's subnets, when the cluster's network plugin enforces NetworkPolicy. They do not limit outbound connections, see [Routing](https://docs.corfedo.ai/operate/kubernetes/routing/#outside-services).

The installation needs outbound HTTPS to download releases and images, to reach the forges and AI providers your workspaces use, and to fetch the identities of MCP clients and the CLI from `clients.corfedo.ai` and the clients' own hosts.

## Where secrets are kept

**Single host**

| Where | What |
| --- | --- |
| `.env` | Generated database passwords |
| `generated/` | Signing and encryption keys, the workload CA and certificates, the setup secret, the account service's client secrets |
| `backups/` | Recovery sets, which contain both |

Limit the installation directory to the operator.

**Kubernetes**

The Secrets in the release's namespace hold the database passwords, the encryption key (`corfedo-keys`), the token signing keys (`corfedo-oauth`), the setup secret, the bucket's access keys and an HTTPS certificate that `ingress.tls` names. Whoever can run `kubectl exec` in the toolbox pod acts on the database as Corfedo and reads the keys. Limit both to the operator, and keep copies of `corfedo-keys` and `corfedo-oauth` with your backups.

Forge credentials, AI provider credentials, sign-in client secrets and Slack app secrets that administrators save in **Settings** are stored in the database, encrypted with the installation's encryption key.

## Audit log retention

The audit log keeps each sign-in and change with the network address and browser until you set a limit in [installation settings](https://docs.corfedo.ai/operate/settings/). Administrators see the limit in **Settings** › **Privacy**.

## Recover sign-in

When sign-in breaks at the identity provider and no administrator can sign in, issue a recovery link:

**Single host**

```sh
sh ~/corfedo/install.sh recover-sign-in
```

**Kubernetes**

```sh
kubectl exec --namespace corfedo deployment/corfedo-toolbox -- dotnet Corfedo.Host.dll recovery issue
```

With more than one workspace, add `--workspace` and the workspace's address, such as `--workspace acme`.

It prints a single-use link, valid for 30 minutes. Open it in a browser to repair the sign-in connections and appoint an administrator. Issuing the link is recorded in the audit log.

## Clear a network list

A workspace administrator can limit where the workspace is used from in **Settings** › **Network access**. Corfedo refuses a list that leaves out the saving administrator's own address, but a network change can still lock every administrator out. Clear the list:

**Single host**

```sh
sh ~/corfedo/install.sh clear-network-list
```

**Kubernetes**

```sh
kubectl exec --namespace corfedo deployment/corfedo-toolbox -- dotnet Corfedo.Host.dll network-policy clear
```

With more than one workspace, add `--workspace` and the workspace's address.

It prints the removed list.

**Check:** administrators can sign in from any network. The workspace's audit log records the change as an operator command.

## Related

- [Reverse proxy](https://docs.corfedo.ai/operate/single-host/reverse-proxy/#set-the-trusted-proxy) explains which client address Corfedo sees on a single host, [Routing](https://docs.corfedo.ai/operate/kubernetes/routing/#trusted-proxy) on Kubernetes.
- [Certificates and trust](https://docs.corfedo.ai/operate/single-host/certificates-and-trust/).
