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 7m13s

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
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-01 18:37:15 +02:00
1 parent 3ad6cc538b
commit 043f3589bd
29 files changed
+961 -15

No files matched your search

+2 -1
View File
@@ -27,6 +27,7 @@ For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_too
- **Custom semgrep detectors**, shipped in the binary and matched back to controls **by rule id** so a broad CWE can't over-attribute:
- for Python and JavaScript/TypeScript: `cra-ai-1`, `7`, `10`, `14` (secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers), `cra-ai-20` (shell commands and SQL built from variables, request input echoed into a response), `cra-ai-8` (hard-coded credentials, Python) and `cra-ai-15` (plain `http://` requests);
- for C and C++ firmware: `cra-ai-8`, `13`, `16`, `20` (hard-coded credentials including `#define` macros, broken hash/cipher, `rand()`, unbounded string functions and non-literal format strings), next to cppcheck for memory safety.
- **mobsfscan** for Android and iOS apps, bound **by CWE** (a mobsfscan binding only ever attaches mobsfscan findings): `cra-ai-1` (debuggable, exported components, outdated `minSdkVersion`), `7`, `8`, `9`, `13`, `14`, `15` (cleartext, TLS, App Transport Security), `16` and `20`. Each binding lists only the languages mobsfscan has rules for under those CWEs, so `cra-ai-1` covers Java and Kotlin (its manifest checks) but not Swift.
- **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`): the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern.
- **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection.
@@ -34,7 +35,7 @@ For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_too
Each binding in the control map names the **languages** its rules run on (`languages`, empty for language-independent tools such as gitleaks, syft and osv). A test keeps these in step with the rule pack. Each scan run records the source languages it saw outside vendor code (`ScanRun.languages`).
The CRA status calls a covered control **"no violation found"** only when one of its bindings applies to those languages *and* no tool it relies on failed in that scan (a skipped `sast`, `sast_c_cpp` or `cve_lookup` stage). Otherwise the control is **not assessed**, with the reason: not scanned yet, no rule for the languages found, a tool that did not complete, or languages unknown (a run from before they were recorded). A C-only firmware repo therefore never reads "no violation found" for controls only Python rules check (#368, #387).
The CRA status calls a covered control **"no violation found"** only when one of its bindings applies to those languages *and* no tool it relies on failed in that scan (a skipped `sast`, `sast_c_cpp`, `sast_mobile` or `cve_lookup` stage). Otherwise the control is **not assessed**, with the reason: not scanned yet, no rule for the languages found, a tool that did not complete, or languages unknown (a run from before they were recorded). A C-only firmware repo therefore never reads "no violation found" for controls only Python rules check (#368, #387).
At scale, the **master-controls** corpus (breakpilot's deduped clusters, exported as OSCAL) currently provides **~2,882 code-checkable controls** (2,143 `network` + 739 `source_code`), matched semantically.
+2 -1
View File
@@ -18,7 +18,8 @@ names while the scan runs.
- *Firmware analysieren* -- for firmware, lists the libraries and toolchain the build uses.
2. **Static code analysis** (*Statische Codeanalyse*) -- Semgrep with
Prüfwerk's own rules (Python, JavaScript/TypeScript, C and C++; see
[Tools](/reference/tools)); for C and C++ also cppcheck, which follows values through the code
[Tools](/reference/tools)); for Android and iOS apps mobsfscan (code,
AndroidManifest and Info.plist); for C and C++ also cppcheck, which follows values through the code
(out-of-bounds writes, uninitialised reads, null dereferences). Vendor and
third-party code (HAL, CMSIS, vendored libraries) is left out of the code
findings and listed under **Nicht ausgeführt**; it stays in the SBOM.
+26
View File
@@ -33,6 +33,32 @@ finds the defects that matter in firmware: out-of-bounds writes, uninitialised
reads, null dereferences and leaks. It parses the code and never runs it. Its
findings are **Codeanalyse (SAST)** findings with the tool name `cppcheck`.
## mobsfscan -- Android and iOS Apps
[mobsfscan](https://github.com/MobSF/mobsfscan) (LGPL-3.0, used unchanged) runs
on trees with Java, Kotlin, Swift or Objective-C code. It checks the code and
the app settings:
- **AndroidManifest.xml:** `debuggable`, `allowBackup`, cleartext traffic, an
outdated `minSdkVersion`, exported components, task hijacking.
- **Info.plist:** App Transport Security exceptions (`NSAllowsArbitraryLoads`).
- **Code:** WebViews with a JavaScript bridge or ignored TLS errors, weak hashes
and ciphers, ECB mode and static IVs, `java.util.Random` for security,
world-readable storage, trust-all certificate handling, command and SQL
injection, unsafe deserialisation, sensitive data in logs.
Each finding carries its CWE and the OWASP MASVS requirement. mobsfscan runs
once with the Android and once with the iOS rules when a repository holds both
apps (React Native, Flutter); on its own it would check such a repository as
Android only. It runs on the same Semgrep engine with metrics off, never reads
a `.mobsf` file from your repository, and skips `Pods/`, `build/`, `.gradle/`,
`DerivedData/`, `Carthage/` and `node_modules/`. Its findings are
**Codeanalyse (SAST)** findings with the tool name `mobsfscan`.
Not reported: the app-wide "missing protection" hints (no certificate pinning,
no root or jailbreak detection, no screenshot protection). They name no place in
the code and are heuristics. Dart code (Flutter) has no rules yet.
## Vendor Code Exclusion
Firmware projects carry their silicon vendor's SDK (HAL, CMSIS, board support)