feat(sast): Android and iOS app analysis with mobsfscan #442

Merged
sharang merged 1 commits from feat/mobsfscan into main 2026-10-05 13:38:45 +00:00
Owner

Stacked on #441 (which is stacked on #440). Retarget after those merge.

Mobile app SAST with mobsfscan (https://github.com/MobSF/mobsfscan, LGPL-3.0, rules and code used unchanged), as decided after the tool research.

What it adds

  • pipeline/mobsfscan.rs:
    • Runs when the tree holds Java, Kotlin, Swift or Objective-C outside vendor code.
    • AndroidManifest: debuggable, allowBackup, cleartext, minSdkVersion, exported components and task hijacking.
    • Info.plist: ATS (NSAllowsArbitraryLoads).
    • Code: WebView JavaScript bridge and TLS errors, weak hashes and ciphers, ECB and static IVs, insecure Random, world-readable storage, trust-all TLS, command and SQL injection, deserialisation and log leaks.
    • Each finding carries a CWE (normalised to CWE-NNN) and its OWASP MASVS requirement plus a reference link in the description.
  • A failed run records a sast_mobile skip. tool_of_stage maps it to mobsfscan, so the controls it covers become Nicht bewertet instead of clean. Dashboard text is in DE and EN.
  • Control map: mobsfscan is bound by CWE to cra-ai-1, 7, 8, 9, 13, 14, 15, 16 and 20. Each binding lists only the languages mobsfscan has rules for under those CWEs. For example, cra-ai-1 covers Java and Kotlin (its manifest checks) but not Swift.
  • languages.rs: .m/.mm count as objc.

mobsfscan defaults we had to neutralise (all verified on fixtures)

  1. Paths skipped by substring. libsast skips any file whose path contains an ignored name, and the defaults include spec and fixtures. A Store.java under inspection/ gave zero findings. The wrapper docker/pruefwerk_mobsfscan.py clears the defaults. Our ignores (Pods, build, .gradle, DerivedData, Carthage, node_modules and vendor directories) are anchored as /name/.
  2. The repository's .mobsf was honoured. Without -c, mobsfscan reads a .mobsf from the scanned tree, so a repository could switch rules off. We always pass our own config.
  3. Android-only on mixed repos. --type auto configures the iOS rules only when the tree has no Android code (elif android … elif ios), so React Native, Flutter and monorepos lost all Swift/ObjC findings. It now runs once per platform present.
  4. Line 1 for every manifest and plist finding. The line that sets the key (android:debuggable=…, android:minSdkVersion<29, NSAllowsArbitraryLoads=…) is looked up. Prose matches keep line 1.
  5. Process pool crashes under Python 3.14. Runs with --multiprocessing thread. The image runs Python 3.11, but this keeps a base-image bump from silently breaking it.
  6. File-less "missing protection" hints dropped. These are no pinning, no root/jailbreak detection and no screenshot protection: heuristics with no location to show.

Image

  • pip install --no-deps mobsfscan==1.0.1. mobsfscan pins semgrep 1.172; it runs fine on our 1.177, so there is no second 260 MB semgrep.
  • Its other dependencies are pinned: libsast 3.1.8, billiard, pyyaml, colorama, sarif-om, jschema-to-python, jsonpickle, pbr, tabulate and xmltodict.
  • tool-versions.json names mobsfscan.
  • Verified with docker build --target tools -f Dockerfile.agent: mobsfscan 1.0.1 on semgrep 1.177. A scan run with --network none works, so there is no egress.

Fixtures (fixtures/nightly/mobile/)

Target Expected
android-insecure manifest debuggable/backup/cleartext at line 4, minSdk at line 3; Kotlin webview + MD5; Java world-readable + Random under inspection/
ios-insecure ios_ats_arbitrary_loads (Info.plist:6), ios_weak_hash (Swift CC_MD5), ios_app_logging (ObjC NSLog)
react-native now also java_insecure_random + ios_sha1_collision, which proves both platforms run
other mobile fixtures no findings: clean Kotlin and Swift stay clean

Not covered

  • Dart (Flutter) has no mobsfscan rules.
  • Objective-C rules are regex-based and few. For example, NSString *password = @"…" is not matched by its hard-coded secret rule.

Checks

  • fmt, plus clippy with the CI flags on the agent, control-map and dashboard server.
  • Agent lib tests: 497. control-map: 12.
  • Local nightly on the staging image plus mobsfscan with this binary, all targets: both bless and compare pass. Only the three mobile baselines above changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

**Stacked on #441** (which is stacked on #440). Retarget after those merge. Mobile app SAST with **mobsfscan** (https://github.com/MobSF/mobsfscan, **LGPL-3.0**, rules and code used unchanged), as decided after the tool research. ## What it adds - **`pipeline/mobsfscan.rs`:** - Runs when the tree holds Java, Kotlin, Swift or Objective-C outside vendor code. - **AndroidManifest:** `debuggable`, `allowBackup`, cleartext, `minSdkVersion`, exported components and task hijacking. - **Info.plist:** ATS (`NSAllowsArbitraryLoads`). - **Code:** WebView JavaScript bridge and TLS errors, weak hashes and ciphers, ECB and static IVs, insecure `Random`, world-readable storage, trust-all TLS, command and SQL injection, deserialisation and log leaks. - Each finding carries a CWE (normalised to `CWE-NNN`) and its OWASP MASVS requirement plus a reference link in the description. - **A failed run records a `sast_mobile` skip.** `tool_of_stage` maps it to `mobsfscan`, so the controls it covers become *Nicht bewertet* instead of clean. Dashboard text is in DE and EN. - **Control map:** mobsfscan is bound by CWE to cra-ai-1, 7, 8, 9, 13, 14, 15, 16 and 20. Each binding lists only the languages mobsfscan has rules for under those CWEs. For example, cra-ai-1 covers Java and Kotlin (its manifest checks) but not Swift. - **`languages.rs`:** `.m`/`.mm` count as `objc`. ## mobsfscan defaults we had to neutralise (all verified on fixtures) 1. **Paths skipped by substring.** libsast skips any file whose path *contains* an ignored name, and the defaults include `spec` and `fixtures`. A `Store.java` under `inspection/` gave **zero** findings. The wrapper `docker/pruefwerk_mobsfscan.py` clears the defaults. Our ignores (`Pods`, `build`, `.gradle`, `DerivedData`, `Carthage`, `node_modules` and vendor directories) are anchored as `/name/`. 2. **The repository's `.mobsf` was honoured.** Without `-c`, mobsfscan reads a `.mobsf` from the scanned tree, so a repository could switch rules off. We always pass our own config. 3. **Android-only on mixed repos.** `--type auto` configures the iOS rules only when the tree has no Android code (`elif android … elif ios`), so React Native, Flutter and monorepos lost all Swift/ObjC findings. It now runs once per platform present. 4. **Line 1 for every manifest and plist finding.** The line that sets the key (`android:debuggable=…`, `android:minSdkVersion<29`, `NSAllowsArbitraryLoads=…`) is looked up. Prose matches keep line 1. 5. **Process pool crashes under Python 3.14.** Runs with `--multiprocessing thread`. The image runs Python 3.11, but this keeps a base-image bump from silently breaking it. 6. **File-less "missing protection" hints dropped.** These are no pinning, no root/jailbreak detection and no screenshot protection: heuristics with no location to show. ## Image - `pip install --no-deps mobsfscan==1.0.1`. mobsfscan pins semgrep 1.172; it runs fine on our 1.177, so there is no second 260 MB semgrep. - Its other dependencies are pinned: libsast 3.1.8, billiard, pyyaml, colorama, sarif-om, jschema-to-python, jsonpickle, pbr, tabulate and xmltodict. - `tool-versions.json` names mobsfscan. - Verified with `docker build --target tools -f Dockerfile.agent`: mobsfscan 1.0.1 on semgrep 1.177. A scan run with `--network none` works, so there is no egress. ## Fixtures (`fixtures/nightly/mobile/`) | Target | Expected | |---|---| | `android-insecure` | manifest debuggable/backup/cleartext at line 4, minSdk at line 3; Kotlin webview + MD5; Java world-readable + Random under `inspection/` | | `ios-insecure` | `ios_ats_arbitrary_loads` (Info.plist:6), `ios_weak_hash` (Swift `CC_MD5`), `ios_app_logging` (ObjC `NSLog`) | | `react-native` | now also `java_insecure_random` + `ios_sha1_collision`, which proves both platforms run | | other mobile fixtures | no findings: clean Kotlin and Swift stay clean | ## Not covered - Dart (Flutter) has no mobsfscan rules. - Objective-C rules are regex-based and few. For example, `NSString *password = @"…"` is not matched by its hard-coded secret rule. ## Checks - fmt, plus clippy with the CI flags on the agent, control-map and dashboard server. - Agent lib tests: 497. control-map: 12. - **Local nightly on the staging image plus mobsfscan with this binary, all targets:** both bless and compare pass. Only the three mobile baselines above changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang changed target branch from feat/no-registry-rules to main 2026-10-05 13:03:44 +00:00
sharang added 1 commit 2026-10-05 13:19:58 +00:00
feat(sast): Android and iOS app analysis with mobsfscan
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m55s
1852fed0bd
mobsfscan (LGPL-3.0, used unchanged) checks Java, Kotlin, Swift and
Objective-C code and the AndroidManifest and Info.plist settings, with a
CWE and the OWASP MASVS requirement on each rule. It runs on the image's
semgrep (installed --no-deps, its other dependencies pinned) with metrics
off.

Three of its defaults would mislead on a customer's tree, so:
- docker/pruefwerk_mobsfscan.py clears its path ignores: libsast skips
  any path that merely contains 'spec' or 'fixtures', so code under
  inspection/ vanished. Ours are anchored as /name/ and passed with -c,
  which also stops it reading a .mobsf file from the repository.
- --type auto configures the iOS rules only when there is no Android
  code, so a React Native or Flutter app was checked as Android only. It
  now runs once per platform present.
- Manifest and plist matches report line 1; the line that sets the key is
  looked up. App-wide "missing protection" hints carry no location and
  are left out.

The scan runs in scan_tree after cppcheck when the tree holds Java,
Kotlin, Swift or Objective-C (`.m`/`.mm` now count as objc); a failure
records a sast_mobile skip, which the CRA view treats like a failed
semgrep. The control map binds mobsfscan by CWE to cra-ai-1, 7, 8, 9, 13,
14, 15, 16 and 20, each with only the languages it has rules for.

Nightly: android-insecure and ios-insecure fixtures, and one flaw each in
the React Native fixture's Java and Swift, so both platforms must run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/mobsfscan from cf7b69949d to 1852fed0bd 2026-10-05 13:19:58 +00:00 Compare
sharang merged commit a9ca31d60c into main 2026-10-05 13:38:45 +00:00
Sign in to join this conversation.