Skip to content

Commit 1500089

Browse files
Add test cases for webforms auth via web.config files
1 parent 1b6e7f9 commit 1500089

File tree

11 files changed

+116
-4
lines changed

11 files changed

+116
-4
lines changed

csharp/ql/lib/semmle/code/csharp/security/auth/MissingFunctionLevelAccessControlQuery.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ predicate hasAuthViaCode(ActionMethod m) {
122122
)
123123
}
124124

125-
/** An `<authorization>` XML element that */
125+
/** An `<authorization>` XML element. */
126126
class AuthorizationXmlElement extends XmlElement {
127127
AuthorizationXmlElement() {
128128
this.getParent() instanceof SystemWebXmlElement and
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| Test1/EditProfile.aspx.cs:9:20:9:29 | btn1_Click | This action is missing an authorization check. |
2-
| Test1/ViewProfile.aspx.cs:14:20:14:36 | btn_delete1_Click | This action is missing an authorization check. |
2+
| Test1/ViewProfile.aspx.cs:12:20:12:36 | btn_delete1_Click | This action is missing an authorization check. |
3+
| Test3/B/EditProfile.aspx.cs:7:20:7:29 | btn1_Click | This action is missing an authorization check. |

csharp/ql/test/query-tests/Security Features/CWE-285/MissingAccessControl/Test1/ViewProfile.aspx.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
class ViewProfile : System.Web.UI.Page {
66
private void doThings() { }
77

8-
public System.Security.Principal.IPrincipal User { get; } // TODO: this should be in the stubs
9-
108
protected void btn_safe_Click(object sender, EventArgs e) {
119
doThings();
1210
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Web.UI;
3+
4+
class EditProfile2 : System.Web.UI.Page {
5+
private void doThings() { }
6+
7+
protected void btn1_Click(object sender, EventArgs e) {
8+
doThings();
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
3+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
4+
5+
<system.web>
6+
7+
<authorization>
8+
<deny users="?" />
9+
</authorization>
10+
11+
</system.web>
12+
</configuration>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Web.UI;
3+
4+
class EditProfile3 : System.Web.UI.Page {
5+
private void doThings() { }
6+
7+
protected void btn1_Click(object sender, EventArgs e) {
8+
doThings();
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Web.UI;
3+
4+
class EditProfile4 : System.Web.UI.Page {
5+
private void doThings() { }
6+
7+
protected void btn1_Click(object sender, EventArgs e) {
8+
doThings();
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Web.UI;
3+
4+
class EditProfile5 : System.Web.UI.Page {
5+
private void doThings() { }
6+
7+
protected void btn1_Click(object sender, EventArgs e) {
8+
doThings();
9+
}
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Web;
3+
using System.Web.Routing;
4+
5+
public class Global : System.Web.HttpApplication {
6+
7+
void Application_Start(object sender, EventArgs e) {
8+
RegisterRoutes(RouteTable.Routes);
9+
}
10+
11+
void Application_End(object sender, EventArgs e) { }
12+
13+
void Application_Error(object sender, EventArgs e) { }
14+
15+
void Session_Start(object sender, EventArgs e) { }
16+
17+
void Session_End(object sender, EventArgs e) { }
18+
19+
static void RegisterRoutes(RouteCollection routes) {
20+
routes.MapPageRoute("VirtualEditProfile",
21+
"Virtual/Edit",
22+
"~/C/EditProfile.aspx",
23+
false
24+
);
25+
}
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0"?>
2+
3+
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
4+
5+
<location path="A">
6+
<system.web>
7+
<authorization>
8+
<deny users="?" />
9+
</authorization>
10+
</system.web>
11+
</location>
12+
<location path="Virtual">
13+
<system.web>
14+
<authorization>
15+
<deny users="?" />
16+
</authorization>
17+
</system.web>
18+
</location>
19+
</configuration>

0 commit comments

Comments
 (0)