界: Security Features

ソフトウェアのセキュリティは、セキュリティ ソフトウェアではありません。ここでは、認証、アクセス制御、機密性、暗号化、権限管理などのトピックについて説明します。

Authentication Bad Practice: Missing Host Check

Abstract
NSURLConnection または NSURLSession の認証処理コールバックは、認証情報の送信先ホストをチェックできません。
Explanation
アプリケーションは NSURLConnection または NSURLSession コールバックを実装して、認証リクエストを処理します。予測されるホストから認証リクエストが届くように設定しなかった場合は、アプリケーションによってロードされたすべての URL に認証情報が送信されます。また、この認証情報を安全に送信できることをチェックしなかった場合は、認証情報が盗まれてしまいます。

例 1: 次のアプリケーションは、認証を要求しているすべてのホストにユーザー認証情報を送信します。


- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NS URLAuthenticationChallenge *)challenge completionHandler:(void (^)(NS URLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler {
NSString *user = [self getUser];
NSString *pass = [self getPassword];

NSURLCredential *cred = [NSURLCredential credentialWithUser:user
password:pass persistence:NSURLCredentialPersistenceForSession];
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
}
References
[1] David Thiel iOS Application Security: The Definitive Guide for Hackers and Developers No Starch Press
[2] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[3] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[4] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[5] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1
desc.structural.objc.authentication_bad_practice_missing_host_check
Abstract
NSURLConnection または NSURLSession の認証処理コールバックは、認証情報の送信先ホストをチェックできません。
Explanation
アプリケーションは NSURLConnection または NSURLSession コールバックを実装して、認証リクエストを処理します。予測されるホストから認証リクエストが届くように設定しなかった場合は、アプリケーションによってロードされたすべての URL に認証情報が送信されます。また、この認証情報を安全に送信できることをチェックしなかった場合は、認証情報が盗まれてしまいます。

例 1: 次のアプリケーションは、認証を要求しているすべてのホストにユーザー認証情報を送信します。


func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {

let user = getUser()
let pass = getPassword()

let credential = URLCredential(user: user, password: pass, persistence: .none)

completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, credential)
}
References
[1] David Thiel iOS Application Security: The Definitive Guide for Hackers and Developers No Starch Press
[2] Standards Mapping - General Data Protection Regulation (GDPR) Access Violation
[3] Standards Mapping - OWASP API 2023 API2 Broken Authentication
[4] Standards Mapping - OWASP Mobile 2024 M3 Insecure Authentication/Authorization
[5] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-AUTH-1
desc.structural.swift.authentication_bad_practice_missing_host_check