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?
This post walks through the security boundary of ByteChef Embedded 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.
sub as the user.BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS so only your app can frame the embedded pages.BYTECHEF_AUDIT_ENABLED=true.
| Layer | Enforced by | You configure |
|---|---|---|
| Who the user is | JWT signature vs. your Signing Key | One key per environment, short TTL |
| Whose data | sub must match the path; frontend endpoints read the user from the token |
Nothing |
| Which environment | Keys, users and MCP servers each belong to one | X-Environment header, optionalenvironmentId claim |
| Who can frame the UI | frame-ancestors CSP + origin-checked handshake |
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS |
| Admin operations | Tenant-admin check on every call | Who gets the admin role |
| What an agent can call | Server-wide and per-user MCP tool switches | Your MCP servers |
| Credentials at rest | AES-GCM encryption | Encryption key provider |
| Evidence | Audit events | bytechef.audit.enabled |
| Volume | Nothing | Rate limits at your ingress |
Your users never get ByteChef accounts. Your backend vouches for them with a signed JWT, and ByteChef trusts the signature, not the browser.
Create 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.
Minting a token on your backend looks like this:
import jwt from 'jsonwebtoken';
export function signConnectedUserToken(userId: string): string {
return jwt.sign(
{
sub: userId, // your user's stable id
environmentId: 2, // optional: pin to PRODUCTION
connectionDialogAllowed: true, // optional: may they create connections?
},
process.env.BYTECHEF_PRIVATE_KEY!,
{ algorithm: 'RS256', expiresIn: '10m', keyid: process.env.BYTECHEF_KID! }
);
}
What ByteChef checks before any endpoint runs:
kid`` 401. exp``environmentId`` name, email, anything else PATCH call.
If the check itself can't run (say, the database is down), you get a 503, never a silent pass.
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.
| Connected-user JWT | Embedded API Key | |
|---|---|---|
| Lives in | The browser, for minutes | Your backend |
| Used on | /automation/workflows ,/connections , ... |
/{externalUserId}/automation/workflows , ... |
| The user is | The token's sub |
The path segment |
Two rules make this safe:
{externalUserId}, it's a 1234 can't touch user 5678.
Every request lives in exactly one environment, picked by the X-Environment header. No header means PRODUCTION.
User 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.
The 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.
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS=https://app.example.com,https://admin.example.com
Once 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.
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.
With the list empty, every embedded page logs a console warning. Production shouldn't show it.
The 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.
This is the table to remember when someone opens devtools:
| Control | Server-enforced? |
|---|---|
connectionDialogAllowedclaim |
✅ false means creating a connection is a403 |
connectionDialogAllowedprop |
Only as a restriction; it can't grant what the token denies |
includeComponents ,tabs ,editWorkflowAllowed |
❌ UI only |
| Enabled integration configurations | ✅ |
| Shared connections | ✅ only the owner can reconnect or delete |
| Permission expressions | Evaluated server-side, but on data the user can edit |
That 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.
Embedded 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.
Well 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.
The 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.
Tools have two layers of switches:
One 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.
Connection 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.
The audit log is off by default. Turn it on:
BYTECHEF_AUDIT_ENABLED=true
You'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.
ByteChef 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.
The embedded sample app is built to run in five minutes, not to face the internet:
POST /api/token signs for any user id in the request body.origin: '*'. connectionDialogAllowed={true} is only a prop.
ByteChef runs the checks, but the signature is only as strong as the rule that decides who gets a token.
connectionDialogAllowed set where neededX-Environment sent explicitly on every callBYTECHEF_ENCRYPTION_PROVIDER=PROPERTY with a backed-up key on multi-instance setupsAuthorization headers, EMBED_INIT payloads or connection_required links
Set 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.
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. Questions about embedding securely? Drop them in the comments.