# Security Center

The Security Center is one page in the kosa8 Cloud dashboard (**Access → Security Center** at app.kosa8.com), the same thing in the CLI (`kosa8 cloud security`, `agents`, `freeze`, `siem`, `evidence`) and a **Cloud Security** panel in the desktop app's Account view. It reads your organization's own settings, API keys and [audit log](https://docs.kosa8.com/guides/audit/). It does not certify anything: the checklist is a self-check for you to act on, and the evidence file is your own record for your own review or your auditor's.

## Posture checklist

Each check passes, fails, or does not apply, and names the dashboard page that changes it. The score is the number that pass out of the number that apply, for example `7 / 12`. There is no letter grade.

| Check | Passes when |
|---|---|
| Single sign-on is connected | An OIDC or SAML 2.0 connection is set up (Team & SSO). |
| Dashboard sign-in requires SSO | “Require SSO for the dashboard” is on. |
| An email domain is verified | At least one SSO domain is verified by its DNS TXT record. |
| A named person is an owner | At least one member has the owner role, so the org is not run only from a shared admin key. |
| Few people hold owner or admin | Owners plus admins are at most half the members, or at most two. Does not apply with no members. |
| At most 2 live admin keys | No more than two unrevoked, unexpired API keys have the `admin` scope. |
| No key older than 90 days | Every live key was made (or rotated) in the last 90 days. |
| No key unused for 30 days | Every live key was used, or made, in the last 30 days. |
| Non-admin keys have an end date | Every live key without `admin` has an expiry. |
| A monthly spending cap is set | Settings has a spending cap. |
| The audit log's hash chain verifies | `GET /v1/audit/verify` finds no edited, removed or reordered event. |
| The audit log left kosa8 in the last 30 days | An NDJSON export or an evidence export in the last 30 days, or a working SIEM destination. |
| The audit log streams to a SIEM | At least one SIEM destination whose last delivery succeeded. |

Not checked, and said so on the page: kosa8 Cloud has no built-in multi-factor sign-in (require SSO and use your identity provider's MFA), and network rules (set the default for new sandboxes, and whether it is enforced, under **Organization settings, Network default**).

```
curl -s https://api.kosa8.com/v1/security/posture -H "Authorization: Bearer $KOSA8_API_KEY"
# {"score":{"passed":7,"total":12},"frozen":false,"items":[{"id":"sso_connected","area":"Identity",
#   "title":"Single sign-on is connected","ok":false,"detail":"…","fix":{"tab":"team","label":"Set up SSO"}},…]}
```

Reading it needs the owner or admin role, or a key with `audit:read`.

## Agent inventory

Every API key (an agent's, a CI job's or a person's) and every member, with its scopes or role, its state (`active`, `suspended`, `expired`, `revoked`), when it was last used, and the sandboxes and functions it made. Who made what comes from the audit log's successful `sandbox.create`, `sandbox.fork` and `function.deploy` events; anything made before the audit log, or by a key revoked more than 30 days ago, is listed as unattributed. Revoke ends a key at once through the usual `DELETE /v1/api-keys/{id}`.

```
$ kosa8 cloud agents
$ kosa8 cloud agents --revoke key_…
```

## Kill switch: freeze the organization

An owner or admin can freeze the organization, for example when a key may have leaked or an agent is doing something it should not. You type the organization's name to confirm (the CLI asks for it unless you pass `--yes`). A freeze:

- refuses new sandboxes, commands, wakes, forks, file writes, function calls and deploys, new keys and key rotation, with `423` and `{"error":"org_frozen"}`, scheduled and web-endpoint function calls included;

- puts every running sandbox to sleep through the normal sleep path (state kept, nothing deleted). A host that does not answer is retried by the minute tick until it does;

- with `suspend_keys`, suspends every live API key except the one making the call. A suspended key answers `401 key_suspended`. Members' dashboard sessions keep working, so someone can always unfreeze.

While frozen, reads and incident response still work: revoking keys, adding, demoting or removing members, changing SSO and settings, deleting or sleeping sandboxes, deleting functions and webhooks, and the Security Center itself. Function invocations already running when the freeze lands are not cut short.

Unfreezing restores the keys the freeze suspended, unless you ask it not to. Sandboxes stay asleep until woken; their next command wakes them. Both actions are in the audit log as `security.freeze` and `security.unfreeze`, with the reason, how many keys were suspended or restored and how many sandboxes were put to sleep; every refused call is recorded too.

```
curl -s -X POST https://api.kosa8.com/v1/security/freeze -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d '{"confirm":"Acme Inc","reason":"key in a public repo","suspend_keys":true}'
curl -s -X POST https://api.kosa8.com/v1/security/unfreeze -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d '{"confirm":"Acme Inc"}'   # "restore_keys":false keeps them suspended
```

```
$ kosa8 cloud freeze --reason "key in a public repo" --suspend-keys
$ kosa8 cloud unfreeze
```

When an event is in the log: sign-ins, keys, members, settings, billing and Security Center actions are in it before their call answers. Sandbox, function, job and other high-volume events are written in batches and appear within a few seconds of the call (longer only while kosa8 Cloud's database is overloaded); none is dropped, and each is chained once. An event's `seq` is the order it entered the chain, which follows the order of `at` except for events a second or two apart from different requests.

## SIEM streaming

Every audit event, in order, to up to five destinations per organization. The minute tick sends the events after each destination's cursor, up to 100 per request and 500 per minute, and moves the cursor only when the destination answers `2xx`. A failure is retried after 1, 5 and 15 minutes, then hourly, and the stream resumes where it stopped: no event is skipped. Redirects are not followed, and URLs must be public `https`. Owners and admins manage destinations.

| Kind | Request |
|---|---|
| `webhook` | `POST` of `{"org_id","destination_id","events":[…]}` with `Kosa8-Signature: t=<unix s>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>`, as the [event webhooks](https://docs.kosa8.com/guides/cloud-webhooks/) sign. The `whsec_…` secret is shown once. |
| `splunk_hec` | Your HEC URL with `Authorization: Splunk <token>`; one `{"time","host","source","sourcetype","index"?,"event"}` object per line. `sourcetype` defaults to `ocsf:api_activity`. |
| `datadog` | `https://http-intake.logs.<site>/api/v2/logs` with `DD-API-KEY`; a JSON array of `{"ddsource":"kosa8","service":"kosa8-cloud","message","ocsf"}`. Sites: datadoghq.com, us3, us5, datadoghq.eu, ap1, ap2, ddog-gov.com. |
| `s3` early access | A `PUT` of one object per batch to your own Amazon S3 bucket, or any S3-compatible store, signed with SigV4. Fields: `bucket`, `region` (default `us-east-1`), `endpoint` (optional, the `https` address of an S3-compatible store), `access_key_id`, `secret_access_key` (a key that may write to the bucket), and `prefix` (default `kosa8-audit/`). |
| `r2` early access | The same, to a Cloudflare R2 bucket in your own Cloudflare account. Fields: `bucket`, `account_id` (32 hex characters), `jurisdiction` (optional, `eu` or `fedramp`), `access_key_id`, `secret_access_key` (an R2 API token's S3 credentials) and `prefix`. |

An `s3` or `r2` object is NDJSON, one OCSF event per line, at `<prefix><org_id>/YYYY/MM/DD/<first seq>-<last seq>.ndjson`. A retried batch writes the same key, so a retry never duplicates an object. Failed writes are retried like the others, after 1, 5 and 15 minutes and then hourly. The web app's **Security** page shows each destination's last delivery and error, and its **Send test** button sends one test event (for a bucket, a test object).

Tokens and API keys are stored encrypted and never returned by the API. Each event is OCSF API Activity (`class_uid` 6003, `category_uid` 6): `activity_id` from the action's verb (1 create, 2 read, 3 update, 4 delete, 99 other), `status_id` 2 with `status_code` for a refused call, `time`, `actor.user` (a member, an API key or the system), `api.operation` (the audit action, e.g. `sandbox.exec`), `resources`, and `metadata.uid` `org:seq`. kosa8 Cloud does not record client IP addresses, so `src_endpoint` carries only the channel (`key`, `session`, `sso`, `system`). The original event, its detail and its chain hashes are in `unmapped`.

```
curl -s -X POST https://api.kosa8.com/v1/security/siem -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"kind":"splunk_hec","url":"https://splunk.example.com:8088/services/collector/event","token":"…","index":"security"}'
# start: "beginning" (default, sends the whole log first) or "now"
curl -s -X POST https://api.kosa8.com/v1/security/siem -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"kind":"s3","bucket":"acme-audit","region":"eu-west-1","access_key_id":"AKIA…","secret_access_key":"…"}'
curl -s -X POST https://api.kosa8.com/v1/security/siem/siem_…/test -H "Authorization: Bearer $KOSA8_API_KEY"
```

```
$ KOSA8_SIEM_TOKEN=… kosa8 cloud siem add --kind datadog --site datadoghq.eu
$ KOSA8_SIEM_TOKEN=… kosa8 cloud siem add --kind r2 --bucket audit --account-id 0123…cdef --access-key-id …
$ kosa8 cloud siem ls
$ kosa8 cloud siem test siem_…
```

## Evidence export

**Download evidence** (or `kosa8 cloud evidence export`, or `GET /v1/security/evidence?since=&until=`) saves one JSON file: the posture checklist, the audit chain's verification, and the audit events in the range (default the last 90 days, at most 20,000 events, with `truncated` set past that).

```
{"content":{"format":"kosa8.evidence.v1","statement":"…","org":{…},"range":{…},"posture":{…},
  "audit":{"chain":{"ok":true,…},"count":412,"truncated":false,"events":[…]}},"sha256":"9f2c…"}
```

`sha256` is the SHA-256 of `content` as served: canonical JSON, object keys sorted and no spaces, the same form the audit chain hashes. The CLI checks it before saving. To check it yourself:

```
python3 -c 'import json,hashlib,sys; f=json.load(open(sys.argv[1]));
c=json.dumps(f["content"],sort_keys=True,separators=(",",":"),ensure_ascii=False);
print(hashlib.sha256(c.encode()).hexdigest()==f["sha256"])' kosa8-evidence-….json
```

Each export is recorded in the audit log as `security.evidence_export`, with its hash. The file is generated by kosa8 Cloud from your organization's own data; it is not a certification, an attestation or an audit opinion.

## Single sign-on and provisioning

An organization connects one identity provider, by **OpenID Connect** or **SAML 2.0**, and can add **SCIM 2.0** provisioning on top. Okta, Microsoft Entra ID, Google Workspace, OneLogin, JumpCloud and other providers that speak either protocol work. Only an owner can change the connection, the SCIM token or the group mapping. Every sign-in and every SCIM change is in the [audit log](https://docs.kosa8.com/guides/audit/).

- **Verified domains.** People sign in, and SCIM provisions them, only with an email address in a domain the organization has verified with a DNS TXT record (`_kosa8.<domain>`). A domain can be verified by one organization only.

- **Just-in-time.** With it on, someone new is added with the default role at first sign-in; with it off, only invited or SCIM-provisioned members get in.

- **Require SSO.** Turns off password and API-key sign-in to the dashboard. Admin API keys still work against the API, which is how SSO is switched off again if the provider is ever down.

### SAML 2.0

Service-provider-initiated Web Browser SSO: kosa8 sends an AuthnRequest by HTTP-Redirect and the provider posts its Response to the ACS URL. The Response must be signed (the assertion, the response, or both) with RSA and SHA-256 or SHA-512, by one of the one or two certificates you pinned (two while rotating). SHA-1 is refused, as are encrypted assertions (turn assertion encryption off), DTDs, comments and more than one assertion. kosa8 checks the issuer, audience, recipient, destination, time window (with three minutes of clock skew), that the Response answers a sign-in this browser started in the last ten minutes, and that its assertion was not used before. The email is taken from an email attribute, else from a NameID in the `emailAddress` format. That email decides which member signs in, so map it from the directory's primary email, never from a profile field users can edit. Sign-in from the provider's app tile (IdP-initiated) is off unless you turn on *Allow IdP-initiated*; when on, a tile click starts an ordinary SP-initiated sign-in rather than signing in from the unsolicited Response.

| In the IdP | Value |
|---|---|
| Single sign-on URL / ACS URL / Reply URL | `https://app.kosa8.com/auth/saml/acs` |
| Audience URI / SP entity ID / Identifier | `https://app.kosa8.com/auth/saml/metadata?org=org_…` (your org id; Team & SSO shows it) |
| SP metadata | the same URL; the IdP can read it |
| Name ID format | `EmailAddress` |
| Signing | sign the assertion (or the response) with SHA-256; no encryption |

**Okta.** Applications → Create App Integration → SAML 2.0. Set the Single sign-on URL and Audience URI above, Name ID format *EmailAddress*, Application username *Email*, and add an attribute statement `email` = `user.email` (and `firstName`, `lastName` if you like). Leave the response and assertion signed with RSA-SHA256. On the app's Sign On tab, copy the metadata URL, and in kosa8 Cloud paste it as the IdP metadata URL (or paste the metadata XML). Assign the people or groups who should have access.

**Microsoft Entra ID.** Enterprise applications → New application → Create your own application (non-gallery) → Single sign-on → SAML. Set Identifier (Entity ID) and Reply URL (ACS) above. Under Attributes & Claims keep `emailaddress` = `user.mail`: kosa8 uses that claim, not the user principal name, since a UPN is not always a mailbox. Under SAML Certificates, the signing option *Sign SAML assertion* with SHA-256 is the default. Copy the *App Federation Metadata Url* into kosa8 Cloud. Assign users and groups. When Entra rotates its certificate, add the new one beside the old one, then remove the old one after the switch.

```
curl -s -X PUT https://api.kosa8.com/v1/sso -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"protocol":"saml","idp_metadata_url":"https://login.microsoftonline.com/…/federationmetadata/2007-06/federationmetadata.xml?appid=…",
       "domains":["acme.com"],"default_role":"developer","jit":true}'
# or "idp_entity_id", "idp_sso_url" and "idp_certificates": ["-----BEGIN CERTIFICATE-----…"]
```

### SCIM 2.0

The provider creates, updates, deactivates and deletes members at `https://app.kosa8.com/scim/v2` (Users and Groups; filters of the form `userName eq "…"`, paging with `startIndex` and `count`, PATCH as Okta and Entra send it). Make the bearer token under Team & SSO, or with `POST /v1/sso/scim-token`; it is shown once and only its hash is kept. Making a new one stops the old one at once, so rotate by making one and pasting it into the provider. Requests are limited to 600 a minute per token.

- **Deactivating or deleting a user** removes the member at once: their dashboard sessions end and every API key bound to them is revoked. A deactivated user stays readable, so the provider can reactivate them.

- **Roles.** With a group mapping (for example `{"Engineering":"admin","Contractors":"viewer"}`), a member gets the highest role of the mapped groups they are in, or the default role. Without one, a `roles` value of `admin`, `developer` or `viewer` sets the role, and new members otherwise get the default role. A role change revokes the member's keys.

- **Owners.** SCIM never makes anyone an owner and never changes an owner's role or email (403). It can remove a departing owner, but never the last one (409): make someone else owner first.

**Okta.** On the SAML or OIDC app's General tab, enable SCIM provisioning. Under Provisioning → Integration: SCIM connector base URL `https://app.kosa8.com/scim/v2`, unique identifier field `userName`, actions *Push New Users*, *Push Profile Updates* and *Push Groups*, authentication mode *HTTP Header* with the token. Then under To App enable Create Users, Update User Attributes and Deactivate Users.

**Microsoft Entra ID.** In the same enterprise application, Provisioning → Automatic. Tenant URL `https://app.kosa8.com/scim/v2`, Secret Token the token, then Test Connection. In the user mapping, keep `emails[type eq "work"].value` = `mail`, since it is the member's address. Start provisioning; Entra syncs about every 40 minutes.

```
curl -s -X POST https://api.kosa8.com/v1/sso/scim-token -H "Authorization: Bearer $KOSA8_API_KEY"
# {"base_url":"https://app.kosa8.com/scim/v2","scim_token":{"id":"scim_…","secret":"k8c_scim_…",…},"replaced":0}
curl -s -X PUT https://api.kosa8.com/v1/sso -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d '{"scim_group_roles":{"Engineering":"admin","Contractors":"viewer"}}'
```

Not supported yet: SAML single logout, signed AuthnRequests, encrypted assertions, SCIM bulk operations, sorting and ETags.

## API

| Route | Scope |
|---|---|
| `GET /v1/security/posture` | `audit:read` |
| `GET /v1/security/inventory` | `audit:read` |
| `GET /v1/security/evidence` | `audit:read` |
| `GET /v1/security/freeze` | any key of the org |
| `POST /v1/security/freeze`, `/unfreeze` | `admin` (owners and admins) |
| `GET`, `POST /v1/security/siem`, `DELETE /v1/security/siem/{id}`, `POST …/{id}/test` | `admin` |
| `GET /v1/sso` | `admin` |
| `PUT`, `DELETE /v1/sso`, `POST /v1/sso/domains/{domain}/verify`, `GET`, `POST`, `DELETE /v1/sso/scim-token` | `admin`, owners only |
| `/scim/v2/…` | the SCIM token |

---
Source: https://docs.kosa8.com/guides/cloud-security/
