-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Blazor: Add non-local jump node for parameter passing #19122
C#: Blazor: Add non-local jump node for parameter passing #19122
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 |
Check warning
Code scanning / CodeQL
Query test without inline test expectations Warning test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
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
Names
was tainted,Then a read in the
DisplayName
component would be considered tainted