crossdomain.xml
設定ファイルの該当する設定によりこのポリシーを変更することを開発者に許可しています。しかし、この設定を変更する場合には、注意が必要です。クロスドメインポリシーが過度に許容的であると、悪意のあるアプリケーションが不正な方法で攻撃対象のアプリケーションとやりとりし、偽装、データの盗み出し、リレーなどの攻撃が実行されるおそれがあるためです。
flash.system.Security.allowDomain("*");
*
を allowDomain()
への引数として使用すると、アプリケーションのデータが、任意のドメインにある他の SWF アプリケーションにアクセスできることになります。crossdomain.xml
設定ファイルの該当する設定によりこのポリシーを変更することを開発者に許可しています。Flash Player 9,0,124,0 以降、Adobe は Flash Player がドメイン間で送信できるカスタム ヘッダーを定義する機能も導入しました。ただし、これらの設定を定義するときには注意が必要です。過度に許容的なカスタム ヘッダー ポリシーを、過度に許容的なクロスドメイン ポリシーと一緒に適用すると、悪意のあるアプリケーションが任意のヘッダーをターゲット アプリケーションに送信できるようになります。その結果、さまざまな攻撃の対象となったり、受信したヘッダーの処理方法がわからない、アプリケーションの実行エラーが発生したりする可能性があります。
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
*
を headers
属性の値として使用すると、任意のヘッダーがドメイン間で送信できてしまいます。crossdomain.xml
設定ファイルの該当する設定によりこのポリシーを変更することを開発者に許可しています。しかし、この設定に影響を与えるユーザーを決定する場合には、注意が必要です。クロスドメインポリシーが過度に許容的であると、悪意のあるアプリケーションが不正な方法で攻撃対象のアプリケーションとやりとりし、偽装、データの盗み出し、リレーなどの攻撃が実行されるおそれがあるためです。ポリシー制約の回避の脆弱性は次のように発生します。例 2: 次のコードは、ロードされた SWF ファイルへのパラメーターの 1 つの値を使用して、信頼されるドメインのリストを定義しています。
...
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var url:String = String(params["url"]);
flash.system.Security.loadPolicyFile(url);
...
...
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var domain:String = String(params["domain"]);
flash.system.Security.allowDomain(domain);
...
crossdomain.xml
設定ファイルの該当する設定によりこの制約を変更することを開発者に許可しています。しかし、HTTP を介してロードされたアプリケーションは、中間者攻撃を受ける可能性があり、信頼するべきではないため、これらの設定を定義するときには、注意が必要です。allowInsecureDomain()
をコールしています。これは、HTTP でロードされた SWF アプリケーションが HTTPS でロードされた SWF アプリケーションのデータにアクセスすることを禁止する制約を解除するものです。
flash.system.Security.allowInsecureDomain("*");
...
String lang = Request.Form["lang"];
WebClient client = new WebClient();
client.BaseAddress = url;
NameValueCollection myQueryStringCollection = new NameValueCollection();
myQueryStringCollection.Add("q", lang);
client.QueryString = myQueryStringCollection;
Stream data = client.OpenRead(url);
...
en&poll_id=1
のような lang
を指定できる可能性を考慮しておらず、攻撃者が思いのままに poll_id
を変更できます。
...
String lang = request.getParameter("lang");
GetMethod get = new GetMethod("http://www.example.com");
get.setQueryString("lang=" + lang + "&poll_id=" + poll_id);
get.execute();
...
en&poll_id=1
のような lang
を指定できる可能性を考慮しておらず、攻撃者が思いのままに poll_id
を変更できます。
<%
...
$id = $_GET["id"];
header("Location: http://www.host.com/election.php?poll_id=" . $id);
...
%>
name=alice
を指定していますが、さらに name=alice&
を追加しています。これが最初に出現するサーバーで使用されると、alice
になりすましてそのアカウントに関する情報をさらに取得します。allowBackup
属性を true
(デフォルト値) に設定し、<application>
タグの backupAgent
属性を定義することで行えます。Environment.getExternalStorageDirectory()
が Android デバイスの外部ストレージに参照を返しています。private void WriteToFile(String what_to_write) {
try{
File root = Environment.getExternalStorageDirectory();
if(root.canWrite()) {
File dir = new File(root + "write_to_the_SDcard");
File datafile = new File(dir, number + ".extension");
FileWriter datawriter = new FileWriter(datafile);
BufferedWriter out = new BufferedWriter(datawriter);
out.write(what_to_write);
out.close();
}
}
}
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:ThisDeviceOnly
を含まないアクセシビリティ レベルでは、暗号化されていないバックアップを使用する場合でも、iCloud および iTunes にバックアップされ、どのデバイスにもリストアできます。格納されているデータがどれだけ機密性が高く個人的かによっては、プライバシーの問題が発生する可能性があります。
...
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSData *token = [@"secret" dataUsingEncoding:NSUTF8StringEncoding];
// Configure KeyChain Item
[dict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id) kSecClass];
[dict setObject:token forKey:(__bridge id)kSecValueData];
...
[dict setObject:(__bridge id)kSecAttrAccessibleWhenUnlocked forKey:(__bridge id) kSecAttrAccessible];
OSStatus error = SecItemAdd((__bridge CFDictionaryRef)dict, NULL);
...
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:ThisDeviceOnly
を含まないアクセシビリティ レベルでは、暗号化されていないバックアップを使用する場合でも、iCloud および iTunes にバックアップされ、どのデバイスにもリストアできます。格納されているデータがどれだけ機密性が高く個人的かによっては、プライバシーの問題が発生する可能性があります。
...
// Configure KeyChain Item
let token = "secret"
var query = [String : AnyObject]()
query[kSecClass as String] = kSecClassGenericPassword
query[kSecValueData as String] = token as AnyObject?
...
query[kSecAttrAccessible as String] = kSecAttrAccessibleWhenUnlocked
SecItemAdd(query as CFDictionary, nil)
...
protected void onCreate(Bundle savedInstanceState) {
...
try {
File httpCacheDir = new File(context.getExternalCacheDir(), "http");
long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
HttpResponseCache.install(httpCacheDir, httpCacheSize);
} catch (IOException e) {
Log.i(TAG, "HTTP response cache installation failed:" + e);
}
}
protected void onStop() {
...
HttpResponseCache cache = HttpResponseCache.getInstalled();
if (cache != null) {
cache.flush();
}
}
{app ID}/Library/Caches/com.mycompany.myapp/Cache.db*
ファイルに暗号化せずに格納します。{app ID}/Library/Caches/com.mycompany.myapp/Cache.db*
ファイルに暗号化せずに格納します。{app ID}/Library/Caches/com.mycompany.myapp/Cache.db*
ファイルに暗号化せずに格納します。 URLCache
クラスの diskCapacity
または memoryCapacity
プロパティを 0 に設定することで、HTTP(S) レスポンス キャッシュ システムを効果的に無効化できると考えるかもしれません。しかし、NSURLCache
ドキュメントには、デバイスのメモリまたはディスク領域が残り少なくなった場合のみ、ディスク上のキャッシュとメモリ内のキャッシュの両方が設定されたサイズまで切り詰められると記載されています。両方の設定は、セキュリティ制御としてではなく、システム リソースを解放してパフォーマンスを向上させるために使用されます。{app ID}/Library/Caches/com.mycompany.myapp/Cache.db*
ファイルに暗号化せずに格納します。 URLCache
クラスの diskCapacity
または memoryCapacity
プロパティを 0 に設定することで、HTTP(S) レスポンス キャッシュ システムを効果的に無効化できると考えるかもしれません。しかし、NSURLCache
ドキュメントには、デバイスのメモリまたはディスク領域が残り少なくなった場合のみ、ディスク上のキャッシュとメモリ内のキャッシュの両方が設定されたサイズまで切り詰められると記載されています。両方の設定は、セキュリティ制御としてではなく、システム リソースを解放してパフォーマンスを向上させるために使用されます。NSFileManager
に定数として定義されます。つまり、NSFileManager
インスタンスと関連付けられた NSDictionary
に NSFileProtectionKey
鍵の値として割り当てられることになります。またファイルを作成するか、あるいは setAttributes:ofItemAtPath:error:
、attributesOfItemAtPath:error:
、createFileAtPath:contents:attributes:
などの NSFileManager
関数を使用して変更されるデータ保護クラスをファイルに含めることができます。さらに、対応するデータ保護定数は NSData
オブジェクトに NSDataWritingOptions
として定義され、これを options
引数として NSData
関数 writeToURL:options:error:
および writeToFile:options:error:
に渡すことができます。NSFileManager
および NSData
の各種データ保護クラス定数の定義を以下に示します。NSFileProtectionComplete
, NSDataWritingFileProtectionComplete
:NSFileProtectionCompleteUnlessOpen
, NSDataWritingFileProtectionCompleteUnlessOpen
:NSFileProtectionCompleteUntilFirstUserAuthentication
, NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication
:NSFileProtectionNone
, NSDataWritingFileProtectionNone
:NSFileProtectionCompleteUnlessOpen
または NSFileProtectionCompleteUntilFirstUserAuthentication
でマーキングすると、ユーザーのパスワードとデバイスの UID から導出された鍵を使用してファイルを暗号化できる一方、データは特定の状況下でアクセス可能のままになります。このように、NSFileProtectionCompleteUnlessOpen
または NSFileProtectionCompleteUntilFirstUserAuthentication
の使用方法については慎重に検証し、今後も NSFileProtectionComplete
による保護が保証されるかどうかを見極める必要があります。例 2: 以下の例では、所定のデータはユーザーがデバイスの電源をオンにして初回のパスワードを入力するまでに限り保護されます (次の再起動まで)。
...
filepath = [self.GetDocumentDirectory stringByAppendingPathComponent:self.setFilename];
...
NSDictionary *protection = [NSDictionary dictionaryWithObject:NSFileProtectionCompleteUntilFirstUserAuthentication forKey:NSFileProtectionKey];
...
[[NSFileManager defaultManager] setAttributes:protection ofItemAtPath:filepath error:nil];
...
BOOL ok = [testToWrite writeToFile:filepath atomically:YES encoding:NSUnicodeStringEncoding error:&err];
...
...
filepath = [self.GetDocumentDirectory stringByAppendingPathComponent:self.setFilename];
...
NSData *textData = [textToWrite dataUsingEncoding:NSUnicodeStingEncoding];
...
BOOL ok = [textData writeToFile:filepath options:NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication error:&err];
...
NSFileManager
に定数として定義されます。つまり、NSFileManager
インスタンスと関連付けられた Dictionary
に NSFileProtectionKey
鍵の値として割り当てられることになります。またファイルを作成するか、あるいは setAttributes(_:ofItemAtPath:)
、attributesOfItemAtPath(_:)
、createFileAtPath(_:contents:attributes:)
などの NSFileManager
関数を使用して変更されるデータ保護クラスをファイルに含めることができます。さらに、対応するデータ保護定数は NSData
オブジェクトに NSDataWritingOptions
列挙型として定義されています。これは options
引数として NSData
の関数 (
writeToFile(_:options:)
など) に渡すことができます。NSFileManager
および NSData
の各種データ保護クラス定数の定義を以下に示します。NSFileProtectionComplete
, NSDataWritingOptions.DataWritingFileProtectionComplete
:NSFileProtectionCompleteUnlessOpen
, NSDataWritingOptions.DataWritingFileProtectionCompleteUnlessOpen
:NSFileProtectionCompleteUntilFirstUserAuthentication
, NSDataWritingOptions.DataWritingFileProtectionCompleteUntilFirstUserAuthentication
:NSFileProtectionNone
, NSDataWritingOptions.DataWritingFileProtectionNone
:NSFileProtectionCompleteUnlessOpen
または NSFileProtectionCompleteUntilFirstUserAuthentication
でマーキングすると、ユーザーのパスワードとデバイスの UID から導出された鍵を使用してファイルを暗号化できる一方、データは特定の状況下でアクセス可能のままになります。このように、NSFileProtectionCompleteUnlessOpen
または NSFileProtectionCompleteUntilFirstUserAuthentication
の使用方法については慎重に検証し、今後も NSFileProtectionComplete
による保護が保証されるかどうかを見極める必要があります。例 2: 以下の例では、所定のデータはユーザーがデバイスの電源をオンにして初回のパスワードを入力するまでに限り保護されます (次の再起動まで)。
...
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0])
let filename = "\(documentsPath)/tmp_activeTrans.txt"
let protection = [NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication]
do {
try NSFileManager.defaultManager().setAttributes(protection, ofItemAtPath: filename)
} catch let error as NSError {
NSLog("Unable to change attributes: \(error.debugDescription)")
}
...
BOOL ok = textToWrite.writeToFile(filename, atomically:true)
...
...
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0])
let filename = "\(documentsPath)/tmp_activeTrans.txt"
...
BOOL ok = textData.writeToFile(filepath, options: .DataWritingFileProtectionCompleteUntilFirstUserAuthentication);
...
kSecAttrAccessible
キーの値として割り当てる必要があります。さまざまなキーチェーン アクセシビリティ定数の定義を以下に示します。kSecAttrAccessibleAfterFirstUnlock
:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleAfterFirstUnlock
でマーキングすると、ユーザーのパスコードとデバイスの UID から導出された鍵を使用してファイルを暗号化できる一方、データは特定の状況下でアクセス可能のままになります。このように、kSecAttrAccessibleAfterFirstUnlock
の使用方法については慎重に検証し、今後も保護が保証されるかどうかを見極める必要があります。
...
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSData *token = [@"secret" dataUsingEncoding:NSUTF8StringEncoding];
// Configure KeyChain Item
[dict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id) kSecClass];
[dict setObject:token forKey:(__bridge id)kSecValueData];
...
[dict setObject:(__bridge id)kSecAttrAccessibleAfterFirstUnlock forKey:(__bridge id) kSecAttrAccessible];
OSStatus error = SecItemAdd((__bridge CFDictionaryRef)dict, NULL);
...
kSecAttrAccessible
キーの値として割り当てる必要があります。さまざまなキーチェーン アクセシビリティ定数の定義を以下に示します。kSecAttrAccessibleAfterFirstUnlock
:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleAfterFirstUnlock
でマーキングすると、ユーザーのパスコードとデバイスの UID から導出された鍵を使用してファイルを暗号化できる一方、データは特定の状況下でアクセス可能のままになります。このように、kSecAttrAccessibleAfterFirstUnlock
の使用方法については慎重に検証し、今後も保護が保証されるかどうかを見極める必要があります。
...
// Configure KeyChain Item
let token = "secret"
var query = [String : AnyObject]()
query[kSecClass as String] = kSecClassGenericPassword
query[kSecValueData as String] = token as AnyObject?
...
query[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlock
SecItemAdd(query as CFDictionary, nil)
...
NSFileManager
に定数として定義されます。つまり、NSFileManager
インスタンスと関連付けられた NSDictionary
に NSFileProtectionKey
鍵の値として割り当てられることになります。またファイルを作成するか、あるいは setAttributes:ofItemAtPath:error:
、attributesOfItemAtPath:error:
、createFileAtPath:contents:attributes:
などの NSFileManager
関数を使用して変更されるデータ保護クラスをファイルに含めることができます。さらに、対応するデータ保護定数は NSData
オブジェクトに NSDataWritingOptions
として定義され、これを options
引数として NSData
関数 writeToURL:options:error:
および writeToFile:options:error:
に渡すことができます。NSFileManager
および NSData
の各種データ保護クラス定数の定義を以下に示します。NSFileProtectionComplete
, NSDataWritingFileProtectionComplete
:NSFileProtectionCompleteUnlessOpen
, NSDataWritingFileProtectionCompleteUnlessOpen
:NSFileProtectionCompleteUntilFirstUserAuthentication
, NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication
:NSFileProtectionNone
, NSDataWritingFileProtectionNone
:NSFileProtectionNone
を指定すると、デバイスの UID のみに基づいて導出された鍵が暗号化に使用されます。これにより、デバイスの電源が入っているときはパスワードでロックされているときや起動時を含み、これらのファイルが常にアクセス可能になります。このため、NSFileProtectionNone
の使用については慎重に検証し、今後もより厳格なデータ保護クラスによる保護が保証されることを見極める必要があります。例 2: 次の例では、所定のデータが保護されていません (デバイスの電源がオンのとき常にアクセス可能)。
...
filepath = [self.GetDocumentDirectory stringByAppendingPathComponent:self.setFilename];
...
NSDictionary *protection = [NSDictionary dictionaryWithObject:NSFileProtectionNone forKey:NSFileProtectionKey];
...
[[NSFileManager defaultManager] setAttributes:protection ofItemAtPath:filepath error:nil];
...
BOOL ok = [testToWrite writeToFile:filepath atomically:YES encoding:NSUnicodeStringEncoding error:&err];
...
...
filepath = [self.GetDocumentDirectory stringByAppendingPathComponent:self.setFilename];
...
NSData *textData = [textToWrite dataUsingEncoding:NSUnicodeStingEncoding];
...
BOOL ok = [textData writeToFile:filepath options:NSDataWritingFileProtectionNone error:&err];
...
NSFileManager
インスタンスに関連付けられた Dictionary
で NSFileProtectionKey
キーの値として割り当てるために、NSFileManager
で定数として定義されています。setAttributes(_:ofItemAtPath:)
、attributesOfItemAtPath(_:)
、createFileAtPath(_:contents:attributes:)
などの NSFileManager
の関数を使用すると、ファイルの作成やデータ保護クラスの変更を行うことができます。さらに、対応するデータ保護定数は NSData
オブジェクトに NSDataWritingOptions
列挙型として定義されています。これは options
引数として NSData
の関数 (
writeToFile(_:options:)
など) に渡すことができます。NSFileManager
および NSData
の各種データ保護クラス定数の定義を以下に示します。NSFileProtectionComplete
, NSDataWritingOptions.DataWritingFileProtectionComplete
:NSFileProtectionCompleteUnlessOpen
, NSDataWritingOptions.DataWritingFileProtectionCompleteUnlessOpen
:NSFileProtectionCompleteUntilFirstUserAuthentication
, NSDataWritingOptions.DataWritingFileProtectionCompleteUntilFirstUserAuthentication
:NSFileProtectionNone
, NSDataWritingOptions.DataWritingFileProtectionNone
:NSFileProtectionNone
を指定すると、デバイスの UID のみに基づいて導出された鍵が暗号化に使用されます。これにより、デバイスの電源が入っているときはパスワードでロックされているときや起動時を含み、これらのファイルが常にアクセス可能になります。このため、NSFileProtectionNone
の使用については慎重に検証し、今後もより厳格なデータ保護クラスによる保護が保証されることを見極める必要があります。例 2: 次の例では、所定のデータが保護されていません (デバイスの電源がオンのとき常にアクセス可能)。
...
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0])
let filename = "\(documentsPath)/tmp_activeTrans.txt"
let protection = [NSFileProtectionKey: NSFileProtectionNone]
do {
try NSFileManager.defaultManager().setAttributes(protection, ofItemAtPath: filename)
} catch let error as NSError {
NSLog("Unable to change attributes: \(error.debugDescription)")
}
...
BOOL ok = textToWrite.writeToFile(filename, atomically:true)
...
...
let documentsPath = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0])
let filename = "\(documentsPath)/tmp_activeTrans.txt"
...
BOOL ok = textData.writeToFile(filepath, options: .DataWritingFileProtectionNone);
...
kSecAttrAccessible
キーの値として割り当てる必要があります。さまざまなキーチェーン アクセシビリティ定数の定義を以下に示します。kSecAttrAccessibleAfterFirstUnlock
:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleAlways
を指定すると、デバイスの UID のみに基づいて導出された鍵が暗号化に使用されます。これにより、デバイスの電源が入っているときはパスワードでロックされているときや起動時を含み、これらのファイルが常にアクセス可能になります。このため、kSecAttrAccessibleAlways
の使用については慎重に検証し、今後もより厳格なキーチェーン アクセシビリティ レベルによる保護が保証されることを見極める必要があります。
...
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSData *token = [@"secret" dataUsingEncoding:NSUTF8StringEncoding];
// Configure KeyChain Item
[dict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id) kSecClass];
[dict setObject:token forKey:(__bridge id)kSecValueData];
...
[dict setObject:(__bridge id)kSecAttrAccessibleAlways forKey:(__bridge id) kSecAttrAccessible];
OSStatus error = SecItemAdd((__bridge CFDictionaryRef)dict, NULL);
...
kSecAttrAccessible
キーの値として割り当てる必要があります。さまざまなキーチェーン アクセシビリティ定数の定義を以下に示します。kSecAttrAccessibleAfterFirstUnlock
:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleAlways
を指定すると、デバイスの UID のみに基づいて導出された鍵が暗号化に使用されます。これにより、デバイスの電源が入っているときはパスワードでロックされているときや起動時を含み、これらのファイルが常にアクセス可能になります。このため、kSecAttrAccessibleAlways
の使用については慎重に検証し、今後もより厳格なキーチェーン アクセシビリティ レベルによる保護が保証されることを見極める必要があります。
...
// Configure KeyChain Item
let token = "secret"
var query = [String : AnyObject]()
query[kSecClass as String] = kSecClassGenericPassword
query[kSecValueData as String] = token as AnyObject?
...
query[kSecAttrAccessible as String] = kSecAttrAccessibleAlways
SecItemAdd(query as CFDictionary, nil)
...
Realm
データベースへの接続を確立します。
Realm realm = Realm.getDefaultInstance();
Realm
データベースへの接続を確立します。
RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
RLMRealm *realm = [RLMRealm realmWithConfiguration:config error:nil];
Realm
データベースへの接続を確立します。
let realm = try! Realm()
UIImageWriteToSavedPhotosAlbum
を使用して画像をフォト アルバムに保存します。
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
...
}
UIImageWriteToSavedPhotosAlbum
を使用して画像をフォト アルバムに保存します。
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.contentMode = .ScaleAspectFit
imageView.image = pickedImage
}
// Save image
UIImageWriteToSavedPhotosAlbum(pickedImage!, self, nil, nil)
dismissViewControllerAnimated(true, completion: nil)
}
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
のような合理的にセキュアなポリシーで格納される場合、デバイスが盗まれ、パスコードが設定されていた場合、盗んだ人はキーチェーン アイテムを復号化するためにデバイスをロック解除する必要があります。正しいパスコードを入力できない場合、盗んだ人はキーチェーン アイテムを復号化できません。ただし、パスコードが設定されていない場合、攻撃者は指をスライドさせるだけでデバイスをロック解除し、キーチェーン アイテムを復号化できます。このため、デバイスでのパスコードの設定を強制できない場合、キーチェーン暗号化メカニズムが脆弱になる可能性があります。
...
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSData *token = [@"secret" dataUsingEncoding:NSUTF8StringEncoding];
// Configure KeyChain Item
[dict setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id) kSecClass];
[dict setObject:token forKey:(__bridge id)kSecValueData];
...
[dict setObject:(__bridge id)kSecAttrAccessibleWhenUnlockedThisDeviceOnly forKey:(__bridge id) kSecAttrAccessible];
OSStatus error = SecItemAdd((__bridge CFDictionaryRef)dict, NULL);
...
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
:kSecAttrAccessibleAlways
:kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
:kSecAttrAccessibleAlwaysThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
:kSecAttrAccessibleWhenUnlockedThisDeviceOnly
:kSecAttrAccessibleWhenUnlocked
のような合理的にセキュアなポリシーで格納される場合、デバイスが盗まれ、パスコードが設定されていた場合、盗んだ人はキーチェーン アイテムを復号化するためにデバイスをロック解除する必要があります。正しいパスコードを入力できない場合、盗んだ人はキーチェーン アイテムを復号化できません。ただし、パスコードが設定されていない場合、攻撃者は指をスライドさせるだけでデバイスをロック解除し、キーチェーン アイテムを復号化できます。このため、デバイスでのパスコードの設定を強制できない場合、キーチェーン暗号化メカニズムが脆弱になる可能性があります。
...
// Configure KeyChain Item
let token = "secret"
var query = [String : AnyObject]()
query[kSecClass as String] = kSecClassGenericPassword
query[kSecValueData as String] = token as AnyObject?
...
query[kSecAttrAccessible as String] = kSecAttrAccessibleWhenUnlockedThisDeviceOnly
SecItemAdd(query as CFDictionary, nil)
...
setPersistent:YES
を呼び出すことで永続的なものとして構成されます。
...
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:@"myPasteboard" create:YES];
[pasteboard setPersistent:YES];
...
setPersistent(true)
を呼び出すことで永続的なものとして構成されます。
...
let pasteboard = UIPasteboard(name: UIPasteboard.Name(rawValue: "myPasteboard"), create: true)!
pasteboard.setPersistent(true)
...