This product is not supported for your selected Datadog site. ().
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: swift-security/insecure-storage

Language: Unknown

Severity: Warning

Category: Security

Description

This rule identifies the use of insecure storage mechanisms, such as legacy or non-secure archiving APIs, that can expose sensitive data to tampering or unauthorized access. Storing data insecurely can lead to serious security vulnerabilities, including data leaks, integrity issues, and potential exploitation by attackers.

Developers can avoid violations of this rule by adopting secure archiving patterns, for example: NSKeyedArchiver.archivedData(withRootObject:requiringSecureCoding:) and NSKeyedUnarchiver.unarchivedObject(ofClass:from:). Where applicable, encrypt archived data before saving it to disk or transmitting it. Following these best practices helps protect user data confidentiality and integrity in Swift applications.

Non-Compliant Code Examples

class SomeController: UIViewController {
    func foo(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
        if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
            imageView.contentMode = .ScaleAspectFit
            imageView.image = pickedImage
        }
        NSKeyedArchiver.archivedData(pickedImage!)
        dismissViewControllerAnimated(true, completion: nil)
    }
}
class SomeController: UIViewController {
    func foo(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
        if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
            imageView.contentMode = .ScaleAspectFit
            imageView.image = pickedImage
        }
        UIImageWriteToSavedPhotosAlbum(pickedImage!, self, nil, nil)
        dismissViewControllerAnimated(true, completion: nil)
    }
}

Compliant Code Examples

import Foundation
import CryptoKit

enum SecureArchive {
    // Archive (secure coding required)
    static func archive<T: NSSecureCoding>(_ value: T) throws -> Data {
        try NSKeyedArchiver.archivedData(withRootObject: value, requiringSecureCoding: true)
    }
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

원활한 통합. Datadog Code Security를 경험해 보세요