GebSecure Docs v0.1.0

Guides · Security

Credential broker and vault

Write-only secrets, envelope encryption, connections and how the broker executes actions without ever giving agents a credential.

Agents never receive credentials for the systems they act on. Secrets live in the vault, envelope-encrypted; connector code runs in a sandbox that cannot open network connections itself; the credential broker performs every outbound request, enforces the allowed hosts and injects the credential (ADR 0009).

Secrets#

Secret values are write-only: no API returns them (GET /v1/secrets lists metadata and masks only) and the SDKs never log them. Plaintext reaches only in-process runtime code, after the status, expiry, scope and access policy checks, and every use is audited (secret.use).

POST /v1/secrets (permission secrets:write):

Field Notes
name ^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,127}$; the most specific of environment, project and organization scope wins when resolving by name
type api_key, oauth_token, database, certificate, cloud, ssh_key, generic
value per type: api_key {key, header?, prefix?, queryParam?}; oauth_token {accessToken, refreshToken?, tokenType?, expiresAt?, scope?, clientSecret?, assertionKey?}; database {username, password, connectionString?}; certificate {certPem, keyPem, caPem?, passphrase?}; cloud {provider: "aws", accessKeyId, secretAccessKey, sessionToken?} | {provider: "gcp", serviceAccountJson} | {provider: "azure", tenantId, clientId, clientSecret}; ssh_key {privateKey, passphrase?}; generic {value}
projectId, environmentId scope (organization when omitted)
accessPolicy {agents?, agentTags?, connectors?, actions?, environments?} — who may use the secret
expiresAt, rotationPolicy rotationPolicy: {intervalDays?, strategy: "manual" | "generate" | "oauth_refresh"}
description, metadata

Access policy: agents lists agent ids; agentTags requires one matching tag; connectors matches the connector key exactly; actions uses wildcard patterns; environments matches the environment slug or tier.

Operation Endpoint
New version (a value, or {generate: {length}} for generic/api_key, 16–128 bytes) POST /v1/secrets/{id}/rotate
Revoke one version or the whole secret POST /v1/secrets/{id}/revoke ({version?, reason?})
Update metadata, access policy, expiry, rotation policy, status (active/disabled) PATCH /v1/secrets/{id}
Delete DELETE /v1/secrets/{id}

Secret statuses are active, disabled, expired and revoked; version statuses active, superseded and revoked. The worker expires secrets every minute and refreshes OAuth tokens that expire within five minutes (authorization-code tokens with their refresh token; client-credentials and JWT-bearer installations by minting a new token), writing a new version each time.

From the CLI, values are read from stdin, a file or a hidden prompt — never echoed:

bash
gebsecure secrets create stripe-key --type api_key --from-file ./stripe.key
printf '%s' "$TOKEN" | gebsecure secrets create github-token --type oauth_token
gebsecure secrets rotate stripe-key

Envelope encryption and key management#

Each secret version is encrypted with a fresh 256-bit data key (AES-256-GCM); the data key is wrapped by the key-encryption key (KEK) of the configured KMS. The context {orgId, secretId, version, purpose: "vault"} is bound as additional authenticated data on both layers, so a ciphertext cannot be moved to another secret or organization (ADR 0010).

KMS_PROVIDER Settings
local (default) MASTER_KEY=v2:<base64>,v1:<base64> (first key active, each 32 bytes) or MASTER_KEY_FILE; generated under .gebsecure/ in development
aws KMS_KEY_ID, AWS_REGION (the context is the KMS encryption context)
gcp GCP_KMS_KEY_NAME (or KMS_KEY_ID)
azure AZURE_KEY_VAULT_URL, AZURE_KEY_NAME (or KMS_KEY_ID)

Staging and production refuse to start without a real key. KEK rotation re-wraps only the data keys: the worker's kms-rewrap loop re-wraps every registered envelope column every five minutes; retire the old key once GET /v1/compliance/encryption reports staleRecords: 0. See Compliance.

Connections#

A connection installs a connector from the catalog (GET /v1/connectors) into a project: POST /v1/connections (permission connectors:manage) with projectId, environmentId?, connector, name (^[a-z0-9][a-z0-9_-]{0,62}$), authType (default none), a vault secretId or an inline credential (stored as the secret connection/<name>, usable only by that connector), config, allowedHosts, signRequests, timeoutMs (default 15000, at most 120000) and maxRetries (0–5, default 2).

OAuth installations:

Flow Endpoints
Authorization code + PKCE POST /v1/connections/{id}/oauth/start → redirect the user to authorizationUrl → POST /v1/connections/oauth/callback with state and code (single-use state, 10 minutes)
Client credentials POST /v1/connections/{id}/oauth/client-credentials (clientId, clientSecret, scopes)
JWT bearer (RFC 7523, e.g. a Google service account) POST /v1/connections/{id}/oauth/jwt-bearer (serviceAccountJson, or issuer + privateKeyPem …)

