Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/server/src/controllers/assistants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const createAssistant = async (req: Request, res: Response, next: NextFunction)
const newAssistantCount = 1
await checkUsageLimit('flows', subscriptionId, getRunningExpressApp().usageCacheManager, existingAssistantCount + newAssistantCount)

body.workspaceId = workspaceId
const apiResponse = await assistantsService.createAssistant(body, orgId, workspaceId)

return res.json(apiResponse)
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/services/assistants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ const createAssistant = async (requestBody: any, orgId: string, workspaceId: str
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error creating new assistant - ${getErrorMessage(error)}`)
}
const newAssistant = new Assistant()
Object.assign(newAssistant, requestBody)
Object.assign(newAssistant, stripProtectedFields(requestBody))
newAssistant.workspaceId = workspaceId
Comment on lines +143 to +144
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

Avoid mass assignment from request bodies to entities. Instead of using Object.assign, explicitly map allowed properties. This prevents potential IDOR vulnerabilities and ensures sensitive fields like workspaceId are handled correctly from a trusted source (e.g., user session), as per the repository security rules.

Suggested change
Object.assign(newAssistant, stripProtectedFields(requestBody))
newAssistant.workspaceId = workspaceId
newAssistant.details = requestBody.details
newAssistant.credential = requestBody.credential
newAssistant.iconSrc = requestBody.iconSrc
newAssistant.type = requestBody.type
newAssistant.workspaceId = workspaceId
References
  1. Avoid mass assignment from request bodies to entities. Instead of using a generic assignment like Object.assign(entity, body), explicitly map allowed properties. Sensitive fields like workspaceId must be set on the server from a trusted source (e.g., user session), not from the client request body, to prevent IDOR vulnerabilities.


const assistant = appServer.AppDataSource.getRepository(Assistant).create(newAssistant)
const dbResponse = await appServer.AppDataSource.getRepository(Assistant).save(assistant)
Expand Down
Loading