Ashrafiucse flutter security

From jiayaoqijia/cryptoskill · View interactive version

Ashrafiucse flutter security is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Audits Flutter/Dart mobile apps — tokens outside flutter_secure_storage (SharedPreferences/plaintext files/sqflite), certificate-validation bypass (badCertificateCallback, HttpOverrides global, Dio onHttpClientCreate), cleartext http endpoints, WebView JavaScript bridges fed external URLs, unvalidat

How to use this skill

Skill file

Flutter Security

Dart-side shapes for Flutter apps. The platform manifest half (Android

exported components, iOS ATS) stays with ../mobile-security/SKILL.md —

run both for a Flutter repo; this skill owns what lives in lib/, build

scripts, and pubspec.

Step 0 — Detect

rg -n "flutter" -g 'pubspec.yaml' ; rg --files -g '*.dart' | head -5
rg -n "flutter_secure_storage|shared_preferences|sqflite" -g 'pubspec.yaml'

Record: secure-storage package present? dio/http in use? WebView? uni_links

/deep links? Platform channels? Obfuscated release builds?

Step 1 — Storage census (persona: device thief / rooted device / backup extractor)

rg -n "SharedPreferences\.getInstance" -g '*.dart'
rg -n "writeAsString\(|writeAsStringSync\(" -g '*.dart'
rg -n "openDatabase\(|db\.insert\(|db\.execute\(" -g '*.dart'

Census discipline: list EVERY hit, disposition each (credential-class value →

finding; theme/locale/flags → verified-safe). Credential-class values are

tokens, keys, passwords, PII, session state. Stored outside

flutter_secure_storage → High (SharedPreferences is a plaintext XML file;

sqflite is an unencrypted sqlite DB; app-documents files are world-readable

to anything with the device).

Android OPTION and contains the token SharedPreferences — anchor on

.getInstance call sites, never the bare token.

legitimate. The finding is WHAT value is stored.

Step 2 — Certificate validation & cleartext

rg -n "badCertificateCallback|onBadCertificate" -g '*.dart'
rg -n "HttpOverrides" -g '*.dart'
rg -n "onHttpClientCreate" -g '*.dart'
rg -n "http://" -g '*.dart'

Critical: kills TLS validation for EVERY HttpClient in the app — MITM

harvests the auth token on any hostile network.

shape) → Critical for that client's traffic.

request carries the auth header. http://localhost in test/main-dev

files is the common safe near-miss — disposition explicitly.

(defense-in-depth; mobile MITM requires position).

Step 3 — WebView bridges

rg -n "JavascriptMode\.unrestricted|setJavaScriptMode" -g '*.dart'
rg -n "addJavaScriptChannel\(" -g '*.dart'
rg -n "loadRequest\(|loadHtmlString\(|loadUrl\(" -g '*.dart'

Every JavascriptChannel registration is a Dart API exposed to the page:

trace what its onMessageReceived does (payment ops, file access, token

read → Critical when the URL is external/attacker-influenced). unrestricted

JS + external URL + bridge = the classic chain; check the URL source

(constant vs controller/navigation-delegate vs intent/deep-link).

Step 4 — Platform channels (trust boundary both directions)

rg -n "invokeMethod\(" -g '*.dart'
rg -n "setMethodCallHandler\(" -g '*.dart'
rg -n "call\.arguments" -g '*.dart'

the method name (invokeMethod(action)) lets another app choose the

native method → High.

forwarded to native) → High — the native side trusts the plugin.

(regex/parse) on arguments before invoke/forward.

Step 5 — Deep links & route injection

rg -n "getInitialLink|linkStream|appLinks" -g '*.dart'
rg -n "pushNamed\(" -g '*.dart'

Any other app on the device can fire the scheme. Deep-link path or query

reaching pushNamed / route generation without an allowlist map → High

(route injection: private screens, checkout with attacker amount).

Canonicalize + map through a const allowlist; treat query params as hostile

input, not config.

Step 6 — Secrets in the build & source

rg -n "dart-define" -g '*.sh' -g '*.yaml' -g '*.yml' -g 'Makefile' -g '*.gradle'
rg -n -i "api[_-]?key|secret|token|password" -g '*.dart' | rg -v "test|example|fake" | head -20
rg -n "print\(|debugPrint\(" -g '*.dart' | head -20

lands in release binaries, extractable from the APK/IPA. The Dart-side

String.fromEnvironment READER is not the leak — the committed value is.

../secrets-detection/SKILL.md classes too).

wrap in if (kDebugMode) at minimum, better: structured logger with

redaction.

Step 7 — Crypto

rg -n "Random\(\)" -g '*.dart'
rg -n "md5\.|sha1\." -g '*.dart'

(guessable). Safe: Random.secure(). Check what the random value

PROTECTS, not just that it exists.

checksums (cache keys, etags) → verified-safe, note it.

Step 8 — Build & release hygiene

rg -n "flutter build" -g '*.sh' -g '*.yaml' -g 'Makefile' 2>/dev/null

Release builds without --obfuscate --split-debug-info → informational

(hardening). Debug banners/symbols shipped to prod → Low.

Dependencies

pubspec.lock is a Pub manifest: ../dependency-vulns/SKILL.md (osv_scan)

already parses it — no duplicate scanning here. Unpinned pubspec.yaml =

Low (reproducibility).

Reporting

Severity table as in steps. Fixes are short: exact widget/store code for

the secure-storage shape, allowlist map for routes, Random.secure().

Cross-reference: manifest findings → ../mobile-security/SKILL.md;

key-value secrets → ../secrets-detection/SKILL.md; dep CVEs →

../dependency-vulns/SKILL.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.