MobSF Audit of an iOS app powered by the Flickr API, built with Swift 5 and MVVM architecture findings

MobSF SAST

Posted on 29 May 2026 . 4 min read


Introduction


I performed a MobSF static analysis of ImageGalleryApp, a Swift-based iOS app that browses images from Flickr. The scan produced a security score of 40/100 and highlighted three issues that need attention: disabled App Transport Security (ATS), a likely hardcoded API key, and logging present in production code.


What MobSF found


The main findings surfaced by MobSF were:

  • App Transport Security allows arbitrary loads — a network configuration weakness.
  • Possible hardcoded sensitive information — a Flickr API key present in source.
  • Application logs information — debug/log statements in controller and networking files.

MobSF scorecard
MobSF scorecard: 40/100

Why these issues matter


These findings are important for the following reasons:

  • Disabled ATS weakens transport security and can allow insecure HTTP or downgraded TLS for app network traffic.
  • Hardcoded API keys can be extracted from source or application binaries and abused by attackers or third parties.
  • Logging in production can leak internal state, request/response details, or other sensitive information if logs are not controlled.

Detailed findings & evidence


IMG-01 — App Transport Security allows arbitrary loads (High)


Evidence

MobSF flagged: App Transport Security AllowsArbitraryLoads is allowed

Why this is risky Allowing arbitrary loads disables iOS ATS protections and can permit insecure HTTP connections or relaxed TLS checks across the app.


Remediation Remove the global ATS exception from Info.plist. If an exception is absolutely required, add a domain-specific NSException with the narrowest allowed exceptions.


Suggested fix (Info.plist)

<key>NSAppTransportSecurity</key>
<dict>
<!-- Remove or avoid using NSAllowsArbitraryLoads at application level -->
<!-- Example: only allow an exception for a specific host if required -->
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSIncludesSubdomains</key><true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
</dict>
</dict>
</dict>

Verification Re-run MobSF and confirm the ATS high-severity warning is no longer reported.


IMG-02 — Possible hardcoded sensitive information (High)


Evidence

// MobSF highlighted a value that looks like an API key in:
ImageGalleryApp/Extension+Helper/Constants.swift
(from scan): f9cc014fa76b098f9e82f1c288379ea2

Why this is risky API keys embedded in source or configuration included in the app binary can be extracted and misused. Even if the key is limited, secrets in the client increase risk and are hard to rotate.


Remediation Remove the key from source and inject it at build-time from environment variables or use a server-side proxy to keep secrets out of the client. Rotate the key if it has been published.


Suggested code change (move key out of code)

// Bad (do not store keys in source)
let flickrKey = "f9cc014fa76b098f9e82f1c288379ea2"

// Better: read from Info.plist or environment-injected value
let flickrKey = Bundle.main.object(forInfoDictionaryKey: "FLICKR_API_KEY") as? String ?? ""

// Even better: do not call 3rd-party directly from client for privileged actions; use server-side proxy.

Verification After removing the key from the repo, re-run MobSF. The hardcoded secret finding should be gone. Confirm the app still functions with the key provided securely at build time or via a backend service.


IMG-03 — Application logs information (Info)


Evidence

// MobSF flagged logging in these files:
ImageGalleryApp/Controller/FlickrCollectionViewController.swift
ImageGalleryApp/Controller/FullScreenViewController.swift
ImageGalleryApp/Networking/FlickrImageSource.swift

Why this is risky Uncontrolled logging in release builds may leak URLs, parameters, or internal states that could aid attackers or expose user data.


Remediation Remove debug prints from production or wrap them with build-time checks so they only appear in debug builds. Avoid logging tokens, keys, or personally identifiable information.


Suggested code pattern

// Example pattern: only log in debug builds
#if DEBUG
print("Loaded \(images.count) images from Flickr: \(someDebugInfo)")
#endif

// Or use a controlled logger with levels that are disabled in releases.

Verification Re-run MobSF and verify the logging info message is reduced or absent. Validate that no sensitive values are logged in release builds by inspecting compiled release behavior or testing on a device.


Remediation summary


  • Remove global ATS exceptions; prefer domain-scoped exceptions only when strictly required.
  • Remove hardcoded API keys from source, rotate exposed keys, and use secure injection or a server-side proxy where possible.
  • Restrict logging to debug builds and remove any logs that print sensitive values.

Lessons learned


This audit demonstrates how static analysis tools like MobSF provide a fast, actionable first pass on mobile app security. The most common problems are often configuration or developer hygiene issues (transport security and hardcoded values) rather than exotic vulnerabilities.


Quick links & evidence




Thanks!


Share this article



Written By

Generic placeholder image

Gurjit Singh

I’m Computer Science graduate and CompTIA Security+ certified SOC Analyst and Mobile Application Security Engineer with 10+ years of cross-platform development experience across iOS, Android, and web.


Discover articles by topics

SwiftUI Class Struct Networking XCode NSCache Enum Optionals Property Observers Closures Guard Reviews StoreKit App Store Algorithms Testing Operators Protocol Extensions Weak Unowned SwiftData WWDC23 GCD API Admob SwiftLint Lottie Foreach Objective-C UIKit NavigationSplitView

Related Articles


Understanding Certificates in Cybersecurity

Transitioning from software development into cybersecurity is one of the most natural career moves in tech today....

2026-05-26 . 4 min read     Security Certificates

Read More »

Swift 6.1: New Features & Enhancements

Swift 6.1, officially released in March 2025, continues the evolution of Apple's powerful and expressive programming language....

2025-08-12 . 3 min read     Swift 6.1

Read More »

String Concatenation in Swift: A Comprehensive Guide

In any programming language, working with strings is essential, and Swift is no different.Whether you are building iOS apps......

2024-10-17 . 3 min read     String Concatenation

Read More »

Integrating SwiftUI with UIKit Using UIHostingController

With the introduction of SwiftUI, Apple has provided developers with a modern way to build user interfaces across all Apple platforms....

2024-07-09 . 3 min read     UIHostingController

Read More »

Deep Dive into Autorelease Pools in Swift

In the realm of software development, memory management plays a crucial role in ensuring the efficient allocation and deallocation of memory...

2024-01-28 . 4 min read     Swift Autorelease

Read More »

Swift enum equatable: with or without associated values

Swift enums provide a powerful way to model a set of related values. Enums can be equipped with associated values, allowing them to represen...

2024-01-24 . 3 min read     Swift Enums

Read More »