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.
TL;DR
- Your backend signs a short-lived RS256 JWT per user. ByteChef verifies it on every request and treats
subas the user. - A token works for one user in one environment. Nothing else.
- Set
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINSso only your app can frame the embedded pages. - Turn on the audit log with
BYTECHEF_AUDIT_ENABLED=true. - Rate limiting is your job.
The boundary on one screen
| 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, optional environmentId 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 |
1. Identity: one signed token per user
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:
-
kidis required and must exist in the request's environment, or you get a401. - Signature is verified against the stored public key.
-
expis honored, but not required. Always set it. -
subis required and decides whose data the request touches. The first request for a newsubcreates the user. -
environmentId, if present, must match the request's environment. -
name,email, anything else is ignored. Profile data comes from the admin UI, a CSV import or aPATCHcall.
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.
2. Two credentials that never overlap
| 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:
-
A JWT acts only for itself. If
subdoesn't match{externalUserId}, it's a401before the endpoint runs. A token for user1234can't touch user5678. - An API Key never acts as a browser. Keys are rejected on frontend paths, and must be an Embedded key from the same environment.
3. Environments are separate worlds
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.
4. Lock the frame
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.cominframe-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 handshake checks both ways
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.
5. Enforced vs. merely hidden
This is the table to remember when someone opens devtools:
| Control | Server-enforced? |
|---|---|
connectionDialogAllowed claim
|
✅ false means creating a connection is a 403
|
connectionDialogAllowed prop
|
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.
6. CORS, CSRF and sessions
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.
7. Admin side: tenant admins only
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.
8. MCP: who can switch what
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:
- Server-wide (admin): off means not listed and not callable, period. New tools start on, so review the list after adding a component.
- Per user: tools start off and users enable them on their own instances. An admin can flip a user's switch, but the user can flip it back. For anything that must stay off, use the server-wide switch.
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.
9. Credentials at rest and the audit trail
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.
10. Rate limiting is yours
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.
Fix these in the sample app
The embedded sample app is built to run in five minutes, not to face the internet:
-
POST /api/tokensigns for any user id in the request body. Derivesubfrom your own session. Never trust a user id from the browser. -
CORS is
origin: '*'. Allow only your frontend, or serve the token route same-origin. - TTL defaults to 1h. Ten minutes is plenty.
- The token cache is a module variable used from server components, so it's shared across requests. Key it by user.
-
connectionDialogAllowed={true}is only a prop. Set the claim in the token for users who shouldn't create connections.
ByteChef runs the checks, but the signature is only as strong as the rule that decides who gets a token.
Production checklist
- [ ] One Signing Key per environment; private key is a backend secret
- [ ] Tokens minted from your authenticated session,
exp≈ 10 min - [ ]
environmentIdandconnectionDialogAllowedset where needed - [ ] API Keys only on the backend, one per environment
- [ ]
X-Environmentsent explicitly on every call - [ ]
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINSset to exact origins - [ ] UI props and permission expressions treated as presentation, not security
- [ ] Admin group kept small
- [ ] MCP servers keep auth on; tool list reviewed after each new component
- [ ]
BYTECHEF_ENCRYPTION_PROVIDER=PROPERTYwith a backed-up key on multi-instance setups - [ ]
BYTECHEF_AUDIT_ENABLED=true - [ ] Rate limits at your ingress and token endpoint
- [ ] Logs never capture
Authorizationheaders,EMBED_INITpayloads orconnection_requiredlinks
Try it
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.



Top comments (0)