I recently inherited an ASP.NET MVC 4 database. One of the problems I noted was the use of some database identifiers (ints) in URLs, as well as in HTML form submissions. The code in its current state can be used both for URL search and for creating custom HTML messages with different numbers.
Now that I can easily fix problems with URLs using session state or additional authentication, I'm less sure about the database identifiers that are embedded in the HTML code that the site pulls out (i.e. I give them a drop-down list option fill). When identifiers are returned in a message, how can I be sure that I will put them there as valid options? What is considered “best practice” to solve this problem?
While I appreciate that I could just “DIRECT it”. I hesitate to do this because I find them a pain in the ass to work when debugging databases.
Do I have a choice here? Should I have a GUID to prevent easy guessing of identifiers, or is there some DRY mechanism that I can use to check if identifiers are used when they return to the site?
UPDATE: A commenter asked about the exploits I am expecting. Suppose I spit out an HTML form with a drop-down list of all the places from which you can import a "treasure". The identifier of the locations owned by the user is 1.2 and 3, they are presented in HTML. But the user learns html, scripts with him and decides to build a POST with an identifier of 4 selected. 4 is not his location, his alien.
source share