[GH-ISSUE #961] Disallow user image upload by default #8522

Closed
opened 2026-04-13 03:36:55 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @jamesjulich on GitHub (Dec 20, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/961

Is this suited for github?

  • Yes, this is suited for github

Not all services want/need to include the ability to have user profile pictures. Allowing users to upload images can lend itself to abuse. Imagine a scenario where a malicious user uploads inappropriate/illegal content. This could expose a company to risk from storing these images. Because storing this data is very risky, the default behavior of better-auth should be to disallow user image upload.

Even if image upload is not possible via the client, the server's public HTTP API will allow it. A technically savvy user could upload a user image using a tool like Postman. Although we can prevent other users from seeing these images by simply not implementing user profile images within the client, it is still a risk to be storing user-provided image data in a company database.

Describe the solution you'd like

better-auth should provide safe defaults, so better-auth should disable user image upload by default.

I think either solution would work fine:

  1. Create an enableImageUpload option in the betterAuth config object that defaults to false. If false, this would cause an error to be thrown any time an image (url or actual image data) is included in a signup/update user request. This would make sure that services have to explicitly opt-in to allowing users to upload images for their account.

  2. Remove the 'image' column from the default user table schema. Create a plugin to work with images. This would be a larger refactor, but I think that this behavior feels more appropriate since images are not always a core feature of AuthN libraries. Moving this functionality to a plugin forces developers to opt-in before use by installing the plugin.

Describe alternatives you've considered

It is currently possible to write a plugin that blocks image upload by checking for the presence of "image" in request bodies. This can prevent users from uploading images.

However, not all services/companies may be aware that it is even possible to upload images. Making image upload opt-in only ensures that services are not accidentally exposing themselves to risk. It also gives developers a chance to pause and reflect on the risk they are about to take on before enabling the feature.

Additional context

Great project! Loving this so far...keep up the great work! This is the best AuthN library I have seen in JS ecosystem by a long margin. The fact that this is still an early iteration of the project makes me very excited for the future.

Originally created by @jamesjulich on GitHub (Dec 20, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/961 ### Is this suited for github? - [X] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Not all services want/need to include the ability to have user profile pictures. Allowing users to upload images can lend itself to abuse. Imagine a scenario where a malicious user uploads inappropriate/illegal content. This could expose a company to risk from storing these images. Because storing this data is very risky, the default behavior of better-auth should be to disallow user image upload. Even if image upload is not possible via the client, the server's public HTTP API will allow it. A technically savvy user could upload a user image using a tool like Postman. Although we can prevent other users from seeing these images by simply not implementing user profile images within the client, it is still a risk to be storing user-provided image data in a company database. ### Describe the solution you'd like better-auth should provide safe defaults, so better-auth should disable user image upload by default. I think either solution would work fine: 1) Create an enableImageUpload option in the betterAuth config object that defaults to false. If false, this would cause an error to be thrown any time an image (url or actual image data) is included in a signup/update user request. This would make sure that services have to explicitly opt-in to allowing users to upload images for their account. 2) Remove the 'image' column from the default user table schema. Create a plugin to work with images. This would be a larger refactor, but I think that this behavior feels more appropriate since images are not always a core feature of AuthN libraries. Moving this functionality to a plugin forces developers to opt-in before use by installing the plugin. ### Describe alternatives you've considered It is currently possible to write a plugin that blocks image upload by checking for the presence of "image" in request bodies. This can prevent users from uploading images. However, not all services/companies may be aware that it is even possible to upload images. Making image upload opt-in only ensures that services are not accidentally exposing themselves to risk. It also gives developers a chance to pause and reflect on the risk they are about to take on before enabling the feature. ### Additional context Great project! Loving this so far...keep up the great work! This is the best AuthN library I have seen in JS ecosystem by a long margin. The fact that this is still an early iteration of the project makes me very excited for the future.
GiteaMirror added the locked label 2026-04-13 03:36:55 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 20, 2024):

Hey, thanks for the kind words! we're planning to make non-essential user fields like image, name, and so on configurable. But that said, image upload isn't managed by us. it's just a database field. So, people can't really upload images other than filling the value with random data. This can still be prevented by using database hooks, the upcoming hooks feature, or by creating a plugin.

<!-- gh-comment-id:2556889671 --> @Bekacru commented on GitHub (Dec 20, 2024): Hey, thanks for the kind words! we're planning to make non-essential user fields like image, name, and so on configurable. But that said, image upload isn't managed by us. it's just a database field. So, people can't really upload images other than filling the value with random data. This can still be prevented by using database hooks, the upcoming hooks feature, or by creating a plugin.
Author
Owner

@Kinfe123 commented on GitHub (Apr 11, 2025):

there already exist an issue regarding to this. closing this now

<!-- gh-comment-id:2797345268 --> @Kinfe123 commented on GitHub (Apr 11, 2025): there already exist an issue regarding to this. closing this now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8522