Secure storage
Skill almasumdev/awesome-mobile-security-agent-skills/.github/skills/storage/secure-storage
Agent skills for securing mobile apps: storage, transport, auth, obfuscation, and hardening.
npx -y skills add almasumdev/awesome-mobile-security-agent-skills --skill secure-storageAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Cross-platform secure storage on mobile. Covers Android EncryptedSharedPreferences / Tink, iOS Keychain, flutter_secure_storage, and react-native-keychain. Use when persisting tokens, credentials, or PII on device.
SKILL.md
4.3 KB, 992 tokens by cl100k_base, as published. Nobody here has run it
Secure Storage on Mobile
Instructions
Follow these guidelines to persist sensitive values without leaking them to disk, backups, or co-resident apps.
1. What Belongs Where
| Data | Android | iOS |
|---|---|---|
| Opaque tokens (refresh, session) | Keystore-wrapped blob or EncryptedSharedPreferences | Keychain (kSecClassGenericPassword) |
| Symmetric / asymmetric keys | Android Keystore | Keychain (kSecClassKey) / Secure Enclave |
| Structured data (blobs, JSON) | EncryptedFile or SQLCipher | File with NSFileProtectionComplete or SQLCipher |
| User preferences that are not sensitive | SharedPreferences / DataStore | NSUserDefaults |
Never place tokens or PII in SharedPreferences, NSUserDefaults, or a plain SQLite file.
2. Android: EncryptedSharedPreferences (Tink-backed)
// build.gradle.kts: androidx.security:security-crypto:1.1.0-alpha06
val masterKey = MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.setUserAuthenticationRequired(false) // set true + timeout for biometric gating
.build()
val prefs = EncryptedSharedPreferences.create(
context,
"secure_prefs",
masterKey,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
)
prefs.edit().putString("refresh_token", token).apply()
For new code prefer Tink directly (AeadConfig, KeysetHandle) so you control the keyset lifecycle — EncryptedSharedPreferences is in alpha indefinitely.
3. iOS: Keychain
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: "com.example.app.auth",
kSecAttrAccount as String: "refresh_token",
kSecValueData as String: Data(token.utf8),
kSecAttrAccessible as String:
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly,
]
SecItemDelete(query as CFDictionary)
let status = SecItemAdd(query as CFDictionary, nil)
guard status == errSecSuccess else { throw KeychainError.store(status) }
Always use a *ThisDeviceOnly accessibility class so items don't sync via iCloud Keychain.
4. Flutter: flutter_secure_storage
const storage = FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock_this_device,
),
);
await storage.write(key: 'refresh_token', value: token);
On Android < 23 the plugin falls back to RSA + AES in SharedPreferences — document this in the threat model or raise minSdk to 23.
5. React Native: react-native-keychain
import * as Keychain from 'react-native-keychain';
await Keychain.setGenericPassword('user', token, {
service: 'com.example.app.auth',
accessible: Keychain.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY,
accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET, // optional
storage: Keychain.STORAGE_TYPE.AES_GCM, // Android 23+
});
Avoid AsyncStorage for secrets — it is plain JSON on disk.
6. Backups, Exports, and Logs
- Android: set
android:allowBackup="false"or provide an explicitbackup_rules.xmlthat excludes secure stores. - iOS: set
NSFileProtectionCompleteon anything sensitive written to the filesystem; mark files withisExcludedFromBackupKey = truewhere appropriate. - Never log token values. Log only token IDs / hashes for debugging.
7. Migration & Wipe
- On logout, explicitly delete every entry you wrote — do not rely on app uninstall.
- On key rotation (OS upgrade invalidating keystore entries), surface a re-auth flow rather than crashing.
Checklist
- No tokens or PII written to
SharedPreferences/NSUserDefaults/AsyncStorage. - Keys use
*ThisDeviceOnlyaccessibility on iOS. - Android uses
EncryptedSharedPreferencesor Tink, backed by Keystore. -
allowBackup="false"or an explicit backup exclusion rule is set. - Logout path deletes every secure entry.
- No secret values appear in logs, crash reports, or analytics.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most security skills give in 992 tokens
Counted across 648 of the 828 authors here whose files we hold, read 2026-08-07
- Parameterize all database queriesin 68 of 648, across 51 files
- Hash passwords using bcrypt, scrypt, or argon2in 49 of 648, across 36 files
- Apply rate limiting to authentication endpointsin 48 of 648, across 24 files
- Configure security headersin 35 of 648, across 19 files
- Validate all inputsin 32 of 648, across 24 files
- Validate all external input at the system boundaryin 29 of 648, across 19 files
- Run containers as a non-root userin 28 of 648, across 15 files
- Use httponly secure samesite cookies for sessionsin 26 of 648, across 15 files
- Run dependency audits before every releasein 21 of 648, across 10 files
- Encode output to prevent cross-site scriptingin 21 of 648, across 11 files
- Copy dependencies before source codein 20 of 648, across 9 files
- Store secrets in environment variablesin 20 of 648, across 18 files
Said here and by no other author read
- store tokens and PII in platform secure storage
- use EncryptedSharedPreferences or Tink on Android
- use Keychain or Secure Enclave on iOS
- use flutter_secure_storage in Flutter
- use react-native-keychain in React Native
- use ThisDeviceOnly accessibility classes on iOS
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.