Hi everyone,
I searched and found there are 2 methods:
using uuid, which requires adding uuid for my migrations table and following by a trait so that it can be used everywhere
this is to encyptIs it use to encrypt id in blade like: encrypt($blog->id) and decrypt it in controller like: Crypt::decrypt($id);
However this one is not very secure, if the user change the value, and an exception can be thrown.
Is there a way that i can make the secod method more secure to use it ?
Or may be you have other suggestion ?
Thanks a lot !
Yes, many developers prefer uuid, but i guess i have to modify all my migration tables by adding uuid column, right ? which is not practical when i want add it for an app in production mode,
the second thing, is that uuid can slow the performence as it generates a long string encryption, but its recommanded when using multi dbs.
check if it does exists in database as an id. If doesn't exist - throw 404. this sounds good if its secure
I'm sending IDs from blades via update,create,show, forms to controllers, and vise versa,
and i don't want to expose IDs in url traffic which make my app vulnerable to attach,
i'm looking for a way that i hide IDs on fly
@Zoul How does your id exposing make your app vulnerable? are you not protecting your app from that kind of thing? For example, you can easily validate your delete function so that the correct person deletes the correct data whether the id is exposed to them or not. so what vulnerability actually your trying to point out?
Let me take the id of 2 as an example that is being sent from blade to controller, and send the id back again
with more the exact record, this id looks like this in url:
Thanks @MohamedTammam for your help !
I don't know if exposing IDs in url is not dangerous, i'm about to secure my app
before deplying it in production, and i found developers talking about uuid, ecrypting ids
that should be hidden from url,
Do you think, if i'm sending id number 1 which passes through url as 1 and getting it
in controller and then check and getting its reocrd from db and send it back again in blade, is save ?
thanks @jlrdw for your support !
If i got you correctly, you are saying, when authenticating users, its not applicable,
but what is for when using other data, like blogs etc, does not that matter ?
Yes, you should do some kind of validation for those sort of things that you've mentioned. People use id / slug / UUID / GUID in urls and it is totally fine.
@Zoul There's no security issue here. People use something different than the id for different cases.
For example, slugs for better seo, uuid to prevent users to find the order of records, for example if you see blog/2 you know that the next blog is blog/3 etc.
But there's no a security issue by exposing the id.
thanks a lot for your valuable time @dincho186, its very good article explaining uuid,
i'm trying to avoid using uuid if i find another option, although its the most recommended,
thanks alot for your support @MohamedTammam,
People use something different than the id for different cases. you are right, as others confirmed that
for authenticated user no need to use uuids,guids or hashids but other than that, its not recommaed to expose ids in urls
@zoul Yes, pitting auto-incrementing primary keys in URLs can be a security issue if it means someone can just create a script to enumerate your IDs and scrape your data.
You can use UUIDs as has been mentioned. I wouldn’t put encrypted IDs in URLs because if you ever change your encryption key, then that’s going to “break” every URL for your site. So URLs people have bookmarked/favourited, in their browsers’ suggestions, URLs indexed by search engines, etc. Also, if someone does identify encrypted IDs as encrypted strings, then they can start attacking that by trying to decrypt them and if they discover your encryption key, then you have larger problems, especially if you’re using encryption anywhere else in your app.
Another alternative is hashids. This will let you put pseudo-random alphanumeric IDs in URLs that you can then decode server-side back to the integer primary key value.
@martinbeancan be a security issue if it means someone can just create a script to enumerate your IDs and scrape your data. ->
Unless you have correct authorization and validation right?