C#: Blazor: Add non-local jump node for parameter passing#19122
C#: Blazor: Add non-local jump node for parameter passing#19122tamasvajk merged 16 commits intogithub:mainfrom
Conversation
csharp/ql/integration-tests/all-platforms/blazor_build_mode_none/XSS.qlref
Fixed
Show fixed
Hide fixed
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll
Fixed
Show fixed
Hide fixed
| @@ -0,0 +1 @@ | |||
| Security Features/CWE-079/XSS.ql No newline at end of file | |||
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning test
michaelnebel
left a comment
There was a problem hiding this comment.
Thank you for following up on this @tamasvajk !
Would it be possible to add a brief explanation in the PR description on, which jump step we are modelling?
csharp/ql/integration-tests/all-platforms/blazor_build_mode_none/XSS.expected
Outdated
Show resolved
Hide resolved
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll
Outdated
Show resolved
Hide resolved
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll
Outdated
Show resolved
Hide resolved
csharp/ql/lib/semmle/code/csharp/frameworks/microsoft/aspnetcore/Components.qll
Outdated
Show resolved
Hide resolved
| query: Security Features/CWE-079/XSS.ql | ||
| postprocess: utils/test/PrettyPrintModels.ql |
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning
| query: Security Features/CWE-079/XSS.ql | ||
| postprocess: utils/test/PrettyPrintModels.ql |
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning
| query: Security Features/CWE-079/XSS.ql | ||
| postprocess: utils/test/PrettyPrintModels.ql |
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning
michaelnebel
left a comment
There was a problem hiding this comment.
Thank you for looking into it; One clarifying follow-up question and one comment.
| { | ||
| builder.OpenElement(2, "li"); | ||
| builder.OpenComponent<VulnerableBlazorApp.Components.Name>(3); | ||
| builder.AddComponentParameter(4, nameof(VulnerableBlazorApp.Components.Name.TheName), name); |
There was a problem hiding this comment.
So, the jump step ensures that we have data flow from name into the property VulnerableBlazorApp.Components.Name.TheName?
There was a problem hiding this comment.
Yes, there's flow from name to the property reads of VulnerableBlazorApp.Components.Name.TheName.
| Expr getParameterValue() { result = this.getArgument(2) } | ||
| } | ||
|
|
||
| private class ComponentParameterJump extends DataFlow::NonLocalJumpNode { |
There was a problem hiding this comment.
The NonLocalJumpNode is a bi-directional imported abstract class, but this is not that evident. I think it makes sense to explicitly make a private import module above the NonLocalJumpNode declaration that imports all file modules that extends the class.
There was a problem hiding this comment.
Do you mean the below?
--- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll
+++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll
@@ -147,6 +147,10 @@ predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
pragma[inline]
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
+private import semmle.code.csharp.frameworks.microsoft.aspnetcore.Components
+private import semmle.code.csharp.frameworks.Razor
+private import semmle.code.csharp.frameworks.NHibernate
+
/**
* A data flow node that jumps between callables. This can be extended in
* framework code to add additional data flow steps.There was a problem hiding this comment.
Yes, and just in a private module.
/**
* A module importing the modules that provide non local jump node declarations,
* ensuring that they are visible to the taint tracking / data flow library.
*/
private module JumpNodes {
private import semmle.code.csharp.frameworks.microsoft.aspnetcore.Components
private import semmle.code.csharp.frameworks.Razor
private import semmle.code.csharp.frameworks.NHibernate
}
|
I have started a DCA run. Also, it would be nicer to use inline test expectations, as suggested by QL4QL. |
Should inline test expectations work when the source and sink locations are mapped to |
Sorry, you are right, it doesn't work for |
Continuation of #18930.
Establishes the pattern that when a variable is passed to a subcomponent, the reads of the set property are considered tainted.
For example, if in the following example
Nameswas tainted,Then a read in the
DisplayNamecomponent would be considered tainted