File tree Expand file tree Collapse file tree
packages/server/src/services/leads Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,8 +25,16 @@ const createLead = async (body: Partial<ILead>) => {
2525 const chatId = body . chatId ?? uuidv4 ( )
2626
2727 const newLead = new Lead ( )
28- Object . assign ( newLead , body )
29- Object . assign ( newLead , { chatId } )
28+ // Whitelist allowed fields to prevent mass assignment vulnerability
29+ // Only copy explicitly allowed fields from request body
30+ const allowedFields : ( keyof ILead ) [ ] = [ 'chatflowid' , 'name' , 'email' , 'phone' ]
31+ for ( const field of allowedFields ) {
32+ if ( body [ field ] !== undefined ) {
33+ newLead [ field ] = body [ field ] as any
34+ }
35+ }
36+ // Set chatId explicitly (either from body or auto-generated)
37+ newLead . chatId = chatId
3038
3139 const appServer = getRunningExpressApp ( )
3240 const lead = appServer . AppDataSource . getRepository ( Lead ) . create ( newLead )
You can’t perform that action at this time.
0 commit comments