{"id":3432,"date":"2026-07-06T04:54:46","date_gmt":"2026-07-06T04:54:46","guid":{"rendered":"https:\/\/tucumandevelopers.com\/index.php\/2026\/07\/06\/shifting-mobile-security-left-applying-sast-to-android-apps-with-mobsf\/"},"modified":"2026-07-06T04:54:46","modified_gmt":"2026-07-06T04:54:46","slug":"shifting-mobile-security-left-applying-sast-to-android-apps-with-mobsf","status":"publish","type":"post","link":"https:\/\/tucumandevelopers.com\/index.php\/2026\/07\/06\/shifting-mobile-security-left-applying-sast-to-android-apps-with-mobsf\/","title":{"rendered":"Shifting Mobile Security Left: Applying SAST to Android Apps with MobSF"},"content":{"rendered":"<div>\n<div><\/div>\n<p><strong>The Victim: A Vulnerable Android App<\/strong><br \/> For this test, I uploaded an open-source vulnerable Android application (similar to InsecureBankv2). Instead of executing the app, MobSF decompiles it and runs its SAST ruleset against the extracted source.<\/p>\n<p>Within 60 seconds, the dashboard populated with critical findings. Here are the two most dangerous vulnerabilities caught by the static scan:<\/p>\n<p><strong>1. Hardcoded Secrets (CWE-798)<\/strong><br \/> MobSF flagged the res\/values\/strings.xml file. A developer left a production AWS access key directly in the code: <\/p>\n<div>\n<pre><code><span>&lt;!-- Flagged by MobSF: Hardcoded sensitive information --&gt;<\/span> <span>&lt;string<\/span> <span>name=<\/span><span>\"aws_access_key\"<\/span><span>&gt;<\/span>AKIAIOSFODNN7EXAMPLE<span>&lt;\/string&gt;<\/span> Why it matters: Anyone who downloads the app from the Play Store can use a tool like Apktool to extract this string in seconds. <\/code><\/pre>\n<div>\n<\/p><\/div>\n<\/p><\/div>\n<p><strong>2. Insecure Data Storage (CWE-312)<\/strong><br \/> The analyzer traced a data flow in the Kotlin backend where user session tokens were being saved using SharedPreferences without the EncryptedSharedPreferences wrapper. <\/p>\n<div>\n<pre><code><span>\/\/ Flagged by MobSF: Insecure SharedPreferences implementation<\/span> <span>val<\/span> <span>sharedPref<\/span> <span>=<\/span> <span>activity<\/span><span>?.<\/span><span>getPreferences<\/span><span>(<\/span><span>Context<\/span><span>.<\/span><span>MODE_PRIVATE<\/span><span>)<\/span> <span>with<\/span> <span>(<\/span><span>sharedPref<\/span><span>.<\/span><span>edit<\/span><span>())<\/span> <span>{<\/span> <span>putString<\/span><span>(<\/span><span>\"session_token\"<\/span><span>,<\/span> <span>userToken<\/span><span>)<\/span> <span>\/\/ Tainted data sink<\/span> <span>apply<\/span><span>()<\/span> <span>}<\/span> <\/code><\/pre>\n<div>\n<\/p><\/div>\n<\/p><\/div>\n<p>Why it matters: If the device is rooted, MODE_PRIVATE does not protect the XML file from being read by other malicious applications on the device. Secure storage is a non-functional requirement that must be enforced at the architectural level.<\/p>\n<p>The Next Evolution: Bringing SAST to the IDE<br \/> While running a Dockerized SAST tool is great for CI\/CD pipelines, the feedback loop can be tightened even further.<\/p>\n<p>The future of SAST isn&#8217;t just in dashboards; it\u2019s in the developer&#8217;s immediate workspace. The ultimate goal is to transform tools like these into VS Code extensions or AI-assisted IDE plugins. By bringing the vulnerability analyzer directly into the code editor as a language server &#8220;skill&#8221;, developers receive inline warnings the exact moment they type a hardcoded secret or implement an insecure storage method.<\/p>\n<p><strong>Conclusion<\/strong><br \/> Mobile applications require specialized security tooling. By leveraging MobSF\u2019s static analysis capabilities, we found critical data storage and hardcoded secret vulnerabilities without ever launching an emulator. Automating this process ensures that fundamental security requirements are met before a single line of code reaches production.<\/p>\n<p><strong>Demo repository (code + CI workflow):<\/strong> <a href=\"https:\/\/github.com\/GianfrancoArocutipa\/psalm-sast-demo(#)\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/GianfrancoArocutipa\/psalm-sast-demo(#)<\/a><\/p>\n<\/p><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Fuente: <a href=\"https:\/\/dev.to\/fabrizioperezperalta\/shifting-mobile-security-left-applying-sast-to-android-apps-with-mobsf-47l3\">Art\u00edculo original<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Victim: A Vulnerable Android App For this test, I uploaded an open-source vulnerable Android application (similar to InsecureBankv2). Instead of executing the app, MobSF decompiles it and runs its SAST ruleset against the extracted source. Within 60 seconds, the dashboard populated with critical findings. Here are the two most dangerous vulnerabilities caught by the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[41],"tags":[],"class_list":["post-3432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devto"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts\/3432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/comments?post=3432"}],"version-history":[{"count":0,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/posts\/3432\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/media\/2648"}],"wp:attachment":[{"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/media?parent=3432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/categories?post=3432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tucumandevelopers.com\/index.php\/wp-json\/wp\/v2\/tags?post=3432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}