@@ -22,9 +22,12 @@ const createVariable = async (req: Request, res: Response, next: NextFunction) =
2222 throw new InternalFlowiseError ( StatusCodes . NOT_FOUND , `Error: toolsController.createTool - workspace ${ workspaceId } not found!` )
2323 }
2424 const body = req . body
25- body . workspaceId = workspaceId
25+ // Explicit allowlist — id/ workspaceId/timestamps must not be overrideable by client
2626 const newVariable = new Variable ( )
27- Object . assign ( newVariable , body )
27+ if ( body . name !== undefined ) newVariable . name = body . name
28+ if ( body . value !== undefined ) newVariable . value = body . value
29+ if ( body . type !== undefined ) newVariable . type = body . type
30+ newVariable . workspaceId = workspaceId
2831 const apiResponse = await variablesService . createVariable ( newVariable , orgId )
2932 return res . json ( apiResponse )
3033 } catch ( error ) {
@@ -91,8 +94,11 @@ const updateVariable = async (req: Request, res: Response, next: NextFunction) =
9194 return res . status ( 404 ) . send ( 'Variable not found in the database' )
9295 }
9396 const body = req . body
97+ // Explicit allowlist — id/workspaceId/timestamps must not be overrideable by client
9498 const updatedVariable = new Variable ( )
95- Object . assign ( updatedVariable , body )
99+ if ( body . name !== undefined ) updatedVariable . name = body . name
100+ if ( body . value !== undefined ) updatedVariable . value = body . value
101+ if ( body . type !== undefined ) updatedVariable . type = body . type
96102 const apiResponse = await variablesService . updateVariable ( variable , updatedVariable )
97103 return res . json ( apiResponse )
98104 } catch ( error ) {
0 commit comments