Introducing a new way to review your PRs.

Read the announcement

mobsf / mobile-security-framework-mobsf

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.

View on GitHub

13 documents · Updated Nov 16, 2026

docs / deployment-ops-tooling

Deployment and Operations Tooling

Overview

MobSF is packaged as a Poetry-managed Python/Django application and as a Docker image. pyproject.toml is the packaging source of truth: it publishes the mobsf package, exposes the mobsf = mobsf.__main__:main console script, requires Python ^3.12, and separates platform servers with gunicorn on non-Windows and waitress on Windows. poetry.lock is generated by Poetry 1.8.4 and pins the dependency graph used by local setup, CI, and Docker builds.

Local setup is driven by setup.sh and setup.bat. Both require Python 3.12-3.13, install wheel plus Poetry 1.8.4, refresh the lock file with poetry lock, install main dependencies only, run the destructive cleanup helper, then run Django migrations, create the default mobsf/mobsf superuser, and create roles. The Unix script also checks Xcode CLI tools on macOS; the Windows script additionally requires OpenSSL at C:\Program Files\OpenSSL-Win64\bin\openssl.exe and Visual Studio Build Tools before dependency installation.

Runtime startup differs by platform. run.sh validates an optional IP:PORT argument, defaults to [::]:8000, traps process exit to run manage.py cleanup_android, and starts Gunicorn with one worker, ten threads, a one-hour timeout, and scripts/gunicorn_config.py. run.bat starts waitress-serve with a default dual IPv4/IPv6 listen string and also runs manage.py cleanup_android before returning the server exit code. In Docker, scripts/entrypoint.sh runs migrations at container startup, creates the default superuser and roles, then execs Gunicorn on 0.0.0.0:8000; scripts/gunicorn_config.py repeats Android cleanup in Gunicorn's on_exit hook by running manage.py cleanup_android from the project directory.

The Docker image is built by Dockerfile from python:3.13-slim-bookworm. It creates an unprivileged mobsf user with UID 9901, installs Android build tools, ADB, locale support, SQLite, and temporary build tools, then runs scripts/dependencies.sh before installing Poetry dependencies into the system environment. scripts/dependencies.sh downloads OpenJDK 24.0.2 for amd64 or arm64 based on TARGETPLATFORM, creates apktool framework storage, and runs mobsf/…/tools_download.py to populate /home/mobsf/.MobSF with third-party analysis tools such as JADX. The final image sets MOBSF_PLATFORM=docker, MOBSF_ADB_BINARY=/usr/bin/adb, JAVA_HOME=/jdk-24.0.2, exposes ports 8000 and 1337, and healthchecks /login/.

Docker Compose operation is split between standalone and swarm files. docker/docker-compose.yml runs PostgreSQL 18, an Nginx reverse proxy, a mobsf web container, and a separate djangoq worker container. Both MobSF containers mount $HOME/MobSF/mobsf_data at /home/mobsf/.MobSF; PostgreSQL persists under $HOME/MobSF/postgresql_data. The web container sets MOBSF_ASYNC_ANALYSIS=1, while the worker overrides the image command with scripts/qcluster.sh, waits ten seconds, then runs manage.py qcluster. docker/nginx.conf maps host port 80 to MobSF port 8000 through internal listen port 4000, maps host port 1337 to internal port 4001, forwards large uploads up to 256 MB for the web app, and forwards the proxy service on port 1337 with a 10 MB body limit. docker/docker-compose_swarm.yml is a simpler web-plus-Postgres stack: it publishes 8000 and 1337 directly, reads the database password and API key from Docker secrets (mobsfDB_password, mobsf_api_key), and uses ${POSTGRES_VERSION:-18} and ${MOBSF_IMAGE:-opensecurity/mobile-security-framework-mobsf:latest} for deployment-time image selection.

Database and queue configuration is environment-driven in mobsf/…/settings.py. If POSTGRES_USER, either POSTGRES_PASSWORD or POSTGRES_PASSWORD_FILE, and POSTGRES_HOST are present, Django uses PostgreSQL with POSTGRES_DB defaulting to mobsf and POSTGRES_PORT defaulting to 5432; otherwise it falls back to SQLite. MOBSF_ASYNC_ANALYSIS, MOBSF_ASYNC_WORKERS, and MOBSF_ASYNC_ANALYSIS_TIMEOUT configure Django Q under the scan_queue cluster. Docker swarm secrets feed into this path through the *_FILE variables, and mobsf/…/init.py similarly honors MOBSF_API_KEY_FILE before MOBSF_API_KEY.

