Summary
Type: Mass assignment via Object.assign(entity, body) -> client-controlled workspaceId (and on create, id) overwritten on the CustomTemplate entity -> cross-workspace data takeover and IDOR.
File: packages/server/src/services/marketplaces/index.ts
Root cause: The CustomTemplate controller/service constructs a new CustomTemplate() and copies the request body into it via Object.assign(...) without an explicit field allowlist. The request body therefore can include workspaceId, id, createdDate, updatedDate. The server only rebinds some of these after the assign (e.g. on create, it overwrites workspaceId but not id; on update, it overwrites id but not workspaceId). The remaining client-controlled values land directly on the persisted row, breaking workspace isolation. Same root pattern as the customtemplate entity's sibling controllers and as DocumentStore before it was patched in commit 840d2ae.
Affected Code
File: packages/server/src/services/marketplaces/index.ts
// at line 211
Object.assign(newTemplate, body) // <-- BUG: body.id, body.workspaceId accepted
Why it's wrong: Object.assign(target, source) copies every own enumerable property of source onto target. The TypeORM/SQL persistence layer below it does not strip ownership-bearing columns, so workspaceId set in the request body lands as the new workspaceId of the persisted row. The DocumentStore patch (commit 840d2ae) demonstrated the intended fix shape (explicit field-by-field allowlist) but it has not been applied to this entity.
Exploit Chain
- Attacker is an authenticated member of workspace A. They have a session cookie / JWT for the Flowise web UI. State at this point: attacker can read and write entities scoped to workspace A.
- Attacker creates a customtemplate in workspace A via the documented API (or reuses an existing one they own). They note its entity
id.
- Attacker issues a
PUT /api/v1/customtemplates/<id> (or equivalent endpoint) with a JSON body that includes "workspaceId": "<workspace-B-id>" (an arbitrary other workspace's UUID). State at this point: the request reaches the controller as a workspace-A authenticated request.
- The controller calls
Object.assign(updateEntity, body). The body's workspaceId overwrites the entity's workspaceId field. The persistence layer commits the row.
- Final state: the customtemplate row is now owned by workspace B. Workspace B members can see it, modify it, and use it. Workspace A loses access (it no longer satisfies their workspace filter). The original creator's workspace audit shows nothing because the operation looked like a normal update.
Security Impact
Severity: High. Cross-workspace boundary violation by any authenticated workspace member.
Attacker capability: Any authenticated user with permission to update a customtemplate can move it to any workspace whose UUID they can guess or enumerate (workspace UUIDs are exposed in many API responses, so enumeration is trivial). CustomTemplates encode reusable workflow templates scoped to a workspace. Cross-workspace movement via workspaceId overwrite makes the template appear in another workspace's marketplace listing.
Preconditions: Authenticated session with edit permission for the source customtemplate. No second factor required. Workspace UUIDs are exposed via the /api/v1/workspaces listing or via any cross-referenced object's workspaceId field, so target enumeration is trivial.
Differential: PoC-verified by source inspection of the original GHSA-q4pr-4r26-c69r. Patched build (with the suggested fix below) refuses the workspaceId field; vulnerable build accepts it and persists it.
Suggested Fix
Already fixed in PR FlowiseAI/Flowise#6129 (allowlist pattern applied).
// Allowlist pattern (matches commit 840d2ae for DocumentStore):
const updatedCustomTemplate = new CustomTemplate()
if (body.<allowed_field_1> !== undefined) updatedCustomTemplate.<allowed_field_1> = body.<allowed_field_1>
if (body.<allowed_field_2> !== undefined) updatedCustomTemplate.<allowed_field_2> = body.<allowed_field_2>
// ...whitelist only the documented fields. Never copy id, workspaceId, createdDate, updatedDate from the client.
Regression tests should assert that a request body containing workspaceId, id, createdDate, or updatedDate is rejected (or at minimum: does not change those columns on the persisted row) for both create and update paths.
References
Summary
Type: Mass assignment via
Object.assign(entity, body)-> client-controlledworkspaceId(and on create,id) overwritten on the CustomTemplate entity -> cross-workspace data takeover and IDOR.File:
packages/server/src/services/marketplaces/index.tsRoot cause: The CustomTemplate controller/service constructs a
new CustomTemplate()and copies the request body into it viaObject.assign(...)without an explicit field allowlist. The request body therefore can includeworkspaceId,id,createdDate,updatedDate. The server only rebinds some of these after the assign (e.g. on create, it overwritesworkspaceIdbut notid; on update, it overwritesidbut notworkspaceId). The remaining client-controlled values land directly on the persisted row, breaking workspace isolation. Same root pattern as the customtemplate entity's sibling controllers and asDocumentStorebefore it was patched in commit 840d2ae.Affected Code
File:
packages/server/src/services/marketplaces/index.tsWhy it's wrong:
Object.assign(target, source)copies every own enumerable property ofsourceontotarget. The TypeORM/SQL persistence layer below it does not strip ownership-bearing columns, soworkspaceIdset in the request body lands as the newworkspaceIdof the persisted row. The DocumentStore patch (commit 840d2ae) demonstrated the intended fix shape (explicit field-by-field allowlist) but it has not been applied to this entity.Exploit Chain
id.PUT /api/v1/customtemplates/<id>(or equivalent endpoint) with a JSON body that includes"workspaceId": "<workspace-B-id>"(an arbitrary other workspace's UUID). State at this point: the request reaches the controller as a workspace-A authenticated request.Object.assign(updateEntity, body). The body'sworkspaceIdoverwrites the entity'sworkspaceIdfield. The persistence layer commits the row.Security Impact
Severity: High. Cross-workspace boundary violation by any authenticated workspace member.
Attacker capability: Any authenticated user with permission to update a customtemplate can move it to any workspace whose UUID they can guess or enumerate (workspace UUIDs are exposed in many API responses, so enumeration is trivial). CustomTemplates encode reusable workflow templates scoped to a workspace. Cross-workspace movement via
workspaceIdoverwrite makes the template appear in another workspace's marketplace listing.Preconditions: Authenticated session with edit permission for the source customtemplate. No second factor required. Workspace UUIDs are exposed via the
/api/v1/workspaceslisting or via any cross-referenced object'sworkspaceIdfield, so target enumeration is trivial.Differential: PoC-verified by source inspection of the original GHSA-q4pr-4r26-c69r. Patched build (with the suggested fix below) refuses the
workspaceIdfield; vulnerable build accepts it and persists it.Suggested Fix
Already fixed in PR FlowiseAI/Flowise#6129 (allowlist pattern applied).
Regression tests should assert that a request body containing
workspaceId,id,createdDate, orupdatedDateis rejected (or at minimum: does not change those columns on the persisted row) for both create and update paths.References