Improper Platform Usage

Improper Platform Usage

Each mobile platform provides security features and guidelines, but improper usage of these platform-specific features creates vulnerabilities. Developers unfamiliar with platform security models often misuse or bypass security controls.

Platform Misuse Examples:

  • Requesting excessive permissions
  • Misusing platform keychain/keystore
  • Incorrect URL scheme implementation
  • Improper use of WebViews
  • Bypassing platform security features
  • Incorrect cryptographic API usage

Secure Platform Usage:

// iOS - Secure URL scheme handling
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    // Validate URL scheme
    guard url.scheme == "myapp" else { return false }
    
    // Validate source application
    if let sourceApp = options[.sourceApplication] as? String {
        let trustedApps = ["com.trusted.app1", "com.trusted.app2"]
        guard trustedApps.contains(sourceApp) else { return false }
    }
    
    // Validate and sanitize parameters
    if let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
       let queryItems = components.queryItems {
        for item in queryItems {
            // Validate each parameter
            guard isValidParameter(item) else { return false }
        }
    }
    
    return true
}