False Negative: ImproperWebViewCertificateValidation.ql misses unconditional `handler.proceed()` calls once they are hidden behind aliases or tiny wrappers.
還沒有人認領這個 Issue。
評估
研究方向
從 Security/CWE/CWE-295/ImproperWebViewCertificateValidation.ql 開始,檢查 checker 如何識別 onReceivedSslError 實作和直接的 proceed() 呼叫。使用 PosCase1_Var1.java、PosCase1_Var3.java、PosCase1_Var4.java 和 PosCase1_Var5.java 重現該行為;完成的標準是能夠偵測出這些不安全變體,且不會使現有案例發生回歸。
由索引模型根據 Issue 內容生成。
描述
False Negative: ImproperWebViewCertificateValidation.ql misses unconditional handler.proceed() calls once they are hidden behind aliases or tiny wrappers.
Version
codeql 2.24.3
Checker
- Checker id:
Security/CWE/CWE-295/ImproperWebViewCertificateValidation.ql - Checker description: This checker detects Android WebViewClient.onReceivedSslError method implementations that unconditionally accept all SSL certificates by calling SslErrorHandler.proceed without proper validation.
Description of the false negative
These samples still accept every certificate error in onReceivedSslError(...). The code only changes how proceed() is reached: through an alias, a helper method, or a trivially true guard.
Affected test cases
PosCase1_Var1.java
Aliasing the handler does not change the fact that the code still calls proceed() unconditionally.
// A class extends android.webkit.WebViewClient and overrides onReceivedSslError, directly calling handler.proceed() without any conditional checks should be flagged as unconditional SSL error acceptance.
package scensct.var.pos;
import android.webkit.WebViewClient;
import android.webkit.SslErrorHandler;
import android.net.http.SslError;
public class PosCase1_Var1 extends WebViewClient {
@Override
public void onReceivedSslError(android.webkit.WebView webView, SslErrorHandler sslHandler, SslError sslError) {
// Renamed parameters and added a temporary variable
SslErrorHandler h = sslHandler;
h.proceed();
}
}
PosCase1_Var3.java
Moving the proceed() call into a helper does not make the certificate validation any less unsafe.
// A class extends android.webkit.WebViewClient and overrides onReceivedSslError, directly calling handler.proceed() without any conditional checks should be flagged as unconditional SSL error acceptance.
package scensct.var.pos;
import android.webkit.WebViewClient;
import android.webkit.SslErrorHandler;
import android.net.http.SslError;
public class PosCase1_Var3 extends WebViewClient {
@Override
public void onReceivedSslError(android.webkit.WebView view, SslErrorHandler handler, SslError error) {
// Extracted the call to a private helper method that still unconditionally proceeds
handleSslError(handler);
}
private void handleSslError(SslErrorHandler handler) {
handler.proceed();
}
}
PosCase1_Var4.java
This still accepts every certificate without validation; the wrapper method only hides the call shape.
// A class extends android.webkit.WebViewClient and overrides onReceivedSslError, directly calling handler.proceed() without any conditional checks should be flagged as unconditional SSL error acceptance.
package scensct.var.pos;
import android.webkit.WebViewClient;
import android.webkit.SslErrorHandler;
import android.net.http.SslError;
public class PosCase1_Var4 extends WebViewClient {
@Override
public void onReceivedSslError(android.webkit.WebView view, SslErrorHandler handler, SslError error) {
// Added dead code that does not affect the unconditional call
int unused = 42;
if (unused > 0) {
// This always executes
handler.proceed();
}
// No else branch, so call is still unconditional
}
}
PosCase1_Var5.java
The same handler still reaches proceed(). The extra local variable should not hide the issue.
// A class extends android.webkit.WebViewClient and overrides onReceivedSslError, directly calling handler.proceed() without any conditional checks should be flagged as unconditional SSL error acceptance.
package scensct.var.pos;
import android.webkit.WebViewClient;
import android.webkit.SslErrorHandler;
import android.net.http.SslError;
public class PosCase1_Var5 extends WebViewClient {
@Override
public void onReceivedSslError(android.webkit.WebView view, SslErrorHandler handler, SslError error) {
// Split the call across multiple statements with a temporary
SslErrorHandler temp = handler;
temp.proceed();
// Added a redundant statement that does not change behavior
temp.toString();
}
}
Cause analysis
The query appears to require a very direct handler.proceed() call in the override body. As soon as the same unconditional acceptance is expressed through a local alias, a private helper, or a trivial always-true branch, the match falls apart.
That is a real blind spot. Unsafe WebView certificate handling is often hidden behind exactly these tiny abstractions.
References
None known.
- 主要語言
- CodeQL
- 星號
- 10.1k
- 分支
- 2.1k
- 平均合併
- 2 天 16 小時
- 30 天內合併 PR
- 143
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/codeql 的其他 Issue
-
agentic-workflows
難度 2/5 1-3 小時 新手友好度 70/100
-
false-positive javascript
難度 2/5 1-3 小時 新手友好度 84/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
false-positive
難度 2/5 1-3 小時 新手友好度 70/100
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
canonical/paas-charm#368 · 1 則留言 ·
-
enhancement
難度 2/5 1-3 小時 新手友好度 75/100
palladius/rails8-app-on-gcp#142 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
corsairdev/corsair#1764 ·
-
oblt-aw/detector/security
難度 2/5 1-3 小時 新手友好度 70/100