Guides · Security
Compliance and security operations
Controls and framework mapping, evidence, key management, retention, data-subject requests, organization deletion, residency, incidents and SIEM.
Note
This page is the repository's compliance documentation (docs/compliance/README.md), published as-is. The
endpoints it references are in the control-plane API reference,
incidents and SIEM.
This is the compliance documentation foundation for GebSecure (EPIC 28). It describes the controls the platform implements, how evidence is produced, and how customer data is governed.
Status: each control below is implemented and covered by automated tests (test/compliance.int.test.ts and the suites it cites). None of this is a SOC 2 / ISO 27001 attestation. An attestation needs an independent auditor, organizational policies and an operating period; see Gaps.
- Control catalog and framework mapping
- Evidence collection
- Encryption and key management
- Data governance
- Data residency
- Incident response
- SIEM integration
- API reference
Control catalog and framework mapping#
Controls are defined in packages/core/src/compliance/controls.ts. Each one is evaluated against the organization's live configuration and records, not self-attested. The result is pass, fail or not_applicable, with the observed facts attached.
| Control | Title | SOC 2 | ISO 27001:2022 | NIST 800-53 r5 |
|---|---|---|---|---|
| GS-IAM-01 | Multi-factor authentication for human access | CC6.1 | A.5.17, A.8.5 | IA-2(1), IA-2(2) |
| GS-IAM-02 | Centralized identity (SSO) and automated provisioning | CC6.1, CC6.2 | A.5.16, A.5.18 | AC-2, IA-2 |
| GS-IAM-03 | Periodic access reviews | CC6.2, CC6.3 | A.5.18 | AC-2(3), AC-6(7) |
| GS-IAM-04 | Separation of duties | CC6.3 | A.5.3 | AC-5 |
| GS-IAM-05 | Two-person rule for administrative changes | CC8.1, CC6.3 | A.8.32, A.5.3 | AC-3(2), CM-5 |
| GS-IAM-06 | Network access restriction | CC6.6 | A.8.20 | AC-17, SC-7 |
| GS-AUD-01 | Tamper-evident audit logging | CC7.2 | A.8.15 | AU-2, AU-9, AU-10 |
| GS-AUD-02 | Audit log retention | CC7.2 | A.8.15, A.5.33 | AU-11 |
| GS-AUD-03 | Security monitoring export (SIEM) | CC7.2, CC7.3 | A.8.16 | AU-6, SI-4 |
| GS-CRY-01 | Encryption of sensitive data at rest under the current key | CC6.1, CC6.7 | A.8.24 | SC-12, SC-28 |
| GS-CRY-02 | Credential rotation | CC6.1 | A.5.17, A.8.24 | IA-5(1), SC-12 |
| GS-AGT-01 | Least-privilege authorization for agents | CC6.1, CC6.3 | A.5.15, A.8.2 | AC-3, AC-6 |
| GS-AGT-02 | Human approval for high-risk agent actions | CC8.1 | A.8.32 | AC-3(2) |
| GS-AGT-03 | Adversarial security evaluation | CC4.1, CC7.1 | A.8.29 | CA-2, CA-8 |
| GS-DLP-01 | Data loss prevention | CC6.7, C1.1 | A.8.12 | SC-7(10), AC-4 |
| GS-INJ-01 | Prompt-injection defense | CC6.8, CC7.1 | A.8.7 | SI-3, SI-10 |
| GS-MON-01 | Security alert routing | CC7.3, CC7.4 | A.5.25, A.6.8 | IR-6, SI-4(5) |
| GS-IR-01 | Incident response | CC7.4, CC7.5 | A.5.24, A.5.26, A.5.27 | IR-4, IR-6, IR-8 |
| GS-RET-01 | Data retention and minimization | C1.2, P4.2 | A.5.33, A.8.10 | SI-12 |
There are two views:
GET /v1/compliance/controlslists the controls with their status.GET /v1/compliance/controls?framework=soc2|iso27001|nist80053regroups them by framework requirement. A requirement passes only when every control mapped to it passes.
To add a control, add an entry to CONTROLS with an evaluate(tx) function that reads real state. Then add a test that flips the control between fail and pass.
Evidence collection#
Evidence is stored in compliance_evidence and comes from two sources:
- On demand:
POST /v1/compliance/evidence/collect. - Scheduled: the worker loop
compliance-evidencecollects daily for every active org.
Each collection writes three items:
| Kind | Content |
|---|---|
control_snapshot |
Every control's status and observed facts. |
encryption_report |
The encryption inventory (see below). |
audit_verification |
A full re-verification of the org's audit hash chain, from the earliest retained record or retention checkpoint. |
POST /v1/compliance/reports also stores a Markdown security report as security_report evidence.
Integrity is protected in two ways:
- Sealed: each item stores
sha256over the canonical JSON of{payload, body}.GET /v1/compliance/evidence/:idrecomputes the seal and returnsintact. Tampering by a privileged actor is detectable. - Append-only for the runtime: the application role
gebsecure_apphasUPDATE,DELETEandTRUNCATErevoked oncompliance_evidence(packages/db/sql/grants.sql). Evidence can only be removed when the whole organization is purged, by the owner role.
Encryption and key management#
At rest, every sensitive value uses envelope encryption:
- AES-256-GCM.
- A per-record data key.
- The data key is wrapped by the KMS key-encryption key (KEK).
- An encryption context (AAD) binds the ciphertext to its org and record.
Ciphertext moved to another row or tenant fails to decrypt.
Encrypted columns are listed in one registry, ENVELOPE_COLUMNS in packages/core/src/compliance/encryption.ts:
| Data class | Table.column |
|---|---|
| Vault secret | secret_versions.envelope |
| Webhook signing secret | webhook_endpoints.secret |
| Request signing secret | connections.signing_secret |
| OAuth PKCE verifier | oauth_states.code_verifier |
| Execution input | executions.input_envelope |
| Notification channel secret | notification_channels.secret |
| SSO client secret | sso_connections.secret_envelope |
| Browser screenshot | browser_artifacts.envelope |
| MFA TOTP secret (user-global) | user_mfa.totp_envelope |
A new encrypted column must be registered there, or it will not be inventoried or rotated.
Other secret material:
- Passwords use scrypt.
- Bearer secrets (API keys, agent client secrets, SCIM tokens) are stored as SHA-256 hashes.
KMS providers: local, AWS KMS, GCP KMS and Azure Key Vault (KMS_PROVIDER).
- The local provider takes
MASTER_KEY=v2:<b64>,v1:<b64>. The first key is current; the others remain available for unwrapping. - In development, a key is generated once under
.gebsecure/. This uses an atomic create-if-absent, so concurrently starting services share it.
Rotating the KEK:
- Make the new key current, keeping the old one available. For local KMS, prepend it to
MASTER_KEY; for a cloud KMS, rotate the key there. - The
kms-rewrapworker loop re-wraps every data key that is not on the current KEK, across all registered columns. It runs every 5 minutes in batches and is idempotent. Data is never decrypted; only data keys are re-wrapped. - When
GET /v1/compliance/encryptionreportsstaleRecords: 0for every org, retire the old key. Control GS-CRY-01 fails while stale records exist.
compliance.rewrapAll(s, { orgId }) performs a tenant-scoped rotation.
In transit: connector traffic requires TLS in production and staging. HTTP is allowed only in development, and the inventory reports which policy is in force. Outbound calls go through safeFetch, which pins resolved addresses and refuses private networks unless explicitly allowed.
Data governance#
Retention#
| Policy | Default | Minimum |
|---|---|---|
Audit log (settings.auditRetentionDays) |
365 days | 30 days |
Traces (settings.traceRetentionDays / TRACE_RETENTION_DAYS) |
config | — |
| Executions (terminal) | 90 | 7 |
| DLP events | 180 | 7 |
| Injection detections | 180 | 7 |
| Risk assessments | 90 | 7 |
| Database-gateway queries | 180 | 7 |
| MCP calls | 90 | 7 |
| Simulation runs | 365 | 7 |
| Closed alerts | 365 | 30 |
| Closed approvals | 365 | 30 |
Retention is enforced by the worker's retention loop, per org.
- Operational tables:
GET/PATCH /v1/compliance/retention. - Audit log: expiry deletes from the head of the chain only after writing an
audit_checkpointsrow. The remaining chain therefore still verifies. Only the table owner, with the retention bypass flag, can delete audit rows.
Data-subject requests#
POST /v1/compliance/data-requests/exportreturns what this organization holds about a member: profile, membership, teams, project roles, linked SSO identities, API key metadata (never secrets), owned agents, approval decisions and audit activity.POST /v1/compliance/data-requests/erasureremoves the subject from the organization:- deletes the membership, team memberships, project role bindings and linked SSO identities;
- revokes the subject's API keys in this org;
- clears agent ownership.
- The last owner cannot be erased, and an actor cannot erase themselves.
- If the subject belongs to no other organization, the account itself is anonymized (
gs_user_anonymize):- the email becomes
erased+<id>@invalid.gebsecureand the name is cleared; - the password and MFA factors are removed;
- all sessions are revoked;
- the account is disabled.
- the email becomes
- Audit records keep the opaque user id, which no longer resolves to personal data. Retaining them is the integrity exception for security logs.
Requests are recorded in data_requests and audited.
Organization deletion#
- Request:
POST /v1/org/deletion(owner only, with the org slug confirmed). The org enterspending_deletion:- API keys and agent/service credentials are revoked immediately;
- humans can only cancel or export data (
org_pending_deletionon everything else).
- Grace period: 30 days.
DELETE /v1/org/deletioncancels it. - Purge: the
org-purgeworker loop deletes every row in every table that has anorg_idcolumn, including the audit chain and evidence, plus the org's Redis keys. - Certificate: a deletion certificate (org id, SHA-256 of the slug, rows deleted per table, timestamps and a SHA-256 of the certificate body) is written to
deletion_certificates. The application role cannot read or modify this table.
Data residency#
Each organization has an immutable region. Every deployment runs with REGION.
authenticate()refuses any principal whose org resides in another region:403,reason: wrong_region, with the home region indetails. A request routed to the wrong regional endpoint therefore never reads or writes that tenant's data.POST /v1/orgsonly creates orgs in the deployment's own region (the default whenregionis omitted).REGION=localdisables both checks for single-region self-hosting.- Regions offered at sign-up:
GET /v1/regionslists this deployment's region and the other regional deployments inOTHER_REGIONS(code=consoleUrl). The sign-up page offers only those, so a region without a deployment is never offered. GebSecure Cloud currently runs one region:us(AWS us-east-1). - Deployment model: one independent stack (database, Redis, KMS key, object storage) per region. There is no cross-region replication of tenant data. Global DNS/routing sends users to their region's endpoint. See
docs/operations/deployment.mdandinfra/terraform.
Incident response#
Incident records live in incidents, incident_events and incident_links.
- Severities:
sev1–sev4. - Lifecycle:
open → investigating → contained → resolved → closed. Transitions are enforced. - Timeline: an append-only event timeline holds notes, status changes, links and notifications. Incidents can link to alerts, executions, approvals and other records.
- Personal data breach: sets a regulator-notification deadline 72 hours after declaration (GDPR Art. 33). The incident cannot be closed until
notifiedAtis recorded. - Closing: requires a post-incident review (impact, root cause, remediation, lessons learned). Closed incidents are immutable.
- Metrics: mean time to contain and resolve, plus breaches past deadline. They feed control GS-IR-01.
SIEM integration#
POST /v1/siem/destinations configures continuous export of the org's audit stream:
| Type | Transport | Auth |
|---|---|---|
splunk_hec |
HEC event endpoint, one JSON event per line | Splunk <token> from a vault secret |
datadog |
Logs intake | DD-API-KEY from a vault secret |
elastic |
_bulk with create and the audit id as _id (idempotent; replays return 409 and are tolerated) |
ApiKey from a vault secret |
webhook |
JSON batch | x-gebsecure-signature: sha256=<HMAC> when a secret is set |
Formats:
ocsf: OCSF 1.1 (Authentication 3002, Account Change 3001, API Activity 6003, and others). This is the default.native: the raw audit record.
Category filter: optional.
Delivery:
- The
siem-exportworker uses a per-destination cursor on the audit sequence. Delivery is ordered and at-least-once. - On failure, the destination is marked
failingwith exponential backoff and resumes from the cursor. lagshows how many events are pending.
Security of the exporter:
- Tokens are read through
useSecretunder a system actor and never appear in responses or logs. - The exporter's own
secret.useaudit events are excluded from the stream; otherwise it would feed itself. - Endpoints pass the same SSRF policy as connectors.
- Permission is checked before any URL is resolved.
API reference#
All routes are under /v1, require authentication, and appear in docs/openapi/api.json (tag compliance).
| Permission | Granted to |
|---|---|
compliance:read |
owner, admin, auditor |
compliance:manage |
owner, admin |
incidents:manage |
owner, admin |
audit:configure (SIEM) |
owner, admin |
Organization deletion is owner-only.
Gaps toward an attestation#
- Organizational policies (HR security, vendor management, BCP) and their operating evidence are outside the product.
- Independent audit and penetration test reports: see EPIC 36 in
docs/tracker. - Datadog delivery is implemented to the documented intake contract but has not been tested against a live Datadog account. Splunk HEC, Elastic
_bulkand webhook delivery are tested against local protocol-faithful servers.