Maintenance scripts are intentionally operational rather than part of the web request path. scripts/clean.sh and scripts/clean.bat delete scan databases, uploaded/downloaded artifacts, generated migrations, logs, secrets, bytecode, and the user's .MobSF data directory; tox -e clean invokes the Unix cleaner after removing build products. scripts/migrate.sh is a small migration helper equivalent to the migration portion of setup and entrypoint. scripts/mass_static_analysis.py bulk-uploads mobile app binaries or zipped source from a directory to a running MobSF server via /api/v1/upload, then starts scans through /api/v1/scan with the supplied API key. scripts/update_android_permissions.py scrapes Android's online Manifest permission documentation and prints permissions missing from mobsf/…/dvm_permissions.py.

Dynamic-analysis device setup is supported by emulator scripts. scripts/start_avd.sh starts a named Android AVD on Linux or macOS with writable system, no snapshot, and wiped data; on Linux it can launch socat to forward the emulator console/ADB-adjacent port for Docker and tells operators to set MOBSF_ANALYZER_IDENTIFIER=host.docker.internal:<port>. It can also unpack an OpenGApps ZIP with unzip/lzip and push Play Store components into /system. scripts/start_avd.ps1 performs the Windows equivalent for starting an AVD, rooting ADB, disabling AVB/verity, rebooting, and remounting the filesystem for dynamic analysis.

CI and release automation live under .github/. .github/…/mobsf-test.yml runs on pushes and pull requests to master across Ubuntu, macOS, and Windows with Python 3.12 and 3.13; Ubuntu also runs tox -e lint, all platforms install Poetry dependencies, migrate the DB, initialize the test file submodule, and run manage.py test mobsf; Ubuntu/macOS additionally build the wheel, install it, and smoke-test mobsf db. .github/…/docker-test.yml validates PR Docker builds for linux/amd64 and linux/arm64. .github/…/docker-latest.yml pushes a multi-arch opensecurity/mobile-security-framework-mobsf:latest image on master, and .github/…/docker-release.yml publishes release-tagged multi-arch images with provenance and SBOM on GitHub release publication. .github/…/python-publish.yml builds with Poetry and publishes to PyPI using trusted publishing on release publication. .github/…/codeql-analysis.yml scans Actions, JavaScript/TypeScript, and Python; .github/codeql-config.yml enables security-extended, ignores .github, and suppresses two noisy Python query IDs. .github/dependabot.yml only updates GitHub Actions weekly.

Contributor and repository policy files affect operational workflow mostly through required checks and security posture. AGENTS.md tells automated contributors to run tox -e lint before finishing work and centralizes security review expectations for attacker-controlled mobile app inputs. .github/PULL_REQUEST_TEMPLATE.md asks contributors to run tox -e lint,test and verify Linux, macOS, Windows, and Docker behavior. .github/CONTRIBUTING.md routes support away from issues and asks bug reports to include mobsf/debug.log. .github/SECURITY.md requires private vulnerability reporting through GitHub advisories and lists past bug classes that should influence deployment-facing changes. The root LICENSE is GPL-3.0-only, mirrored in pyproject.toml, with bundled third-party license notices under LICENSES/. .gitmodules declares the mobsf/StaticAnalyzer/test_files submodule used by tests. .gitignore and .dockerignore exclude generated scan data, secrets, local DBs, uploads/downloads, caches, build products, and test fixtures from source control and Docker build context.

Coupling

Risks

  • scripts/clean.sh, scripts/clean.bat, and tox.ini can delete local scan databases, uploads, downloads, generated migrations, secrets, and $HOME/.MobSF; running setup or tox -e clean in the wrong environment can destroy operator data because setup invokes the cleaner automatically with y.
  • setup.sh and setup.bat run poetry lock during installation, which can rewrite dependency resolution instead of only installing poetry.lock; if contributors run setup before committing, dependency drift can enter unrelated changes and make Docker/CI behavior differ from a previously reviewed lock file.
  • scripts/entrypoint.sh runs makemigrations inside the container before migrate; if model changes reach production without committed migrations, containers may generate runtime migrations that are not reviewed or shared across replicas.
  • scripts/qcluster.sh waits a fixed ten seconds for the database and migrations, then starts manage.py qcluster; slow PostgreSQL startup or long migrations in docker/docker-compose.yml can make the worker fail or start before the web container has finished applying migrations.
  • docker/docker-compose.yml hard-codes POSTGRES_PASSWORD=password and publishes Nginx on host port 80; using it outside local/test deployments without overrides exposes weak default database credentials and broad host networking.
  • scripts/start_avd.sh kills all processes matching emulator and may install OpenGApps files into a writable system image; running it on a shared workstation can terminate unrelated emulators or alter the selected AVD irreversibly for that session.