Skip to content

Conversation

@tduhamel42
Copy link
Collaborator

Summary

This PR introduces a comprehensive Android security testing workflow with platform-aware architecture supporting both x86_64 and ARM64 (Apple Silicon) platforms.

🎯 Major Features

Android Static Analysis Workflow

  • Jadx Decompiler: APK → Java source code decompilation
  • OpenGrep/Semgrep: Static analysis with custom Android security rules
  • MobSF Integration: Comprehensive mobile security scanning
  • SARIF Reporter: Unified security findings format

Platform-Aware Worker Architecture

  • Automatic Platform Detection: CLI detects ARM64 vs x86_64 using platform.machine()
  • Multi-Dockerfile Support:
    • Dockerfile.amd64 - Full toolchain with MobSF (x86_64)
    • Dockerfile.arm64 - Jadx + OpenGrep only (Apple Silicon)
  • Worker Metadata Convention: metadata.yaml defines platform capabilities
  • Conditional Imports: MobSF module import wrapped in try-except for graceful degradation
  • Backend Path Resolution: Exposes FUZZFORGE_HOST_ROOT for CLI worker management

✅ Test Results

Successfully tested on ARM64 (Apple Silicon):

ff workflow run android_static_analysis test_projects/android_test/ \
  --wait --no-interactive apk_path=BeetleBug.apk decompile_apk=true

Results:

  • Jadx: 4,145 Java files decompiled
  • OpenGrep: 8 security issues found (1 ERROR, 7 WARNINGS)
  • ⚠️ MobSF: Gracefully skipped on ARM64 (Rosetta 2 incompatibility)
  • Workflow: Completed in ~1.5 minutes

🔧 Technical Changes

  1. Conditional MobSF Import (backend/toolbox/modules/android/__init__.py)

    • MobSFScanner import wrapped in try-except
    • Graceful degradation when aiohttp/MobSF dependencies unavailable
  2. Graceful MobSF Handling (backend/toolbox/workflows/android_static_analysis/activities.py)

    • Activity checks for MobSF installation directory
    • Returns "skipped" status with clear reason when unavailable
  3. CHANGELOG Updates (CHANGELOG.md)

    • Added [Unreleased] section documenting all changes
    • Fixed date typo: 2025-01-16 → 2025-10-16

📦 Commits Included

  • cfcbe91 - feat: Add Android static analysis workflow with Jadx, OpenGrep, and MobSF
  • 1d3e033 - fix(android): correct activity names and MobSF API key generation
  • 0801ca3 - feat: add platform-aware worker architecture with ARM64 support
  • b1a98db - fix: make MobSFScanner import conditional for ARM64 compatibility
  • 73dc264 - docs: update CHANGELOG with Android workflow and ARM64 support

🧪 How to Test

On x86_64 (full toolchain):

ff workflow run android_static_analysis test_projects/android_test/ \
  --wait --no-interactive apk_path=BeetleBug.apk decompile_apk=true

On ARM64 (without MobSF):

export ANDROID_DOCKERFILE=Dockerfile.arm64
docker compose build worker-android
ff workflow run android_static_analysis test_projects/android_test/ \
  --wait --no-interactive apk_path=BeetleBug.apk decompile_apk=true

…obSF

Comprehensive Android security testing workflow converted from Prefect to Temporal architecture:

Modules (3):
- JadxDecompiler: APK to Java source code decompilation
- OpenGrepAndroid: Static analysis with Android-specific security rules
- MobSFScanner: Comprehensive mobile security framework integration

Custom Rules (13):
- clipboard-sensitive-data, hardcoded-secrets, insecure-data-storage
- insecure-deeplink, insecure-logging, intent-redirection
- sensitive_data_sharedPreferences, sqlite-injection
- vulnerable-activity, vulnerable-content-provider, vulnerable-service
- webview-javascript-enabled, webview-load-arbitrary-url

Workflow:
- 6-phase Temporal workflow: download → Jadx → OpenGrep → MobSF → SARIF → upload
- 4 activities: decompile_with_jadx, scan_with_opengrep, scan_with_mobsf, generate_android_sarif
- SARIF output combining findings from all security tools

Docker Worker:
- ARM64 Mac compatibility via amd64 platform emulation
- Pre-installed: Android SDK, Jadx 1.4.7, OpenGrep 1.45.0, MobSF 3.9.7
- MobSF runs as background service with API key auto-generation
- Added aiohttp for async HTTP communication

