{"slug": "embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded", "title": "Embedding Securely: Where the Real Security Boundary Is in ByteChef Embedded", "summary": "ByteChef published a security breakdown of its Embedded automation platform, sorting controls into what the server enforces, what the UI only hides, and what integrators must configure themselves. The writeup details JWT-based connected-user auth with RSA-2048 signing keys and short TTLs, path-scoped external user IDs, per-environment isolation via the X-Environment header, and frame-ancestors CSP gated by BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS. It also notes that rate limiting is left entirely to the integrator's ingress.", "body_md": "You've wired an automation platform into your SaaS: iframes in your UI, signed tokens in the browser, backend API calls, and an MCP endpoint for AI agents. Every one of those is a door into your customers' data. So where exactly is the lock?\n\nThis post walks through the security boundary of [ByteChef Embedded](https://www.bytechef.io) and sorts every control into three buckets: **what the server enforces**, **what the UI only hides**, and **what's left to you**. The good news: most of it is on by default. You have two settings to flip and a handful of sample-app shortcuts to fix before real users show up.\n\n`sub` as the user.`BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS` so only your app can frame the embedded pages.`BYTECHEF_AUDIT_ENABLED=true`.\n| Layer | Enforced by | You configure | \n|---|---|---|\n| Who the user is | JWT signature vs. your Signing Key | One key per environment, short TTL | \n| Whose data | `sub` must match the path; frontend endpoints read the user from the token | Nothing | \n| Which environment | Keys, users and MCP servers each belong to one | `X-Environment` header, optional`environmentId` claim | \n| Who can frame the UI | `frame-ancestors` CSP + origin-checked handshake | `BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS` | \n| Admin operations | Tenant-admin check on every call | Who gets the admin role | \n| What an agent can call | Server-wide and per-user MCP tool switches | Your MCP servers | \n| Credentials at rest | AES-GCM encryption | Encryption key provider | \n| Evidence | Audit events | `bytechef.audit.enabled` | \n| Volume | Nothing | Rate limits at your ingress | \n\nYour users never get ByteChef accounts. Your backend vouches for them with a signed JWT, and ByteChef trusts the signature, not the browser.\n\nCreate a key under **Embedded → Settings → Signing Keys**. ByteChef generates an RSA-2048 pair, stores the public half with a Key Id (your `kid`), and shows you the private key **once**. Lose it and you create a new one.\n\nMinting a token on your backend looks like this:\n\n``` python\nimport jwt from 'jsonwebtoken';\n\nexport function signConnectedUserToken(userId: string): string {\n  return jwt.sign(\n    {\n      sub: userId,                   // your user's stable id\n      environmentId: 2,              // optional: pin to PRODUCTION\n      connectionDialogAllowed: true, // optional: may they create connections?\n    },\n    process.env.BYTECHEF_PRIVATE_KEY!,\n    { algorithm: 'RS256', expiresIn: '10m', keyid: process.env.BYTECHEF_KID! }\n  );\n}\n```\n\nWhat ByteChef checks before any endpoint runs:\n\n`kid`` 401`.` exp``environmentId`` name`, `email`, anything else` PATCH` call.\nIf the check itself can't run (say, the database is down), you get a `503`, never a silent pass.\n\n**Rotation is deliberately boring:** create a new key, deploy it, delete the old one. With a 10-minute TTL and a frontend that refreshes on `401`, nobody notices.\n\n|  | Connected-user JWT | Embedded API Key | \n|---|---|---|\n| Lives in | The browser, for minutes | Your backend | \n| Used on | `/automation/workflows` ,`/connections` , ... | `/{externalUserId}/automation/workflows` , ... | \n| The user is | The token's `sub` | The path segment | \n\nTwo rules make this safe:\n\n`{externalUserId}`, it's a `1234` can't touch user `5678`.\nEvery request lives in exactly one environment, picked by the `X-Environment` header. No header means `PRODUCTION`.\n\nUser `1234` in Development and user `1234` in Production are two different users with different connections and workflows. This also explains the most confusing `401` in development: a token signed with a Development key, sent without the header, gets checked against Production keys.\n\nThe workflow builder, Automation Hub and Integration Marketplace render in your product as iframes. Left open, *any* site could frame them, which is exactly what clickjacking needs.\n\n```\nBYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS=https://app.example.com,https://admin.example.com\n```\n\nOnce set (and the server restarted), those pages send `Content-Security-Policy: frame-ancestors ...` and accept their init message only from the listed origins. Everything else in the ByteChef UI sends `X-Frame-Options: DENY` regardless.\n\n**Gotcha:** use exact origins, no wildcards. A browser would accept `https://*.example.com` in `frame-ancestors`, but the handshake compares origins exactly, so the page renders and then never initializes.\n\nWith the list empty, every embedded page logs a console warning. Production shouldn't show it.\n\nThe iframe posts `EMBED_READY` only to allowed origins and accepts `EMBED_INIT` only from its direct parent. On your side, the `@bytechef/embedded` components only talk to the origin of the `baseUrl` you passed. The JWT rides inside `EMBED_INIT`, **never in the URL**, so it stays out of history, `Referer` headers and access logs, and it's kept in memory, never in local storage.\n\nThis is the table to remember when someone opens devtools:\n\n| Control | Server-enforced? | \n|---|---|\n| `connectionDialogAllowed`**claim** | ✅ `false` means creating a connection is a`403` | \n| `connectionDialogAllowed`**prop** | Only as a restriction; it can't grant what the token denies | \n| `includeComponents` ,`tabs` ,`editWorkflowAllowed` | ❌ UI only | \n| Enabled integration configurations | ✅ | \n| Shared connections | ✅ only the owner can reconnect or delete | \n| Permission expressions | Evaluated server-side, **but** on data the user can edit | \n\nThat last row bites people. A user holding their own JWT can `PATCH /api/embedded/v1/me` and change their own name, email and metadata. So `metadata.plan == 'enterprise'` is fine for tidying a catalog and useless for protecting anything. Restrict real features with things the user can't edit: which configurations you enable, which tokens you mint, what your backend allows.\n\nEmbedded auth is a bearer header, never a cookie, so there's nothing for CSRF to ride on and no server session to hijack. Many embedded endpoints allow cross-origin calls from anywhere, and that's fine: **CORS isn't access control, the token is.** The admin UI does use a session cookie and keeps its XSRF protection.\n\nWell over a hundred embedded admin operations (integrations, MCP servers, connected users, Signing Keys...) require `ROLE_ADMIN`. A connected user's token carries no roles, so it can never pass that check. Keep the admin group small: any admin can manage every key in the environment.\n\nThe embedded MCP URL looks like `https://<your-bytechef>/api/embedded/{secretKey}/mcp`. **The URL routes, the token authenticates**: every call also needs a connected-user JWT, or it's a `401` before a single tool is listed.\n\nTools have two layers of switches:\n\nOne heads-up: a `connection_required` result contains a `setupUrl` with a signed, 10-minute token in the query string. It's the one place a token travels in a URL, so don't log tool results verbatim.\n\nConnection secrets are encrypted with **AES-GCM** and a fresh IV per value, and never returned over the wire. The default `FILESYSTEM` provider keeps the key in `~/.bytechef/key`. For containers or multiple replicas, switch to `BYTECHEF_ENCRYPTION_PROVIDER=PROPERTY` and share the same key everywhere. **Back it up with your database**, or stored credentials are gone.\n\nThe audit log is **off by default**. Turn it on:\n\n```\nBYTECHEF_AUDIT_ENABLED=true\n```\n\nYou'll get events for Signing Key changes, connection changes, connected-user changes, MCP tool switches, publishing, and authentication (`AUTHENTICATION_FAILURE`, plus deduplicated `CREDENTIAL_USED`). Retention defaults to 365 days.\n\nByteChef has no per-user or per-tenant rate limit. Data is isolated; throughput isn't. Put limits where you know the customer: your gateway, your token endpoint, App Event bursts, and expensive operations like workflow generation.\n\nThe embedded sample app is built to run in five minutes, not to face the internet:\n\n`POST /api/token` signs for any user id in the request body.`origin: '*'`.` connectionDialogAllowed={true}` is only a prop.\nByteChef runs the checks, but the signature is only as strong as the rule that decides who gets a token.\n\n`connectionDialogAllowed` set where needed`X-Environment` sent explicitly on every call`BYTECHEF_ENCRYPTION_PROVIDER=PROPERTY` with a backed-up key on multi-instance setups`Authorization` headers, `EMBED_INIT` payloads or `connection_required` links\nSet `BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS` to your local sample app's origin, restart ByteChef, then frame the Automation Hub from a page on another port and watch the browser refuse it. Send a request with another user's id in the path and enjoy the `401`.\n\n*This is part 17 of the ByteChef Embedded series. The full version, with every detail and the rest of the series, is on the [ByteChef blog](https://blog.bytechef.io/blogs/embedded-security). Questions about embedding securely? Drop them in the comments.*", "url": "https://wpnews.pro/news/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded", "canonical_source": "https://dev.to/bytechef/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded-2o32", "published_at": "2026-11-26 17:07:35+00:00", "updated_at": "2026-11-26 17:15:32.780560+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["ByteChef", "MCP"], "also_reported_by": [], "takeaway": "ByteChef Embedded enforces identity by verifying an RS256 JWT against your signing key and requiring its sub to match the path's externalUserId, so a token for user 1234 cannot reach user 5678's data, while rate limiting is left entirely to your ingress.", "recommendation": {"advice": "Set BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS to your app's origins, mint short-TTL RS256 tokens with sub bound to the path user, and add rate limits at your ingress since ByteChef enforces none.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded", "markdown": "https://wpnews.pro/news/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded.md", "text": "https://wpnews.pro/news/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded.txt", "jsonld": "https://wpnews.pro/news/embedding-securely-where-the-real-security-boundary-is-in-bytechef-embedded.jsonld"}}