Skip to content
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

JavaScript CodeQL library updates: new Angular sink(s) #18397

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,26 @@ module DomBasedXss {
}
}

/**
* A write to the `innerHTML` property of a DOM element, viewed as an XSS sink.
*
* Uses the Angular Renderer2 API, instead of the default `Element.innerHTML` property.
*/
class AngularRender2SetPropertyInnerHtmlSink extends Sink {
AngularRender2SetPropertyInnerHtmlSink() {
exists(API::CallNode setProperty |
setProperty =
API::moduleImport("@angular/core")
.getMember("Renderer2")
.getInstance()
.getMember("setProperty")
.getACall() and
this = setProperty.getParameter(2).asSink() and
setProperty.getParameter(1).asSink().asExpr().(StringLiteral).getValue() = "innerHTML"
aegilops marked this conversation as resolved.
Show resolved Hide resolved
)
}
}

/**
* A value being piped into the `safe` pipe in a template file,
* disabling subsequent HTML escaping.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,32 @@

override string getSourceType() { result = ap.getSourceType() }
}

// Angular @Input() decorator on a member declaration.
class InputMember extends MemberDeclaration {

Check warning on line 189 in javascript/ql/lib/semmle/javascript/security/dataflow/RemoteFlowSources.qll

View workflow job for this annotation

GitHub Actions / qldoc

Missing QLdoc for class RemoteFlowSources::InputMember
InputMember() {
exists(Decorator decorator, Expr expr |
decorator.getElement() = this and
decorator.getExpression() = expr and
expr.(CallExpr).getCallee().(VarRef).getName() = "Input"
)
}
}

// Use of an Angular @Input() member.
class InputMemberUse extends DataFlow::Node {

Check warning on line 200 in javascript/ql/lib/semmle/javascript/security/dataflow/RemoteFlowSources.qll

View workflow job for this annotation

GitHub Actions / qldoc

Missing QLdoc for class RemoteFlowSources::InputMemberUse
InputMemberUse() {
exists(InputMember member, string memberName, ThisExpr ta, FieldAccess fa |
memberName = member.getName() and
fa.getBase() = ta and
fa.getPropertyName() = memberName and
this.asExpr() = fa
)
}
}

private class AngularInputUse extends RemoteFlowSource {
Fixed Show fixed Hide fixed
AngularInputUse() { exists(InputMemberUse inputUse | this = inputUse) }
Fixed Show fixed Hide fixed

override string getSourceType() { result = "Angular @Input()" }
}
Loading