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 {
5656}
5757
5858/**
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.
6160 */
62- class AttributeCollectionSink extends HtmlSink {
61+ deprecated class AttributeCollectionSink extends DataFlow :: ExprNode {
6362 AttributeCollectionSink ( ) {
6463 exists ( SystemWebUIAttributeCollectionClass ac , Parameter p |
6564 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 |
33| script.aspx:12:1:12:14 | <%= ... %> | <outside test directory> | Request |
44| script.aspx:16:1:16:34 | <%= ... %> | <outside test directory> | QueryString |
55| 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
1717 Table table ;
1818 Label label ;
1919 string connectionString ;
20+ public Button button ;
2021
2122 public void WebUIXSS ( )
2223 {
@@ -100,6 +101,10 @@ public void HtmlEncoded(HttpContextBase context)
100101 // GOOD: HTML encoding
101102 string name = context . Request . QueryString [ "name" ] ;
102103 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 ) ;
103108 }
104109
105110 public void UrlEncoded ( HttpContextBase context )
You can’t perform that action at this time.
0 commit comments