Security Model
Gostly records your real API traffic, which means it touches the most sensitive data your services carry — credentials, tokens, and PII. Each deployment is self-hosted and single-tenant, credential response headers are redacted in default local capture copies, and recognized body patterns are processed when recorded traffic and snapshot rows enter Postgres. Local files, training selection and export filters have separate boundaries. Seeded mocks receive structural credential redaction and a sensitive response-header floor before storage. These rules do not remove every kind of sensitive data. This page walks the boundaries: what stays verbatim, what gets scrubbed, and where the enforcement actually lives.
Self-hosted data locality
The licensed product ships as a Docker Compose stack and container images — there is no host CLI and no Gostly-hosted control plane in the traffic path. Your captured traffic, mock library, webhooks, and training data live in your own Postgres and on your own Docker volume (gostly-data). Review the separately configured forwarding, model, usage and integration connections described below. Gostly's hosted service holds account, security, license, billing and usage-telemetry records.
Licensed product vs OSS proxy
Plan backups and retention for the Postgres database and the gostly-data volume together. The README's Backup steps keep the database dump, the secret-store key, your .env and the release commit together. The recordings, mock library and adapters on gostly-data need a separate volume copy, taken with the stack stopped. The install guide covers both.
Deleting recorded data
Removing a recording or clearing the library changes the active library and, once the proxy applies it, what it serves. Service deletion reports recording and capture cleanup outcomes; inspect the response and follow its retry links for incomplete cleanup. These operations do not erase retained recorded content: the database keeps every version of each recording's content in a revision history that is append-only, and a backup keeps what it held. To remove one value captured by mistake, such as a credential or personal data, an owner runs the erase command: Settings → Status → Erase a recorded value in the dashboard, or admin erase in ghost-web. Its dry run names the recordings that hold the value and counts what each store holds; --apply erases and reports an outcome for each store, and running the same erase again finishes a step that failed. Backups are not changed: after restoring one, run admin erase-replay. Service deletion also requests cleanup of the agent's capture files; that cleanup is best-effort, so inspect the deletion result. Keeping such values out in the first place depends on the redaction and scrubbing boundaries described below, which do not catch everything, and on reviewing files before you import them.
Capture-age retention (GOSTLY_CAPTURE_MAX_AGE_DAYS) covers inbound webhook and WebSocket capture logs, their mirrored API rows, and request-event rows. The .env that setup writes for a new install sets 30 days; an upgraded install keeps its own .env, where an unset value keeps webhooks and frames with no maximum age and request-event rows 30 days. It excludes recordings/mocks, retained content revisions, LEARN traffic logs, training corpora and adapters, and backups.
Cleanup is scheduled and batched, with error backoff. File pruning removes an old prefix, so older out-of-order records later in a file can remain. Batch limits can leave database rows for later passes. An unreachable or license-locked agent can defer file cleanup while API table cleanup proceeds. This is not a deletion deadline or across-copy erasure.
Rewrites hold the capture file's writer and can make new captures wait. Queue pressure can return 503 for webhook capture or drop WebSocket capture records while traffic forwarding continues; it does not mean transport frames are dropped. See the capture-age and outbound controls for configuration, scope and operating limits.
Single-tenant isolation and enforced RLS
Each deployment is single-tenant. Setup writes its workspace identity to GOSTLY_TENANT_ID; default is the final fallback for a manually configured deployment. Application queries remain tenant-scoped.
Postgres also enforces Row-Level Security on the API's tenant-scoped tables. Request handlers connect as the non-owner gostly_app role, which cannot bypass RLS, and bind gostly.tenant_id for the transaction. Policies apply USING and WITH CHECK, and covered tables use FORCE ROW LEVEL SECURITY. A query that omits its tenant filter is still constrained by the database policy.
Separate runtime and migration credentials
gostly_service role and SERVICE_DATABASE_URL pool with RLS bypass. Migration credentials belong to the one-shot migration job, rather than the serving API. Keep these credentials and roles separate when configuring an external database.Stored provider and model credentials
New saves of Settings keys OPENAI_API_KEY and LLM_AZURE_API_KEY, and model-connection credentials, use install-local AES-256-GCM encryption in PostgreSQL. Other settings, environment variables, .env, recorded traffic and historical backups are outside this boundary.
The API creates its key file on first secret save; see secret-store configuration. The supplied Full Compose file keeps it on its own secret-store volume, which only ghost-web and ghost-migrate mount. The Lite file keeps it on the gostly-data volume, which the proxy also mounts under the same UID 10001, so mode 0600 does not isolate it from the proxy. Database-only copies lack the key; this does not protect against host administrators or combined database-and-key access.
Admins save or clear provider overrides. Saved values precede environment values; clearing restores any environment fallback and does not revoke the provider credential. An unreadable override fails use instead of falling back. A mask, set indicator or has_key reports presence, not decryptability or provider use.
Model credentials bind tenant, connection ID, endpoint origin (scheme, host and port) and allow_remote choice. With a saved credential, changing origin or remote consent requires replacing or clearing the key. Settings provider keys bind tenant and setting name, without that destination binding.
Successful API-startup upgrades encrypt legacy provider Config rows and remove the old plaintext rows. Startup can continue after a failed move; inspect logged failures before treating old rows as migrated. Legacy model ciphertext may await its retired key or re-entry. Preserve key and database together using the secret-store backup guidance.
Use the secret-store maintenance procedure for explicit resealing and separately protected matching-key backups. Resealing does not change historical database dumps or recover credentials when required key material is missing.
The 16-header credential redaction floor
A fixed floor of 16 credential and session header names applies to response headers in default local traffic-capture copies. This processing does not sanitize the response sent to the calling client. Newly seeded mock rows also receive structural credential redaction and sensitive response-header redaction. The floor is built into the proxy and is non-overridable downward — the REDACT_HEADERS env var and per-service redact_headers config can only add headers, never remove them.
# The 16-entry floor (matched case-insensitively): authorization proxy-authorization cookie set-cookie x-api-key x-auth-token x-session-id x-access-token x-user-token x-csrf-token x-amz-security-token x-amz-session-token x-goog-api-key grpc-metadata-authorization api-key token
Matched header values are replaced with [REDACTED]; the header name is preserved so the response-header structure is intact. The floor is pinned at exactly 16 entries — changing the list is a deliberate change to the security claim, not an accident.
Active-session memory and explicit disk persistence
MOCK_PERSIST_VERBATIM=true also preserves credential headers in the local capture JSONL. Review this setting and snapshot-restore artifacts separately from the default capture path.Local body copies and database processing
Header redaction and body scrubbing are two separate boundaries. Default capture-header redaction does not apply the database body scrubber to local replay files. Review each copy separately:
Local replay JSONL
Local captured and replay copies can retain request URLs/query values and captured body content before database body processing. Capture limits can truncate bodies or flag lossy text. Default response-header redaction does not make those files safe to share.
Library + training
The recorded-traffic transition processes recognized request/response body patterns and response headers before writing database-backed library rows. The live-mock training selector requires a scrub-completion marker and other eligibility conditions. Request URIs are retained; a marker does not establish that all sensitive values were removed.
Imported files
HAR, Postman and OpenAPI seeds receive structural credential and response-header rules before rows, revisions and derived serving copies are written; this is not a general personal-data scrub. Snapshot restore separately processes decoded database rows while retaining archive bytes in the local replay artifact. Review source files before uploading.
Selected exports
Bulk mock export defaults to scrubbed_only=true with member access; false requires admin. Training snapshot export defaults to scrubbed_only=false and requires admin, so it can include rows without the body-scrub completion marker. A member can request scrubbed_only=true. Inspect the export type, filters and selected content before sharing.
Body scrubbing runs locally with zero network calls, using regex and structural JSON rules. It recognizes supported token and key formats, private-key blocks and credential-bearing webhook URLs, alongside structured personal-data patterns. Recognized matches are replaced with placeholders such as:
{ "card": "[CARD]", "ssn": "[SSN]", "email": "[EMAIL]",
"token": "[REDACTED]", "ip": "[IPV4]", "wallet": "[ETH_ADDR]" }Supported card patterns include JCB 3528–3589, Mastercard 2221–2720 and Discover 644–649, alongside the existing supported card formats. A matching number must pass the Luhn checksum to be redacted as [CARD]; a checksum failure is not classified as a card by this rule. Other rules can still apply to the same text.
In the recorded-traffic pass, a JSON value equal to a recorded URI path segment can be preserved when only card or phone detection would change it, so a resource's body ID can continue to match its path ID. Credential-name and other detection rules still apply. Stored request URIs remain as captured.
Credential-field rules match recognized names and the words in compound names. Fields such as db_password, githubToken and aws_secret_access_key are replaced with [REDACTED]; names such as token_count and key_id are not treated as credential fields. Booleans and null keep their types, even under sensitive names.
Objects under names such as auth and signature are inspected field by field. Token-like strings under those names, or in lists such as apiKeys and tokens, are redacted; ordinary settings, counts and labels can remain. Other recognized text patterns still apply to those values. URL query credential detection has separate rules.
When recorded traffic or a decoded snapshot row is processed, the scrubber treats one request/response exchange as a unit. By default, a redacted credential value must be token-like and at least eight characters to supply copied-value replacement; blanks and redaction placeholders are excluded. Eligible values are also replaced in matching copies across that exchange's request and response bodies, response-header values and cookies, including supported percent-encoded forms. This does not search other recordings or rewrite the stored request URI.
Short copies and copies made only of ordinary words or numbers can remain. For example, a words-only password can be replaced in password while the same phrase remains in an unrelated note. Explicit service JSONPath or header-redaction rules can also supply values for copied-value replacement without the token-like shape, but still obey the minimum length and placeholder exclusions.
These database body and copied-value rules do not rewrite local capture files, webhook bodies or the agent's resource IDs. Local request bodies and stored URLs can still hold sensitive values.
Remaining sensitive data
scrubbed_at seal records pipeline completion, not the absence of all sensitive content. The sync layer refuses to overwrite a scrubbed row with an unscrubbed one.Serving responses and background generation
Ordinary MOCK HTTP serving selects eligible stored responses, configured stateful behavior and prepared generated responses. Eligible session replay precedes loaded exact entries. Routing, admission and faults can answer or refuse earlier; a missing eligible response remains a configured miss. See the match cascade for serving order and source limits.
Resource reads and configured chart actions use existing scoped state. Ordinary POST replay does not create arbitrary resources; resource capture and explicitly enabled episode creation have separate requirements. Session replay and local files have different retention and processing boundaries.
Eligible cache misses can request background generation without answering the current request. Eligible smart-swap answers can also trigger comparison and generation. Submission, successful generation and a later eligible cache hit are separate outcomes; none guarantees a next-request hit.
Full Compose routes response generation through ghost-inference to local ghost-llamacpp. The model container uses only the internal model network; inference also joins the default network. Separately configured API convention analysis can use external providers. This does not establish zero network activity across the stack.
Local inference applies separate text and personal-data patterns to request-body and URI copies used for retrieval. It does not run the API's JSON-field or whole-exchange copied-value rules. Index examples can retain response bodies as read from local mock files. This processing does not rewrite source captures or establish that every index example or generation input is free of sensitive data.
Generated responses are cached; LoRA adapters are model files loaded by the backend. Live-mock training requires processing markers and other eligibility checks. A marker does not prove complete sensitive-data removal.
AI mock-repair, where present, surfaces operator proposals you approve or reject; it is off by default (ENABLE_AI_MOCK_REPAIR) and never mutates the library on its own.
Operating modes and the transition interstitial
A service override takes precedence over global mode. LEARN forwards eligible traffic and captures supported exchanges; MOCK selects eligible responses and configured behavior; PASSTHROUGH forwards without building the ordinary recorded library. TRANSITIONING is internal: its ordinary HTTP branch returns 503 with Retry-After: 5. Transition processing applies body/header rules before writing PostgreSQL rows and processing markers, but does not rewrite every local replay copy. Wait for completion and confirm effective service mode. See operating modes and local-copy boundaries.
TLS interception is opt-in
Plain HTTP is served on :8080 and is the default path. A TLS-MITM listener runs on :8443 only when ENABLE_TLS_INTERCEPTION is set. The knob is tri-state: default off; true / lax (a listener failure logs and plain HTTP keeps serving); or strict (a TLS failure exits the process — “TLS is load-bearing”).
When interception is on, the agent mints per-host leaf certs from an embedded CA. Fetch and trust the CA once:
curl http://<agent>:8080/ca.crt > gostly-ca.crt # then add gostly-ca.crt to the client/OS trust store
GET /ca.crt returns 503 while interception is off. Outbound TLS fingerprint impersonation (genuine Chrome / Firefox / Safari fingerprints toward the upstream) is off unless a service is configured for it.
SSRF-guarded webhook replay
Webhook capture is automatic in the agent; replay is operator-triggered through the API (POST /v1/webhooks/{service_id}/{webhook_id}/replay) — the agent does not auto-replay. Because replay re-issues an outbound request to a caller-influenced URL, every replay target passes a shared SSRF guard before any socket opens, and the request then connects to the address the guard checked. The same outbound path carries canary replay, OpenAPI imports from a URL, and model connections.
GOSTLY_OUTBOUND_ALLOWED_ORIGINS adds an optional exact-origin filter (scheme, host and port) to selected API deliveries and proxy upstream connections. It only narrows existing destination checks. Agent control-plane, inference, license and telemetry calls, and raw CONNECT tunnels, are outside this filter. Use deployment network policy for those paths; the configuration reference lists the covered paths and explicit container environment mappings.
Scheme
Only http and https are accepted.
Host literals
Local names such as localhost, ip6-localhost and ip6-loopback are refused by default. Explicit private-origin approval or the local-replay opt-in can admit eligible local targets; metadata destinations remain blocked.
Ports
SSH (22), SMTP (25), MySQL (3306), Postgres (5432), Redis (6379), Elasticsearch (9200), memcached (11211), and MongoDB (27017) are rejected on any host.
IP classification
Loopback, RFC1918 private space, IPv6 ULA and CGNAT are refused by default. Metadata, link-local, multicast, reserved and unspecified destinations remain blocked even when private replay is allowed.
DNS rebinding
Every resolved address is classified. The target is refused if any answer violates the active destination policy; delivery is pinned to an admitted address.
Bounds
Replay follows no redirects, and it reads at most 1 MiB of the target's response.
API replay can use exact GOSTLY_OUTBOUND_ALLOWED_PRIVATE_ORIGINS approvals; the broader GOSTLY_ALLOW_LOCAL_REPLAY=1 opt-in is separate. Neither relaxes the scheme, blocked-port or metadata/link-local floor. If the additional origin filter is configured, the target must also be listed there. Follow the private test-receiver policy. Proxy upstream private/loopback handling instead uses GOSTLY_EGRESS_STRICT; API private-origin approval does not configure that separate path.
Authentication, RBAC, and the audit log
SSO and role-based access ship in the web container's auth layer on every license. Three identity backends are supported: password (bcrypt, cost factor 12), SAML 2.0, and OIDC (authorization-code flow with JWKS validation). A four-rank role model gates every state-changing endpoint:
viewer < member < admin < owner
Roles are enforced server-side, not in the client. The owner rank carries a hard invariant — the system refuses to demote the last owner of a tenant. Authentication events (logins, SSO, logouts, session revokes and user changes) and service, mode and transition changes are written to legacy auth/activity streams, separate from the retained event feed described below. Sessions use HttpOnly, Secure, SameSite=Lax cookies; API keys are stored as hashes and compared in constant time.
GET /v1/audit/events reads a separate tenant-bound retained feed of selected authentication and administrative actions. It requires an admin or owner login session; a service key, service-account key or development-bypass principal alone does not qualify. These session and role checks supplement the product's license-admission policy rather than replacing it. The reader does not aggregate the legacy auth/activity streams.
Saved scrub-policy changes record metadata about the enabled flag, rule/header counts and changed configuration categories, without copying rule contents or captured traffic. The retained feed covers selected actions, not a comprehensive action history. Ordinary runtime table permissions allow reading and appending. Scheduled cleanup uses a bounded tenant-scoped database function; separate operator pruning requires a privileged maintenance connection. Hosted organization audit remains a separate Team feature.
Retention is scheduled and bounded, not a deletion deadline; see audit retention for stored expiry, legacy-auth cleanup and dead login-session handling. The deployment audit reference distinguishes paginated JSON from all-matching NDJSON exports of this feed. Both exports require an admin or owner login session. NDJSON uses normal product admission; the paginated POST export has separate admin data-out admission after a previously admitted trial, subscription or license expires.
Use a named service-account key for a CI pipeline or agent. Admins issue scoped keys with an expiry; a key acts as a member within its scopes and cannot bypass an admin role floor. The system service key is a separate admin credential for stack components. See API authentication.
Bulk mock export requires member access and defaults to scrubbed_only=true; including unscrubbed rows requires admin. Training snapshot export defaults to including unscrubbed rows and requires admin, unless scrubbed_only=true is requested by a member. A scrub-completion marker is not a guarantee that all sensitive values were removed. Retained recording revisions have a separate deletion boundary.
Specified data exports and deletions, and service-account mock reads using mocks:read_unscrubbed, add retained audit metadata. This is selected coverage, not an audit of every read or delete; see the deployment audit reference.
What is captured, and what stays observability-only
Gostly records and replays HTTP and HTTPS — HTTP/1.1 and HTTP/2 over TLS. WebSocket frame capture is off by default. When explicitly enabled and allowed by the service's traffic capture switch, frames are retained for observability only; they are not replayed and frame bodies are not scrubbed. See the TLS guide for container configuration and capture limits. There is no gRPC, async-messaging, or database mocking today (roadmap). Cold-start seeding lets you bootstrap a library without live traffic by dragging a HAR, Postman collection, or OpenAPI spec into the dashboard, which posts to POST /v1/seed/{har,postman,openapi}. Drift detection emits drift events plus a 0–100 freshness score and a sparkline trend so you can see when a recorded library is going stale against its upstream.
The telemetry boundary
The agent and API usage payloads carry operational fields and counts, without captured request/response bodies, full traffic URLs or captured credential headers. Keyed uploads authenticate separately with the license key; online key validation records the connecting IP and installation identity. Enterprise signed-file licensing on supported standard images uses local verification instead; it does not disable usage telemetry. See Enterprise signed license setup. This boundary is separate from intentional upstream forwarding, exports and configured external model integrations. The proxy exposes local Prometheus metrics on /metrics: request counts by match type, mock library size, IO errors, HTTP rate and latency, and the TLS subsystem family.
ghost_requests_total{match_type} # one increment per match-path outcome
ghost_mock_library_size # library size gauge
ghost_io_errors_total{operation} # disk-sink open/write failures
axum_http_requests_total / _duration # HTTP rate + latency
gostly_tls_* # TLS MITM subsystem (ALPN, cert cache, listener state)These are counts and gauges, without request bodies. Scrape with the system service key in X-API-Key to include service and endpoint labels; unauthenticated scrapes withhold identity-labelled samples. The selected outgoing usage, installation and licensing records and their different controls are documented on the telemetry page.