Dart Webview Flutter Ssl Verification Bypass

Description

This detector identifies Dart applications using the webview_flutter package that unsafely handle SSL certificate authentication errors, potentially allowing man-in-the-middle attacks. When SSL verification is bypassed or improperly handled, attackers can intercept and modify communications between the app and web servers.

Weakness:

313 - Insecure service configuration - Certificates

Category: Functionality Abuse

Detection Strategy

    Scans Dart source files (excluding test files) that import the webview_flutter package

    Identifies method calls that handle SSL authentication errors

    Reports vulnerabilities when these methods contain unsafe SSL error handling that bypasses certificate verification

Vulnerable code example

import 'package:webview_flutter/webview_flutter.dart';

// VULNERABLE: unconditionally accepting all SSL certificates
NavigationDelegate insecureDelegate() => NavigationDelegate(
  onSslAuthError: (SslAuthError request) => request.proceed(), // bypasses certificate validation
);

// VULNERABLE: async block still proceeds without validation...

✅ Secure code example

import 'package:webview_flutter/webview_flutter.dart';

// SECURE: explicitly rejecting invalid SSL certificates
NavigationDelegate secureDelegate() => NavigationDelegate(
  onSslAuthError: (SslAuthError request) => request.cancel(), // rejects untrusted certificates
);

// SECURE: async block properly cancels invalid certificates...