POST /v1/connections/{id}/health runs the connector's health check through the broker with the real credential. The result says whether the credential was actually exercised: verified: true means the provider accepted an authenticated call (provider connectors such as Facebook call their "who am I" operation and return the account in identity, e.g. the Page's name and id). A connector without a live test returns ok: true, verified: false; the console shows that as not verified, never as healthy. A rejected credential (401/403) fails the check with the provider's explanation. The generic rest connector protects any HTTP API by declaring its operations in the connection's configuration; the example agents use it:

examples/shared/billing-connection.json
{
  "$comment": "Configuration of the 'billing-api' REST connection used by the example agents. Each operation becomes an action rest:<name>; contextFields are visible to policies as context.<field>. The provisioning scripts set baseUrl from BILLING_API_URL.",
  "baseUrl": "http://127.0.0.1:4300",
  "operations": [
    {
      "name": "refunds.create",
      "method": "POST",
      "path": "/v1/refunds",
      "inputSchema": {
        "type": "object",
        "required": ["chargeId", "amount"],
        "properties": {
          "chargeId": { "type": "string" },
          "amount": { "type": "number" },
          "currency": { "type": "string" }
        }
      },
      "bodyFields": ["chargeId", "amount", "currency"],
      "resource": "billing:charge/{chargeId}",
      "contextFields": ["amount", "currency"],
      "risk": { "category": "write", "sensitivity": 40, "financial": true }
    },
    {
      "name": "customers.delete",
      "method": "DELETE",
      "path": "/v1/customers/{customerId}",
      "inputSchema": {
        "type": "object",
        "required": ["customerId"],
        "properties": { "customerId": { "type": "string" } }
      },
      "resource": "billing:customer/{customerId}",
      "risk": { "category": "delete", "sensitivity": 70, "destructive": true }
    }
  ]
}

Execution#

POST {gateway}/v1/execute (permission execute) takes connection (id or name), action, input, idempotencyKey (8–200 characters), approvalId, mode (sync or async), timeoutMs (100–120000), dryRun, environmentId and onBehalfOf. The pipeline:

  1. authenticate; resolve the connection, connector and action; validate input against the action's schema;
  2. outbound DLP on the input (BLOCK → denied with dlp_blocked; REQUIRE_APPROVAL forces approval);
  3. authorize as <connector>:<action> on the resource the connector derives from the input, with risk;
  4. if approval is required, store the encrypted input and return awaiting_approval (HTTP 202);
  5. fetch the credential (access-policy checked, audited) and run the connector in a sandbox;
  6. sanitize the output, then inbound DLP and prompt-injection inspection (tool_output);
  7. audit and return the ExecuteResult.

The same idempotencyKey with the same request replays the original result (replayed: true); with a different request it is a conflict. dryRun returns simulated without side effects. HTTP status: 200 succeeded/simulated, 202 awaiting_approval/running, 403 denied, 502 failed (504 when it timed out).

Sandbox#

Connector code runs in a worker thread (EXECUTION_ISOLATION=worker, the default outside tests) with 128 MB old and 32 MB young generation heaps and a 4 MB stack, terminated on timeout or cancellation. fetch, WebSocket, EventSource and XMLHttpRequest are removed; the only I/O is message passing to the broker.

Broker#

  • Hosts: the union of the connector's allowed hosts, the connection's allowedHosts and — for connectors that derive hosts from configuration, like rest — the host of baseUrl. The environment setting blockedDestinations is a deny list. Credentials are injected only for credential hosts, never for a connector's public hosts.
  • Requests: authorization, cookie, proxy-authorization and x-gebsecure-* headers set by connector code are stripped; auth types none, api_key, bearer, basic, oauth2, aws_sigv4, custom_header; an idempotency-key header on non-GET requests; x-gebsecure-execution-id, and x-gebsecure-signature when signRequests is on.
  • Limits: only idempotent methods are retried; at most five redirects (headers dropped across hosts); responses up to 5 MB; a circuit breaker opens for 30 s after five failures within 60 s.
  • SSRF: HTTPS only (plain HTTP outside production and staging), no credentials in URLs, cloud metadata hosts blocked, every resolved address must be public (unless EXECUTION_ALLOW_PRIVATE_NETWORKS=true, development only), and the connection is pinned to the validated IP against DNS rebinding (ADR 0011).

Output sanitization#

Every credential string the broker injected (six characters or longer) is removed from the output and from error messages, secret-shaped strings are redacted, values under sensitive keys are masked, and the output is bounded (depth 32, 1000 array items, 100 000-character strings, 256 KB in total; outputTruncated reports truncation).