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
Copy file name to clipboardExpand all lines: csharp/ql/src/Security Features/CWE-639/InsecureDirectObjectReference.qhelp
+7-11Lines changed: 7 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,7 @@
3
3
"qhelp.dtd">
4
4
<qhelp>
5
5
<overview>
6
-
<p>When an action method accepts an ID parameter used to control which resource (e.g. a comment, a user profile, etc)
7
-
is being accessed/modified, checks should me made to ensure that the current user is authorized to access that resource.
8
-
Otherwise, an attacker could access an arbitrary resource by guessing the ID parameter.</p>
6
+
<p>Resources like comments or user profiles can be accessed and modified through an action method. To find a specific resource, the action method accepts an ID parameter that determines which resource to access. 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 the ID parameter.</p>
9
7
10
8
</overview>
11
9
<recommendation>
@@ -15,20 +13,18 @@ Ensure that the current user is authorized to access the resource of the provide
15
13
16
14
</recommendation>
17
15
<example>
18
-
<p>In the following example, in the case marked BAD, there is no authorization check, so any user is able to edit any comment.
19
-
In the case marked GOOD, there is a check that the current usr matches the author of the comment.</p>
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 the ID parameter.
17
+
The "GOOD" case includes a check that the current user matches the author of the comment, preventing unauthorized access.</p>
20
18
<samplesrc="WebFormsExample.cs" />
21
-
<p>The following example shows a similar case for the ASP.NET Core framework. In the third case, the `Authorize` attribute is used
22
-
to restrict the method to only administrators, which are expected to be able to access arbitrary resources.
23
-
</p>
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>
24
20
<samplesrc="MVCExample.cs" />
25
21
26
22
</example>
27
23
<references>
28
24
29
-
<li>OWASP - <ahref="https://wiki.owasp.org/index.php/Top_10_2013-A4-Insecure_Direct_Object_References">Insecure Direct Object Refrences</a>.</li>
30
-
<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>
31
-
<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>
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