You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7c230d6
Browse filesBrowse the repository at this point in the historyBrowse files
<p>Resources like comments or user profiles can be accessed and modified through an action method. To target a certain resource, the action method accepts an ID parameter pointing to that specific resource. If the methods do not check that the current user is authorized to access the specified resource, an attacker can access a resource by guessing or otherwise determining the linked ID parameter.</p>
7
+
8
+
</overview>
9
+
<recommendation>
10
+
<p>
11
+
Ensure that the current user is authorized to access the resource of the provided ID.
12
+
</p>
13
+
14
+
</recommendation>
15
+
<example>
16
+
<p>In the following example, in the "BAD" case, there is no authorization check, so any user can edit any comment for which they guess or determine the ID parameter.
17
+
The "GOOD" case includes a check that the current user matches the author of the comment, preventing unauthorized access.</p>
18
+
<samplesrc="WebFormsExample.cs" />
19
+
<p>The following example shows a similar scenario for the ASP.NET Core framework. As above, the "BAD" case provides an example with no authorization check, and the first "GOOD" case provides an example with a check that the current user authored the specified comment. Additionally, in the second "GOOD" case, the `Authorize` attribute is used to restrict the method to administrators, who are expected to be able to access arbitrary resources.</p>
20
+
<samplesrc="MVCExample.cs" />
21
+
22
+
</example>
23
+
<references>
24
+
25
+
<li>OWASP: <ahref="https://wiki.owasp.org/index.php/Top_10_2013-A4-Insecure_Direct_Object_References">Insecure Direct Object Refrences</a>.</li>
26
+
<li>OWASP: <ahref="https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/04-Testing_for_Insecure_Direct_Object_References">Testing for Insecure Direct Object References</a>.</li>
27
+
<li>Microsoft Learn: <ahref="https://learn.microsoft.com/en-us/aspnet/core/security/authorization/resourcebased?view=aspnetcore-7.0">Resource-based authorization in ASP.NET Core</a>.</li>
0 commit comments