Skip to content

Zero-Trust Security Model ​

LatticeDX enforces defense-in-depth from the TLS perimeter down to PostgreSQL 16 row policies. Every inbound request traverses Caddy TLS termination, Apache APISIX or Nginx edge controls, Keycloak OIDC PKCE verification, and FORCE ROW LEVEL SECURITY executed under non-superuser database roles (nocobase_app and lattice_app).

Docker Compose Deployment & 5 Isolated Networks (v0.4.2)
EDGE NETWORK (BRIDGE)APP NETWORK (INTERNAL)SCANNER (INTERNAL: TRUE)DATA NETWORK (INTERNAL: TRUE)TLS 1.3JWKS / OIDCProxyPDFFORCE RLSDB 0/1/2UploadScan :3310Clean S3keycloak_appCaddy 2.10:80 / :443 · TLS 1.3edge + appApache APISIX 3.19:9080 · JWKS / Limitedge + appKeycloak 26.8.2OIDC PKCE S256realm: lattice · iam-syncNocoBase 2.2.507 Plugins :ro · :80PG16 RLS & OutboxGotenberg 8.20.1profile: pdf · :3000read_only · JS disabledFile Scanner:4010 · read_only: trueapp + data + scannerClamAV 1.5.5:3310 · Malware Scanscanner internal onlynocobase-db (PG16)pgvector 0.8.1 · :543256+ FORCE RLS · OutboxValkey 8.1:6379 · AOF 512mbDB0 Cache · DB1 SSE · DB2 AuthRustFS 1.0.6:9000 · S3 StorageScanned ObjectsPostgreSQL 16.16:5432 · Isolated DBskeycloak_app · lattice_app
InspectorNocoBase 2.2.50Click any component to inspect bindings & boundaries
Role
DX-OS Host & 7 Apache-2.0 Plugins
Package / Port
nocobase/nocobase:2.2.50@sha256:04b751... · :80
Protocol
HTTP · edge + app + data + iiot-net
Payload / Schema
2048m / 2.0 CPU · @latticedx/* :ro
Responsibilities
Mounts all 7 @latticedx/* plugins read-only (:ro), enforces AsyncLocalStorage FORCE RLS as nocobase_app, and orchestrates outbox and upload flows.
All containers in infra/compose/prod.yml pin immutable @sha256 digests across 5 isolated networks (edge, app, data, scanner, iiot-net). Read-only file-scanner scans uploads via ClamAV on the scanner network before persisting clean objects to RustFS on the data network.

Five Isolated Docker Networks ​

In infra/compose/prod.yml, every container image is pinned to an immutable @sha256 digest and segmented across five Docker networks. Four networks are marked internal: true so backend services cannot be reached from the host edge or initiate arbitrary outbound traffic:

Docker NetworkModeAttached ServicesIsolation Boundary
edgeExternal bridgecaddy, keycloak, gateway (APISIX), nocobaseTerminates host ports 80 and 443 at Caddy; exposes no database, cache, or object storage sockets.
appinternal: truecaddy, keycloak, gateway, nocobase, file-scanner, orion-ld, n8n, otel-collector, prometheus, grafana, gotenberg, nodered, redisCarries internal HTTP, OTLP telemetry, and Valkey traffic between the gateway, runtime, and observability plane.
datainternal: truepostgres, nocobase-db, redis, rustfs, keycloak, file-scanner, orion-mongo, orion-ld, nocobase, n8n, otel-collector, prometheus, grafanaIsolates both PostgreSQL 16 clusters, MongoDB 8, RustFS S3, and Valkey 8.1 from edge-facing containers.
scannerinternal: trueclamav, file-scannerRestricts ClamAV 1.5.5 (read_only + tmpfs) behind the file-scanner:4010 bridge.
iiot-netinternal: truemosquitto, nodered, nocobaseIsolates the Eclipse Mosquitto 2.0.21 Dynamic Security MQTT broker and Node-RED 4.0.9 downlink flows.

Edge Layer: Caddy TLS, Apache APISIX, and Nginx CSP/CORS/CSRF ​

External requests pass through four edge enforcement layers before reaching NocoBase 2.2.50 application handlers:

LayerComponent / ConfigEnforcement Controls
1Caddy 2.10 (infra/config/caddy/Caddyfile)Provisions TLS for LATTICE_DOMAIN, KEYCLOAK_DOMAIN, and N8N_DOMAIN, strips the Server header (-Server), and attaches hardening headers (Strict-Transport-Security: max-age=63072000; includeSubDomains; preload, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy: strict-origin-when-cross-origin, Permissions-Policy: camera=(self), microphone=(), geolocation=(self)). Requests for /api/* and /.well-known/agent-card.json proxy to gateway:9080.
2Apache APISIX 3.19.0 (infra/config/apisix/apisix.prod.yaml)Injects X-Request-Id, enforces CORS against LATTICE_ALLOWED_ORIGIN, validates bearer JWTs via JWKS (openid-connect with client_id: dx-gateway, bearer_only: true, use_jwks: true, ssl_verify: true) on /api/dxos-oidc*, and applies Valkey-backed limit-count (policy: redis) across route tiers.
3Nginx Public Routes and Per-Response Nonce CSP (10-lattice-public-routes.sh, public-form-html.js, public-track-html.js)Nginx proxies /v/form, /v/track, /v/mobile, and /.well-known/agent-card.json with Cache-Control: no-cache, no-store. Public HTML handlers generate a fresh cryptographic nonce per response and enforce a strict Content Security Policy (default-src 'none'; script-src 'nonce-<n>'; style-src 'nonce-<n>'; img-src data:; connect-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'self').
4Strict CORS and CSRF Binding (observability.js, routes.js)When DX_CORS_STRICT=true, middleware strips all Access-Control-Allow-* response headers if the request Origin is outside DX_CORS_ALLOWED_ORIGINS or the verified host. During enterprise sign-in, the ldx_enterprise_binding cookie sets httpOnly: true, sameSite: 'lax', secure: true (on HTTPS), and path: '/api', while POST /api/enterpriseAuth:finish rejects requests whose Origin header differs from DX_NATIVE_AUTH_ORIGIN or whose Content-Type is not application/json.

APISIX Route Tiers and Rate Limits ​

Route IDURI GroupGateway EnforcementRate Limit (limit-count)Upstream Timeout
dxos-public-paas/.well-known/agent-card.json, /api/dxos:openapi, /api/dxosWms:publicTrack, /api/dxosForms:*Public / form access token120 req / 60s (remote_addr)Default
dxos-enterprise-auth/api/enterpriseAuth:start, :callback, :finish, :backchannelLogoutPKCE S256 / logout_token120 req / 60s (remote_addr)Default
dxos-oidc-bridge/api/dxos-oidc, /api/dxos-oidc/*openid-connect JWKS (dx-gateway)120 req / 60s (remote_addr)Default
dxos-mcp/api/dxos-mcp, /api/dxos-mcp/*Bearer JWT / ldx_pat_*120 req / 60s (remote_addr)600s send/read
dxos-telemetry-ingest/api/dxosBlocks:telemetryIngest, :alarmIngest, /api/dxosBroker:deviceStatusIngest, :orionNotifyX-Lattice-Edge-Token300 req / 60s (remote_addr)Default
dxos-core-api/api/* (priority 10)Bearer JWT / ldx_pat_*240 req / 60s (remote_addr)600s send/read
GET/api/enterpriseAuth:start
Public (PKCE S256)
Generates code_verifier and S256 code_challenge, caches state in Valkey DB 2 (300s TTL), and sets the HttpOnly ldx_enterprise_binding cookie.
POST/api/enterpriseAuth:finish
Same-Origin + HttpOnly Cookie
Verifies Origin, matches the single-use ticket (60s TTL) against the binding cookie via timingSafeEqual, and issues a session.
POST/api/enterpriseAuth:backchannelLogout
Keycloak Logout Token
Validates the signed Keycloak logout_token JWT and writes revoked:/revoked_sid: keys (24h TTL) to Valkey DB 2.

Keycloak OIDC/PKCE and RBAC Role Boundaries ​

The lattice realm in infra/config/keycloak/lattice-realm.prod.json enables bruteForceProtected: true (locking accounts after 5 failed logins), enforces TOTP MFA, and requires a minimum 12-character password. The public browser client dx-native restricts flows to Authorization Code with PKCE S256 (directAccessGrantsEnabled: false), separate from the confidential gateway client dx-gateway used by APISIX.

To prevent identity-provider group claims from granting administrative access, syncMappedUserRoles in plugins/nocobase/plugin-enterprise-auth/src/server/policy.js accepts only role names matching ^ldx_[a-z][a-z0-9_]{1,40}$ and skips privileged roles (ldx_admin, allowConfigure: true, or roles containing pm.* snippets). On every authenticated request, createRevocationGuard checks revoked:<userId> and revoked_sid:<sid> in Valkey DB 2 to terminate revoked sessions immediately after back-channel logout or enterpriseAuth:unlink.

Within the application layer (native-roles.js and portal-roles.js), eight native ldx_* roles partition operational permissions separately from host administrative roles (root, admin, anonymous, member):

Role TierIdentifiersScope of Authorization
Frontline Operationsldx_employee, ldx_operator, ldx_driverCreate business requests, execute assigned workflow tasks, scan QR codes, and submit offline ePOD captures.
Warehouse and Dispatchldx_warehouse, ldx_dispatcherAllocate and issue FEFO stock lots, enforce MKT holds or QA releases, and dispatch cold-chain shipments.
Management and Executiveldx_manager, ldx_directorDecide M-of-N approval requests, review BI dashboards, and triage or escalate IoT incident cases.
Tenant Administrationldx_adminConfigure organization portals, dynamic collections, and directory bindings; excluded from automatic SSO group mapping.
http
Content-Security-Policy: default-src 'none'; script-src 'nonce-8fK2pQ9xL4mN7vR1'; style-src 'nonce-8fK2pQ9xL4mN7vR1'; img-src data:; connect-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'self'
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Referrer-Policy: strict-origin-when-cross-origin

ClamAV Attachment Scanning Boundary ​

Every attachment uploaded to latticeRequests (POST /api/latticeRequestAttachments:upload) must pass synchronous scanning on the isolated scanner network before database persistence. The zINSTREAM client streams payloads up to 1 MiB to clamd on port 3310 (DX_NATIVE_CLAMD_HOST) with a 15-second socket timeout (native-request-attachments.js). When the scanner is unreachable, uploads fail closed with HTTP 503, and detected signatures (stream: ... FOUND) return HTTP 409 without writing to lattice_native_request_attachments.

Secret Handling, Encryption, and PII Redaction ​

Credentials, cryptographic signing keys, and API tokens follow zero-cleartext persistence rules across the platform:

MechanismComponentCryptographic / Validation Controls
Connector Vault (dxosVault)connector-vault.js, latticeConnectorsEncrypts credentials with AES-256-GCM (iv:tag:cipher hex) using a SHA-256 key derived from DX_VAULT_MASTER_KEY || ENCRYPTION_FIELD_KEY || NOCOBASE_APP_KEY || APP_KEY; enforces assertSafeConnectorUrlAsync (redirect: 'error') against SSRF.
Ed25519 Key Wrappingpki-ledger.js, latticePkiKeysWraps per-organization Ed25519 signing keys with AES-256-GCM derived from NOCOBASE_ENCRYPTION_FIELD_KEY || NOCOBASE_APP_KEY.
Scoped API Keys (ldx_pat_*)paas-api-keys.js, latticeApiKeysDisplays ldx_pat_<8hex>_<32hex> once on creation, stores SHA-256 keyHash, verifies via timingSafeEqualHex, enforces 7 scopes (read, write, wms, dmn, iot, ai, ledger), and clamps X-Role via clampHeaderRole.
PII Redaction and Bundle Scrubbingai-governance.js, otel-exporter.js, solution-bundle.jsredactPiiText masks 9 patterns (JWTs, Bearer tokens, sk-... keys, emails, IBANs, national IDs, Vietnamese phone numbers, tax IDs) prior to audit logging or OTLP export; bundle imports strip SECRET_KEY_RE keys.
POST/api/dxosVault:rotateSecret
Bearer JWT | ldx_pat_*write (admin)
Rotates and re-encrypts stored connector credentials under AES-256-GCM without exposing prior secret material.

Database Role Separation (nocobase_app and lattice_app) ​

Bootstrap scripts infra/config/postgres/init-nocobase-db.sh and init-prod.sh isolate runtime applications from PostgreSQL superuser credentials. Both nocobase_app (owning nocobase) and lattice_app, keycloak_app, n8n_app (owning lattice, keycloak, and n8n) are created with NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS, with all PUBLIC privileges revoked on databases and public schemas.

Because init-nocobase-db.sh aborts if NOCOBASE_APP_DB_USER matches POSTGRES_USER, runtime queries executed by NocoBase 2.2.50 always honor NOBYPASSRLS and cannot circumvent FORCE ROW LEVEL SECURITY on any of the 56 static tables or dynamic latticeCustom* tables. On the core cluster, init-prod.sh isolates lattice_app, keycloak_app, and n8n_app into separate databases so identity tables and external workflow state never share credentials with the platform database.

PostgreSQL RoleOwned DatabasePrivilege FlagsConnected Service
nocobase_appnocobase (pgvector)NOSUPERUSER NOBYPASSRLS NOINHERITNocoBase 2.2.50 and 7 LatticeDX plugins
lattice_applatticeNOSUPERUSER NOBYPASSRLS NOINHERITCore API and file storage
keycloak_appkeycloakNOSUPERUSER NOBYPASSRLS NOINHERITKeycloak 26.8.2 IAM
n8n_appn8nNOSUPERUSER NOBYPASSRLS NOINHERITOptional n8n service (n8n profile)
Core Security Environment Variables (prod.env.example)
ParameterTypeDefaultDescription
NOCOBASE_APP_DB_USERrequired
stringnocobase_appNon-superuser PostgreSQL runtime role with NOBYPASSRLS so FORCE RLS stays enforced.
NOCOBASE_ENCRYPTION_FIELD_KEYrequired
secret (32B)—AES-256-GCM key wrapping Ed25519 private keys and encrypted connector vault secrets.
DX_CORS_STRICT
booleantrueStrips CORS headers whenever the request Origin is outside DX_CORS_ALLOWED_ORIGINS or the verified host.
DX_NATIVE_AUTH_CLIENT_ID
stringdx-nativePublic Keycloak OIDC client configured with mandatory PKCE S256.
DX_ALLOW_INTERNAL_CONNECTORS
booleanfalseBlocks connector calls to private and loopback IP ranges by default to prevent SSRF.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)