Providing your primary keys (especially if they are predictable) is a vulnerability called the Insecure Direct Object Reference.
Having a URL (or any other parameter provided by the client), for example:
http:
You give your end users the opportunity to contact these variables and transfer any data they like. A control measure to mitigate this vulnerability is to instead refer to indirect object references. This may seem like a big change, but it is not necessary. You do not need to go and redo all your tables or anything else, you can do this just by knowing your data using an indirect reference card.
Consider this: you have a user who makes a purchase on your site. And when it is time to pay, they are presented with the pop-up credit card numbers that you have "in the file." If you look at the code for the drop-down list, you will see that the credit card numbers are associated with keys 8055, 9044 and 10099.
The user may look at this and think that they are very similar to automatic incremental primary keys (the user will probably be right). So he begins to try other keys to see if he can pay with another card.
Now, technically, you should have a server-side code that ensures that the selected card is part of the user account and that they can use it. This is a contrived example. For now, we assume that this is not the case or that it is a different type of form that may not have such server-side control.
So, how do we prevent the end user from choosing a key that should not be available to them?
Instead of showing them a direct link to a record in the database, give them an indirect link.
Instead of inserting database keys into the drop-down list, we will create an array on the server and write it to the user session.
Array cards = new Array(3); cards[0] = 8055; cards[1] = 9044; cards[2] = 10099;
In the drop-down list, we will now provide a link to the index of the array in which the map is stored. Therefore, instead of seeing the actual keys, the end user will see the values ββ0, 1, and 2 if they look at the source.
When the form is submitted, one of these values ββwill be submitted together. Then we get the array from the user session and use the index to get the value. The actual key never left the server.
And the user can transmit different values ββthroughout the day if he wants, but he will never get a result different from his own cards, no matter what access control on the server side is in place.
Keep in mind that when using the passed index to get the value, if the user is not working with it, you may get some exceptions (ArrayOutOfBounds, InvalidIndex, whatever). So, wrap this stuff in try / catch so that you can suppress these errors and report crashes to look for hack attempts.
Hope this helps.
To learn more about Insecure Direct Object References, check out OWASP Top 10. This is risk number A4. https://www.owasp.org/index.php/Top_10_2010-A4-Insecure_Direct_Object_References