mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Add webview cert validation query
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import java
|
||||
|
||||
class OnReceivedSslErrorMethod extends Method {
|
||||
OnReceivedSslErrorMethod() {
|
||||
this.hasQualifiedName("android.webkit", "WebViewClient", "onReceivedSslError")
|
||||
}
|
||||
|
||||
Parameter handlerArg() { result = this.getParameter(1) }
|
||||
}
|
||||
|
||||
private class SslCancelCall extends MethodAccess {
|
||||
SslCancelCall() {
|
||||
this.getMethod().hasQualifiedName("android.webkit", "SslErrorHandler", "cancel")
|
||||
}
|
||||
}
|
||||
|
||||
private class SslProceedCall extends MethodAccess {
|
||||
SslProceedCall() {
|
||||
this.getMethod().hasQualifiedName("android.webkit", "SslErrorHandler", "proceed")
|
||||
}
|
||||
}
|
||||
|
||||
predicate trustsAllCerts(OnReceivedSslErrorMethod m) {
|
||||
exists(SslProceedCall pr | pr.getQualifier().(VarAccess).getVariable() = m.handlerArg()) and
|
||||
not exists(SslCancelCall ca | ca.getQualifier().(VarAccess).getVariable() = m.handlerArg())
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @name Android `WebVeiw` that accepts all certificates
|
||||
* @description Trusting all certificates allows an attacker to perform a machine-in-the-middle attack.
|
||||
* @kind problem
|
||||
* @problem.severity error
|
||||
* @security-severity 7.5
|
||||
* @precision high
|
||||
* @id java/improper-webview-certificate-validation
|
||||
* @tags security
|
||||
* external/cwe/cwe-295
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.security.AndroidWebViewCertificateValidationQuery
|
||||
|
||||
from OnReceivedSslErrorMethod m
|
||||
where trustsAllCerts(m)
|
||||
select m, "This handler accepts all SSL certificates."
|
||||
Reference in New Issue
Block a user