Back

Is it possible to ban an IP?

  • 0
  • Self Hosted
ianmont
28 Nov, 2023, 19:29

yes

TL;DR
User is asking if it is possible to ban an IP address. They also discuss creating accounts using node-appwrite and preventing users from modifying the payload to assign their own IDs. Additionally, they mention testing and finding that it is possible to register a user with a specific ID. They ask how to prevent this and if they need to create a server-side function for user creation. The solution suggested is to create a server-side function to prevent abuse and perform extra server-side validations. The user also mentions setting limits on the number of executions and changing the status of a user's plan. They ask how to prevent modification of the client-side code and
ianmont
28 Nov, 2023, 19:29

like some extension?

D5
28 Nov, 2023, 19:30

Nope

D5
28 Nov, 2023, 19:30

All browsers have it

D5
28 Nov, 2023, 19:32

Could you please explain further what limits on executions you're trying to achieve client sided?

D5
28 Nov, 2023, 19:33

So I can guide you to achieve the same server side securely

ianmont
28 Nov, 2023, 19:42

Sure the only 2 limits I have are to check if the user plan has expired, if it is expired you cannot execute that function.

If it is not expired, then it checks if plan.userGeneratedCount >= plan.planGenerateLimit and if it is correct then it gives it a toast that says it has exceeded its limit

I think there are 2 things that could easily be put inside the function code

ianmont
28 Nov, 2023, 19:46

I think he definitely modified the code in the browser, I'm checking one of the 4000 executions of the function and it has things that only a plan.planType == "admin" could see and put in the payload of the function

Its crazy that someone can modify the client side code, even if I add those validations inside the function code, how can I prevent it from modifying the code in the browser for now?

D5
28 Nov, 2023, 20:11

How do you get or generate plan.status?

ianmont
28 Nov, 2023, 20:18

The "plan" is a document that each user has that is created at the time of registration and has an attribute called status and that attribute by default is active, however when a user purchases a plan and 30 days pass and does not renew, the status is now changed to expired

D5
28 Nov, 2023, 20:34

So there's no hard limit on the amount of executions in such period?

D5
28 Nov, 2023, 20:34

I think you should have a function that gets triggered by cron and changes status

ianmont
28 Nov, 2023, 21:30

I have not yet set a limit on the number of executions, it's bad for me not to have planned it that way, but right now I will do it

D5
28 Nov, 2023, 21:33

Yes, I think in your case you should do it to prevent abuse, and as said, changin status with a function instead of client sided

ianmont
30 Nov, 2023, 02:06

Continuing this case, I am creating functions for each operation that has to do with a post or patch request in my application to put validations within that function, to prevent a user from modifying the payload again so it has to go through extra server side validations

However, while testing, I noticed that if I modify the POST payload when creating an account and change the ID of unique() to a "1", for example, it is possible to register a user with the ID of 1, the ID shouldn't it be assigned automatically on the server side?

how can I prevent someone from creating an account with the ID they want? or do I also need to create a function that anyone can run that creates the user and assigns the ID on the server side?

Ernest
30 Nov, 2023, 11:11

Passing unique() is what causes appwrite to autogenerate the id. How does a custom id affect your functions/business logic?

D5
30 Nov, 2023, 11:18

You can perform the assign server sided with a function

D5
30 Nov, 2023, 11:19

As I said, to prevent it from being modified

Ernest
30 Nov, 2023, 11:43

I'm still genuinely curious about how custom ids are a security risk. The id of a user or document is pretty much public so whether it was custom or autogenerated an attacker can still find out the id.

ianmont
30 Nov, 2023, 17:13

It is public and I think it is not a security risk, even so, for my webapp I dont want anyone to be able to modify the payload of creating an account and give themselves IDs of "1" or "69" or whatever

ianmont
30 Nov, 2023, 17:14

I was thinking of also making a function for that, but within the appwrite docs, I can't find where accounts can be created. If I change to "Platform: NodeJS" the "create account" disappears, but if I put something like "Platform: Web" appears again

Is it possible to create accounts using node-appwrite?

Ernest
30 Nov, 2023, 17:16

Ok, got it. Then all you need to is have a function override the id field and set it to "unique()"

Ernest
30 Nov, 2023, 17:18

Accounts docs are for the client sdks for servers checkout the Users docs https://appwrite.io/docs/references/cloud/server-nodejs/users

ianmont
30 Nov, 2023, 17:19

thanks Ernest I'll take a look

Drake
1 Dec, 2023, 18:10

With a server SDK, you would use use the user API

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more