Skip to content

Conversation

@christopherholland-workday
Copy link
Contributor

Fix improper mass assignment in account registration by creating an allow-list of fields that can be copied over, while leaving the server-side generated fields to be generated server-side.

@FlowiseAI FlowiseAI deleted a comment from gemini-code-assist bot Jan 29, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly identifies and fixes a mass assignment vulnerability in the account registration flow by introducing an allow-list of fields in account.service.ts. This is a great security improvement.

However, I've found a critical issue in the changes made to user.service.ts. The refactoring of createNewUser to also perform sanitization breaks the existing user invitation functionality. Since the registration flow is already secured by the changes in account.service.ts, I recommend reverting the changes in user.service.ts.

Additionally, I've left a comment in account.service.ts with a suggestion to improve type safety by removing as any casts.

Comment on lines 86 to 96
if (data.user && typeof data.user === 'object' && !Array.isArray(data.user)) {
for (const field of allowedUserFields) {
if (data.user[field] !== undefined) {
sanitized.user[field] = data.user[field] as any
}
}
// Referral is used for Stripe referral tracking in CLOUD; not a User entity column.
if ('referral' in data.user && data.user.referral !== undefined) {
;(sanitized.user as any).referral = data.user.referral
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of as any in this block undermines TypeScript's type safety and should be avoided.

  • On line 89, the cast is likely unnecessary. If data.user and sanitized.user are both typed as Partial<User>, a direct assignment sanitized.user[field] = data.user[field] should be valid.
  • On line 94, casting to any to add the referral property is a workaround. A better, more type-safe solution would be to extend the type of the user object in the AccountDTO to include this optional property, e.g., user: Partial<User> & { referral?: string }.

Refactoring to remove these as any casts would improve code quality and maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants