File tree Expand file tree Collapse file tree 5 files changed +32
-0
lines changed
query-tests/Security Features/CWE-639/WebFormsTests Expand file tree Collapse file tree 5 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Web . UI ;
3
+
4
+ class EditComment : System . Web . UI . Page {
5
+
6
+ // BAD - Any user can access this method.
7
+ protected void btn1_Click ( object sender , EventArgs e ) {
8
+ string commentId = Request . QueryString [ "Id" ] ;
9
+ Comment comment = getCommentById ( commentId ) ;
10
+ comment . Text = "xyz" ;
11
+ }
12
+
13
+ // GOOD - The user ID is verified.
14
+ protected void btn2_Click ( object sender , EventArgs e ) {
15
+ string commentId = Request . QueryString [ "Id" ] ;
16
+ Comment comment = getCommentById ( commentId ) ;
17
+ if ( comment . AuthorName == User . Identity . Name ) {
18
+ comment . Text = "xyz" ;
19
+ }
20
+ }
21
+
22
+ class Comment {
23
+ public string Text { get ; set ; }
24
+ public string AuthorName { get ; }
25
+ }
26
+
27
+ Comment getCommentById ( string id ) { return null ; }
28
+ }
Original file line number Diff line number Diff line change
1
+ | EditComment.aspx.cs:7:20:7:29 | btn1_Click | This method may not verify which users should be able to access resources of the provided ID. |
Original file line number Diff line number Diff line change
1
+ Security Features/CWE-639/InsecureDirectObjectReference.ql
Original file line number Diff line number Diff line change
1
+ semmle-extractor-options: /r:System.Collections.Specialized.dll ${testdir}/../../../../resources/stubs/System.Web.cs
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ public class Control
82
82
public class Page
83
83
{
84
84
public System . Security . Principal . IPrincipal User { get ; }
85
+ public System . Web . HttpRequest Request { get ; }
85
86
}
86
87
87
88
interface IPostBackDataHandler
You can’t perform that action at this time.
0 commit comments