Test APKs:
- BeetleBug.apk and shopnest.apk for workflow validation
- Fix activity names in workflow.py (get_target, upload_results, cleanup_cache)
- Fix MobSF API key generation in Dockerfile startup script (cut delimiter)
- Update activity parameter signatures to match actual implementations
- Workflow now executes successfully with Jadx and OpenGrep
Implement platform-specific Dockerfile selection and graceful tool degradation to support both x86_64 and ARM64 (Apple Silicon) platforms.

**Backend Changes:**
- Add system info API endpoint (/system/info) exposing host filesystem paths
- Add FUZZFORGE_HOST_ROOT environment variable to backend service
- Add graceful degradation in MobSF activity for ARM64 platforms

**CLI Changes:**
- Implement multi-strategy path resolution (backend API, .fuzzforge marker, env var)
- Add platform detection (linux/amd64 vs linux/arm64)
- Add worker metadata.yaml reading for platform capabilities
- Auto-select appropriate Dockerfile based on detected platform
- Pass platform-specific env vars to docker-compose

**Worker Changes:**
- Create workers/android/metadata.yaml defining platform capabilities
- Rename Dockerfile -> Dockerfile.amd64 (full toolchain with MobSF)
- Create Dockerfile.arm64 (excludes MobSF due to Rosetta 2 incompatibility)
- Update docker-compose.yml to use ${ANDROID_DOCKERFILE} variable

**Workflow Changes:**
- Handle MobSF "skipped" status gracefully in workflow
- Log clear warnings when tools are unavailable on platform

**Key Features:**
- Automatic platform detection and Dockerfile selection
- Graceful degradation when tools unavailable (MobSF on ARM64)
- Works from any directory (backend API provides paths)
- Manual override via environment variables
- Clear user feedback about platform and selected Dockerfile

**Benefits:**
- Android workflow now works on Apple Silicon Macs
- No code changes needed for other workflows
- Convention established for future platform-specific workers

Closes: MobSF Rosetta 2 incompatibility issue
Implements: Platform-aware worker architecture (Option B)
- Add try-except block to conditionally import MobSFScanner in modules/android/__init__.py
- Allows Android worker to start on ARM64 without MobSF dependencies (aiohttp)
- MobSF activity gracefully skips on ARM64 with clear warning message
- Remove workflow path detection logic (not needed - workflows receive directories)

Platform-aware architecture fully functional on ARM64:
- CLI detects ARM64 and selects Dockerfile.arm64 automatically
- Worker builds and runs without MobSF on ARM64
- Jadx successfully decompiles APKs (4145 files from BeetleBug.apk)
- OpenGrep finds security vulnerabilities (8 issues found)
- MobSF gracefully skips with warning on ARM64
- Graceful degradation working as designed

Tested with:
  ff workflow run android_static_analysis test_projects/android_test/ \
    --wait --no-interactive apk_path=BeetleBug.apk decompile_apk=true

Results: 8 security findings (1 ERROR, 7 WARNINGS)
Added [Unreleased] section documenting:
- Android Static Analysis Workflow (Jadx, OpenGrep, MobSF)
- Platform-Aware Worker Architecture with ARM64 support
- Python SAST Workflow
- CI/CD improvements and worker validation
- CLI enhancements
- Bug fixes and technical changes

Fixed date typo: 2025-01-16 → 2025-10-16
- Remove unused imports from mobsf_scanner.py (asyncio, hashlib, json, Optional)
- Remove unused variables from opengrep_android.py (start_col, end_col)
- Remove duplicate Path import from workflow.py
Updated worker validation script to accept both:
- Single Dockerfile pattern (existing workers)
- Multi-platform Dockerfile pattern (Dockerfile.amd64, Dockerfile.arm64, etc.)

This enables platform-aware worker architectures like the Android worker
which uses different Dockerfiles for x86_64 and ARM64 platforms.
@tduhamel42 tduhamel42 merged commit bd94d19 into dev Oct 24, 2025
14 checks passed
@tduhamel42 tduhamel42 deleted the feature/android-workflow-conversion branch October 24, 2025 15:22
tduhamel42 added a commit that referenced this pull request Nov 4, 2025
…ersion

feat: Android Static Analysis Workflow with ARM64 Support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants