Is this a security problem? #3295
-
|
I am new to Pocketbase and I'm trying to wrap my head around API rules. I'm wondering if what I'm doing is a bad idea for security reasons. Hopefully, one of you can shed some light on this. Note.. I am using SvelteKit... I have a field called "clients" in my users collection. I'd like to be able to update the clients field in a +page.server.js file, and the update would not necessarily come from an authenticated user. However, I'm not sure if this would cause a vulnerability where someone could maliciously update a field in users that I'd rather only the id = @request.auth.id. Is there a way to do this? Can I somehow set the API update rule to allow the clients field to be updated by everyone, without opening myself up to a vulnerability? Or would I be better off creating a new collection with the update API rule blank with a relation to users collection? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I don't understand the described requirements and what is the desired behavior. What is the purpose of the "clients" field and how it is related to the users collection? What do you mean by "the update would not necessarily come from an authenticated user"? Should guests/unauthorized clients be able to change the value of this field for any user? |
Beta Was this translation helpful? Give feedback.
In this case - Yes, it would be better to have a separate collection with its own API rules.
Technically it is possible to restrict the update to only of a single field, but it'll be difficult and error prone since you'll have to blacklist/disallow the submission of all other user fields manually, something like: