Mask ID - Best option

ANB 181 Reputation points
2021-12-06T04:55:43.527+00:00

www.mysite.com?productId=123

What would be the best practice to mask ID on the URL and avoid business leaks and security?

  1. Hash the productId
  2. Use Guid
  3. Have a guid column on the same product table (productId (int), productIdGuid (guid)

A different option ?
Thx

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

Accepted answer
  1. Yijing Sun-MSFT 7,096 Reputation points
    2021-12-06T08:21:32.37+00:00

    Hi @ANB ,
    For a well designed system, users manipulating URLs should not be an issue. Even if you send the data in an HTTP Post body, users can still manipulate it using an intercepting proxy such as Burp.

    Relying on secrecy of IDs (for example, choosing IDs randomly) is also not a solution. In pentester terminology, you will be vulnerable to direct object reference. The classical terminology for this flaw is violation of the complete mediation principle.

    Instead of worrying about what users may do with URLs and content sent to your server, you should be securing the server from malicious inputs. The issue here is authorisation. I recommend you have a good, thorough read of Securing your ASP.NET MVC 4 App and the new AllowAnonymous Attribute and NerdDinner Step 9: Authentication and Authorization.

    Best regards,
    Yijing Sun


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.