Описание
MobSF's CSRF checks not enforced after Django migration
Summary
Django's CsrfViewMiddleware exists only in the deprecated MIDDLEWARE_CLASSES (ignored since Django 2.0). The active MIDDLEWARE tuple does not include it. All authenticated web POST endpoints (delete scan, upload, download APK, change password, manage users) accept requests without CSRF tokens.
Verified Impact
This was verified by actually deleting a real scan from the running server using only a session cookie — no CSRF token was required:
The scan was removed from the database. This attack works from any website via HTML form auto-submission because:
- No CSRF token is validated (middleware absent)
- Cookie
SameSite=Laxallows form-based top-level navigation to send the session cookie
Affected Component
Steps to Reproduce
1. Start MobSF v4.4.6 and log in at http://127.0.0.1:8000/login/ (creds: mobsf/mobsf).
2. Upload and scan any APK to create a scan entry. Note the MD5 hash from "Recent Scans".
3. Open the following HTML file in the same browser (simulates visiting attacker's page):
4. The scan is deleted. Navigate back to MobSF "Recent Scans" to confirm it's gone.
Why This Is Not a Self-Bug
- The attack requires a victim user who is logged in to visit an attacker-controlled page
- The attacker crafts the form targeting the victim's MobSF instance
- All destructive POST endpoints are affected:
/delete_scan/,/upload/,/download_scan/,/change_password/,/create_user/,/delete_user/ - This matches the pattern of previously accepted MobSF advisories (e.g., GHSA-5jc6-h9w7-jm3p, GHSA-8m9j-2f32-2vx4)
Remediation
Add 'django.middleware.csrf.CsrfViewMiddleware' to the active MIDDLEWARE tuple.
Ссылки
- https://github.com/MobSF/Mobile-Security-Framework-MobSF/security/advisories/GHSA-3p54-567p-2wpr
- https://github.com/MobSF/Mobile-Security-Framework-MobSF/pull/2627
- https://github.com/MobSF/Mobile-Security-Framework-MobSF/commit/62563ca429a75b3e5d47a13b958e1d2e7d5e2bbf
- https://github.com/MobSF/Mobile-Security-Framework-MobSF/releases/tag/v4.5.1
Пакеты
mobsf
< 4.5.1
4.5.1
Связанные уязвимости
MobSF is a mobile application security testing tool used. Prior to 4.5.1, mobsf/MobSF/settings.py places django.middleware.csrf.CsrfViewMiddleware only in the deprecated MIDDLEWARE_CLASSES setting and omits it from the active MIDDLEWARE tuple, allowing a remote attacker to make a logged-in victim submit cross-site POST requests to authenticated web endpoints including /delete_scan/, /upload/, /download_scan/, /change_password/, /create_user/, and /delete_user/. This can delete scans, upload or download applications, change passwords, or manage users with the victim account permissions. This issue is fixed in version 4.5.1.