File tree Expand file tree Collapse file tree 5 files changed +89
-81
lines changed
lib/semmle/code/csharp/security/dataflow/flowsinks
test/query-tests/Security Features/CWE-079/XSSAsp Expand file tree Collapse file tree 5 files changed +89
-81
lines changed Original file line number Diff line number Diff line change @@ -56,10 +56,9 @@ class HtmlTextWriterSink extends HtmlSink {
56
56
}
57
57
58
58
/**
59
- * An expression that is used as an argument to an HTML sink method on
60
- * `AttributeCollection`.
59
+ * DEPRECATED: Attribute collections are no longer considered HTML sinks.
61
60
*/
62
- class AttributeCollectionSink extends HtmlSink {
61
+ deprecated class AttributeCollectionSink extends DataFlow :: ExprNode {
63
62
AttributeCollectionSink ( ) {
64
63
exists ( SystemWebUIAttributeCollectionClass ac , Parameter p |
65
64
p = ac .getAddMethod ( ) .getParameter ( 1 ) or
Original file line number Diff line number Diff line change
1
+ ---
2
+ category : minorAnalysis
3
+ ---
4
+ * C#: The indexer and ` Add ` method on ` System.Web.UI.AttributeCollection ` is no longer considered an HTML sink.
Original file line number Diff line number Diff line change 1
- | script.aspx:4:1:4:23 | <%= ... %> | XSS.cs:115 :16:115 :29 | someJavascript |
2
- | script.aspx:8:1:8:12 | <%= ... %> | XSS.cs:122 :24:122 :28 | Field |
1
+ | script.aspx:4:1:4:23 | <%= ... %> | XSS.cs:120 :16:120 :29 | someJavascript |
2
+ | script.aspx:8:1:8:12 | <%= ... %> | XSS.cs:127 :24:127 :28 | Field |
3
3
| script.aspx:12:1:12:14 | <%= ... %> | <outside test directory> | Request |
4
4
| script.aspx:16:1:16:34 | <%= ... %> | <outside test directory> | QueryString |
5
5
| script.aspx:20:1:20:41 | <%= ... %> | <outside test directory> | QueryString |
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class XSS
17
17
Table table ;
18
18
Label label ;
19
19
string connectionString ;
20
+ public Button button ;
20
21
21
22
public void WebUIXSS ( )
22
23
{
@@ -100,6 +101,10 @@ public void HtmlEncoded(HttpContextBase context)
100
101
// GOOD: HTML encoding
101
102
string name = context . Request . QueryString [ "name" ] ;
102
103
new StringContent ( HttpUtility . HtmlEncode ( name ) ) ;
104
+
105
+ // GOOD: Implicit HTML encoding
106
+ string html = context . Request . QueryString [ "html" ] ;
107
+ button . Attributes . Add ( "data-href" , html ) ;
103
108
}
104
109
105
110
public void UrlEncoded ( HttpContextBase context )
You can’t perform that action at this time.
0 commit comments