guillemroca/agent-skills-android/security-and-hardening
Claude Code and agent skill by guillemroca/agent-skills-android
- community
Checking that the SKILL.md file is still in the repository.
Use when handling sensitive data, authentication, network communication, or before shipping to the Play Store. Three-tier framework (Always Do, Ask First, Never Do) with Android-specific security patterns, plus data privacy and compliance (GDPR/CCPA, Play Data safety, account deletion).
Install
npx vskill@latest install guillemroca/agent-skills-android/security-and-hardeningSKILL.md
The same SKILL.md was published earlier as guillemroca/agent-skills-android/security-and-hardening.
Security and Hardening
Overview
Security is a development constraint, not an afterthought. This skill provides a three-tier framework — Always Do, Ask First, Never Do — covering the OWASP Mobile Top 10, Android-specific attack vectors, and hardening patterns for production apps.
When to Use
- Handling user credentials, tokens, or personal data
- Implementing network communication
- Before shipping any release to the Play Store
- Reviewing code that touches authentication or authorization
- Setting up ProGuard/R8 rules
- Implementing WebView features
- Collecting personal data, adding analytics/ads SDKs, or answering privacy requirements (GDPR, CCPA, Play Data safety)
Skip when: Changes are purely cosmetic with no data or network impact.
Core Process: Three-Tier Framework
Always Do
- Secure data storage. Jetpack Security Crypto (
EncryptedSharedPreferences/MasterKey) is deprecated and unmaintained — do not add it to new code. Encrypt with a key held in the Android Keystore and persist the ciphertext (DataStore or a file):
Existing apps already on EncryptedSharedPreferences can keep it (the format is stable), but plan a migration and never store new categories of secrets with it.
- Network Security Config:
Targeting API 37 (Android 17) also changes the network/auth surface: LAN access requires the ACCESS_LOCAL_NETWORK permission, standard SMS OTPs are delayed 3 hours (use the SMS Retriever API or SMS User Consent instead of reading raw SMS), and Encrypted Client Hello + Certificate Transparency are on by default for TLS — verify pinning still works.
- Input validation:
- Intent validation for exported components:
Deeper audits: android-skills:android-intent-security and android-skills:android-permissions-security (optional Google companion plugin, see README).
- Secrets management:
- Remove debug code for release:
Ask First
- Changes that require review:
- Modifying authentication or authorization logic
- Adding new exported components (Activities, Receivers, Providers)
- Changing certificate pinning configuration
- Adding new permissions to AndroidManifest
- Integrating new third-party SDKs
- Implementing WebView with JavaScript enabled
- Modifying ProGuard/R8 rules
- Changing data encryption or storage approach
Never Do
- Absolute prohibitions:
| Never | Why | |
|---|---|---|
| Commit secrets to git | Secrets in git history are permanent, even after removal | |
Log sensitive data (Log.d with tokens) | Logcat is accessible to other apps on rooted devices | |
| Trust client-side validation alone | All client validation can be bypassed | |
Use MODE_WORLD_READABLE | Any app can read your files | |
Enable cleartext traffic in production | Data interceptable on network | |
| Store passwords in plain text | Use EncryptedSharedPreferences or Android Keystore | |
Use WebView.setJavaScriptEnabled(true) without sanitizing | XSS attacks via injected content | |
Export components without android:permission | Any app can invoke them | |
| Disable certificate verification | Man-in-the-middle attacks | |
Use FLAG_SECURE to prevent screenshots AND log sensitive data | Inconsistent security posture |
WebView Security
- If you must use WebView:
Data Privacy & Compliance
- Hold less, for less time. Security asks "can an attacker read it?"; privacy asks "should we hold it at all, and for how long?" Data never collected cannot be breached, mis-declared, or missed in a deletion. Classify every field as you add it:
| Class | Android examples | Handling | |
|---|---|---|---|
| Non-personal | Aggregate counts, app version, crash-free rate | Normal handling | |
| Personal (PII) | Name, email, IP, user ID, advertising ID, Android ID / other device IDs | Minimize, access-control, include in export/delete, declare in Data safety | |
| Sensitive | Precise location, health, biometrics, contacts, photos/media, financial data, anything about minors | Explicit basis or consent, Keystore-backed encryption, never in cloud backup or logs |
Operating rules:
- Collect against a stated purpose. "Might be useful later" is breach scope, not a purpose. Don't log PII —
observability-and-instrumentationcovers log hygiene. - Minimize permissions. Prefer the Photo Picker (
ActivityResultContracts.PickVisualMedia) overREAD_MEDIA_IMAGES,ACCESS_COARSE_LOCATIONoverACCESS_FINE_LOCATION, and system pickers/intents over broad read permissions. Every permission you don't hold is data you can't leak. - Gate SDKs on consent. Analytics, ads, and attribution SDKs must not start collecting in
Application.onCreatebefore the user has chosen. Default collection off, then enable from the consent result:
- Declare what you actually ship. The Play Data safety form must match real collection, including every third-party SDK (analytics, ads, crash reporting, attribution). Check each SDK's own data-disclosure docs and re-check the form whenever an SDK is added or upgraded.
- Account deletion is a Play requirement. Apps that let users create an account must offer deletion both in-app and via a web link listed in Play Console, and deleting the account must delete (or anonymize) its associated data — not just flip an
isDeletedflag. - Set retention and make deletion reach every copy. On sign-out or account deletion, clear Room tables, DataStore, files and caches, cancel WorkManager jobs whose input data carries personal payloads, and trigger server-side and analytics-vendor deletion. Exclude tokens, PII, and anything bound to a Keystore key (undecryptable after restore anyway) from Auto Backup —
android:dataExtractionRulesfor API 31+,android:fullBackupContentfor API 30 and below. Set both ifminSdk< 31. - Design data-subject rights into the schema. GDPR/CCPA export, correction, and deletion are engineering features: key personal data by user ID so it is findable and erasable, not smeared across denormalized tables, blobs, and logs.
- Make policy configurable by region. Consent requirements and residency rules differ by user location — keep them behind a config boundary rather than hardcoding one jurisdiction.
OWASP Mobile Top 10 Quick Reference
| # | Risk | Android Mitigation | |
|---|---|---|---|
| M1 | Improper Credential Usage | Android Keystore, EncryptedSharedPreferences | |
| M2 | Inadequate Supply Chain Security | Dependency verification, version pinning | |
| M3 | Insecure Authentication | BiometricPrompt, OAuth2 with PKCE | |
| M4 | Insufficient Input/Output Validation | Validate deep links, intents, API responses | |
| M5 | Insecure Communication | Network Security Config, cert pinning | |
| M6 | Inadequate Privacy Controls | Minimize data collection, respect permissions | |
| M7 | Insufficient Binary Protections | R8/ProGuard, tamper detection | |
| M8 | Security Misconfiguration | Review manifest, disable debuggable in release | |
| M9 | Insecure Data Storage | EncryptedSharedPreferences, Room with encryption | |
| M10 | Insufficient Cryptography | Android Keystore for key management |
Common Rationalizations
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/security-and-hardening/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/guillemroca/agent-skills-android/security-and-hardening)