Why exposing database primary keys in URLs is a security risk
Using sequential integer primary keys in public-facing URLs can leak sensitive business metrics, such as order volumes, and make it easy for attackers to enumerate records belonging to other users. This vulnerability, known as Insecure Direct Object Reference (IDOR), can turn a single missing authorization check into a large-scale data breach. The recommended fix is to maintain two separate identifiers: an internal integer primary key for database operations and a random UUID as a public-facing identifier for URLs and APIs. A UUID reveals no information about data volume and cannot be easily guessed or enumerated by an attacker. However, developers are cautioned that an unguessable ID is not a substitute for proper ownership checks, which must still be enforced on every request.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in