On-Demand MobSF: How We Spin Up a Disposable Mobile Pentest Container Per Scan
Pentestas Team
Security Analyst

Introduction to On-Demand Mobile Pentesting
In the ever-evolving landscape of mobile application security, the need for robust and thorough testing mechanisms is more critical than ever. Mobile apps often handle sensitive user data, making them prime targets for cyber threats. As such, security testing must be comprehensive, covering a wide array of potential vulnerabilities. This includes everything from insecure data storage and insufficient cryptography to unauthorized access and insecure communication channels. Our approach at Pentestas is centered around addressing these multifaceted challenges in a streamlined and efficient manner.
Maintaining isolated testing environments for mobile security assessments poses significant challenges. Traditional setups often involve complex configurations and resource management, which can lead to inconsistencies and potential security oversights. To mitigate these challenges, we prioritize the creation of ephemeral testing environments that are both isolated and disposable. This ensures that each test is conducted in a clean slate environment, free from the remnants of previous scans, thereby reducing the risk of cross-contamination and false positives.
The Mobile Security Framework (MobSF) plays a pivotal role in our security assessments. MobSF is an open-source tool that facilitates automated and manual security testing of Android and iOS applications. Its comprehensive suite of features allows us to perform dynamic, static, and malware analysis effortlessly. By leveraging MobSF, we can quickly identify vulnerabilities and provide actionable insights to our clients. The framework's flexibility and extensibility make it an ideal choice for our on-demand mobile pentesting approach.
docker run -d -p 8000:8000 --name mobsf_container -v /path/to/mobsf:/mobsf_dir opensecurity/mobile-security-framework-mobsfAt Pentestas, our on-demand pentesting approach capitalizes on containerization technology to spin up disposable MobSF instances for each scan. This on-demand model not only ensures consistent and isolated testing environments but also optimizes resource utilization by decommissioning environments post-scan. This approach embodies our commitment to delivering efficient and thorough mobile security assessments, ensuring that no stone is left unturned in the pursuit of safeguarding user data.
Architecture of Disposable Containers
Containerization, at its core, is the encapsulation of applications and their dependencies into isolated units called containers. We employ Docker to manage these containers due to its robust ecosystem and ease of use. In our architecture, Docker allows us to package the Mobile Security Framework (MobSF) and its dependencies into a single image, ensuring that each scan runs in a consistent environment. This approach minimizes the "it works on my machine" issues, providing a uniform testing ground for every mobile application we assess.
One of the critical advantages of using containers is the level of isolation they provide. Each container operates in its own isolated filesystem, with processes running independently of those in other containers. This ensures that if one container is compromised, it does not affect the others or the host system. Docker's use of namespaces and control groups (cgroups) plays a pivotal role in this isolation, as they partition kernel resources and manage resource allocation effectively.
docker run --rm --name mob_sf_container \
-v /var/run/docker.sock:/var/run/docker.sock \
mob_sf_image:latestOur architecture leverages a worker-controlled Docker socket, allowing automated orchestration of containers. This socket enables our workers to directly communicate with the Docker daemon, granting them the ability to start and stop containers as needed. By mounting the Docker socket inside the container, we ensure that each scan is initiated and managed efficiently. This setup is crucial for maintaining our on-demand scanning service's agility and responsiveness.
Using ephemeral containers for each scan offers significant benefits. Once a scan is complete, the container is destroyed, eradicating any lingering data that might compromise security. This ephemeral nature not only enhances security but also optimizes resource usage, as containers are only active during the scan duration. Furthermore, since each scan is conducted in a fresh environment, we eliminate potential environmental configuration issues, leading to more accurate and reliable results.
Lifecycle of a MobSF Container
At Pentestas, the lifecycle of a MobSF container begins the moment a mobile application APK is submitted for analysis. We start by provisioning the container with the necessary environment, ensuring it runs the latest MobSF codebase. This setup involves pulling the base image from our Docker registry and initializing the required dependencies. Once the environment is primed, the APK is copied into the container, and the analysis process kicks off. Our automated scripts take care of this initialization, ensuring consistency and reliability with each scan.
We have automated the container lifecycle management through a series of scripts and orchestration tools. Using Docker, we can programmatically spin up a new container using commands like docker run --rm -d mobSF:latest. This command ensures that containers are ephemeral, removing themselves upon completion of the task. By automating this process, we eliminate manual intervention, reducing the potential for human error and speeding up the analysis.
Efficient resource management is crucial for handling multiple concurrent scans. Our system dynamically allocates CPU and memory resources to each container, using tools like Kubernetes to manage load distribution across nodes. When a scan completes, the container is destroyed, freeing up resources for other tasks. This dynamic allocation is critical in our CI/CD pipeline, where timely results are essential. By integrating ephemeral containers into our pipeline, we maintain agility and scalability, allowing us to handle fluctuating demands without compromising performance or resource availability.
Efficient APK/IPA Upload Process
The process of uploading APK and IPA files in our platform is designed with a focus on user experience. We provide a simplified interface that allows users to drag and drop their files directly into the browser. This intuitive design minimizes the steps required to initiate a scan, ensuring a seamless transition from file selection to analysis. A progress bar gives real-time feedback on the upload status, which enhances user confidence and transparency during the interaction.
On the backend, we implement several measures to ensure file integrity and security. Each uploaded file undergoes a checksum verification process to detect any anomalies or corruption. For instance, we use SHA-256 to generate a unique hash for each file, which is then compared against a known set of values. This guarantees that the file has not been tampered with during the upload process. Moreover, all files are stored in a secure, isolated environment, ensuring compliance with data protection standards.
import hashlib
def verify_file_integrity(file_path):
with open(file_path, "rb") as f:
file_hash = hashlib.sha256()
while chunk := f.read(4096):
file_hash.update(chunk)
return file_hash.hexdigest()The upload flow is intricately linked to the lifecycle of the MobSF container. Once a file is successfully uploaded, a new container instance is automatically spawned to handle the analysis. This ensures that each scan is isolated, reducing the risk of cross-contamination and maintaining the integrity of the results. Our orchestration system efficiently manages these containers, creating and destroying them as needed, which optimizes resource usage and maintains system performance.
Speed and Reliability
To ensure both speed and reliability, our upload mechanism is equipped with a multi-threaded approach, allowing simultaneous file processing and container initialization. This reduces wait times and ensures that users can quickly receive their analysis results without compromising on accuracy or security.
Security Measures and Best Practices
When it comes to ensuring data privacy and security within our containers, we utilize robust encryption protocols for both data at rest and data in transit. This involves using AES-256 for encrypting sensitive files within the container. Additionally, TLS is employed to secure communication between the container and external services. These measures help in safeguarding the integrity and confidentiality of the data, especially when dealing with scanned results and user submissions.
Access control is paramount in our architecture. We implement a role-based access control (RBAC) system that ensures only authorized personnel can interact with the containerized environments. Monitoring tools like Prometheus and Grafana are used to track access patterns and detect anomalies in real-time. These tools alert us to any unauthorized access attempts, allowing for swift response and mitigation.
version: '3.8'
services:
mob_sf_container:
image: mob_sf_image
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 256M
ports:
- "8080:8080"
environment:
- MOBSF_API_KEY=${MOBSF_API_KEY}For real-time threat detection, we employ systems that monitor container activity and look for patterns indicative of security threats. This involves using tools like Falco to detect unexpected behavior and potential exploits. By integrating these tools, we significantly reduce the time between detection and response, enhancing the overall security posture of our scanning infrastructure.
Best Practices for Docker Environments
Securing a Docker environment involves regular updates to images, minimizing container privileges, and employing network segmentation. We also recommend using Docker Bench Security to automate security checks and identify potential vulnerabilities.
Scaling and Performance Optimization
At Pentestas, efficiently scaling container deployment is crucial for handling multiple mobile pentest scans concurrently. We employ strategies such as using Kubernetes to orchestrate our containerized environments. By leveraging HorizontalPodAutoscaler, we can automatically adjust the number of running containers based on CPU and memory consumption metrics. This dynamic scaling ensures that resources are allocated effectively without manual intervention, allowing us to maintain high availability and reliability during peak scanning periods.
Load balancing plays a pivotal role in distributing incoming scan requests across our containers. We implement NGINX as a reverse proxy to manage traffic effectively. The configuration snippet below demonstrates how we configure NGINX for load balancing:
upstream mob_sf_backend {
server 10.0.0.1:8080;
server 10.0.0.2:8080;
server 10.0.0.3:8080;
}
server {
listen 80;
location / {
proxy_pass http://mob_sf_backend;
}
}To optimize performance for faster scan results, we fine-tune MobSF configurations and allocate specific resource limits on our containers. This approach reduces bottlenecks and enhances scan throughput. Furthermore, caching frequently used components and preloading analysis tools significantly cuts down the initialization time for each scan. Our real-world deployment scenarios have shown that these optimizations can decrease scan times by up to 30%, providing quicker feedback to our users and enabling rapid iteration cycles.
Integration with AI-driven Insights
At Pentestas, we use AI to revolutionize how vulnerabilities are detected in mobile applications. By leveraging advanced machine learning algorithms, our platform can identify patterns and anomalies that might be missed by traditional static analysis methods. For instance, AI models trained on vast datasets of known vulnerabilities can quickly flag similar patterns in new code, providing a much-needed boost in detection accuracy. This approach not only reduces false positives but also accelerates the entire pentesting process, allowing us to deliver results faster.
AI insights are seamlessly integrated into our pentesting workflow. When a scan is initiated, the AI engine analyzes the application code in real-time, providing detailed insights that are incorporated into the final report. This is done by cross-referencing detected issues with a database of known vulnerabilities and attack vectors, enriching the report with context and actionable recommendations. The AI's ability to learn from each scan means that over time, the system becomes even more proficient at identifying potential security flaws.
{
"scanId": "12345",
"vulnerabilities": [
{
"id": "CVE-2023-1234",
"description": "SQL Injection vulnerability in login module",
"severity": "high",
"recommendation": "Use parameterized queries to prevent SQL injection attacks."
}
],
"aiRecommendations": [
"Implement input validation to sanitize user inputs.",
"Review authentication mechanisms for potential weaknesses."
]
}The AI-driven recommendations generated by our platform are not just about highlighting issues; they provide clear, actionable steps for remediation. For example, if a vulnerability is detected in a specific module, the report might suggest implementing input validation or using parameterized queries to prevent SQL injection attacks. This level of detail ensures that developers have the information they need to secure their applications effectively.
The Future of AI in Mobile Security
Looking ahead, the potential for AI in mobile security testing is vast. As AI technology continues to evolve, we foresee even more sophisticated tools that can predict future vulnerabilities based on emerging threats, further enhancing the resilience of mobile applications.
Challenges and Future Directions
One of the current limitations we've identified with our on-demand container approach is the latency introduced by spinning up new instances for each mobile pentest scan. While containers are generally fast, the initialization time can add up, particularly when dealing with multiple sequential scans. Moreover, maintaining a consistent environment across these containers can be tricky, especially when dependencies are updated or deprecated. Ensuring that every scan has an identical environment is crucial for reliable results.
We faced significant technical challenges around resource allocation and security isolation. For instance, ensuring that each container has adequate CPU and memory resources without impacting other operations required fine-tuning our orchestration scripts. To address this, we implemented Kubernetes resource quotas, which allow us to define limits on CPU and memory usage:
apiVersion: v1
kind: ResourceQuota
metadata:
name: mob-sf-quota
spec:
hard:
requests.cpu: "4"
requests.memory: "8Gi"
limits.cpu: "8"
limits.memory: "16Gi"
Looking forward, we're planning enhancements like integrating AI-driven vulnerability analysis and expanding support for more mobile platforms. Real-time collaboration features are also on the roadmap, allowing multiple team members to interact with a scan in progress. Additionally, we are exploring the use of serverless computing to further reduce latency and improve scalability. As mobile pentesting technology evolves, staying ahead of trends such as automated threat modeling and improved static analysis through machine learning will be key to maintaining a competitive edge.
Try it on your stack
Free tier includes 10 scans/month on a verified domain. No credit card required.
Start scanningWhy this matters when buying pentesting-as-a-service
Pentestas is a pentesting-as-a-service offering — an AI penetration testing system that scans web apps, APIs, mobile binaries, cloud accounts, and internal networks under one platform. We default to penetration testing with Claude for triage and exploit-chain narration, and switch to penetration testing with DeepSeek for cost-sensitive bulk passes; both modes go through the same accuracy gate, the same destructive-payload guard, and the same reporting pipeline so a B2B SaaS pentest you run today and one you run six months from now produce comparable, auditable results.
If you've previously bought one-off engagements and you're comparing them against penetration testing with AI, the trade-offs in this post are the ones to read against your last consulting report.
- SARIF Export: Plugging Pentestas Findings Into GitHub Code Scanning
- Active Directory From the Web App's Perspective: The Azure-PS Container
- Bring Your Own Anthropic Key: Why We Don't Mark Up LLM Costs
- Per-Tenant Fernet Encryption: Why Your Findings Are Unreadable to the Other 999 Tenants

Alexander Sverdlov
Founder of Pentestas. Author of 2 information security books, cybersecurity speaker at the largest cybersecurity conferences in Asia and a United Nations conference panelist. Former Microsoft security consulting team member, external cybersecurity consultant at the Emirates Nuclear Energy Corporation.