cyberaudit-skill 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +241 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +126 -0
- package/package.json +58 -0
- package/skills/cyberaudit/AGENT-BOOT.md +122 -0
- package/skills/cyberaudit/COMMANDS.md +1125 -0
- package/skills/cyberaudit/INSTALL.md +311 -0
- package/skills/cyberaudit/MASTER.md +194 -0
- package/skills/cyberaudit/README.md +154 -0
- package/skills/cyberaudit/USAGE-GUIDE.md +107 -0
- package/skills/cyberaudit/mobile/MOBILE-CHECKLIST.md +245 -0
- package/skills/cyberaudit/mobile/MOBILE-PHILOSOPHY.md +352 -0
- package/skills/cyberaudit/mobile/MOBILE-REMEDIATION-LIBRARY.md +468 -0
- package/skills/cyberaudit/mobile/MOBILE-THREAT-MODELS.md +279 -0
- package/skills/cyberaudit/mobile/frameworks/EXPO.md +247 -0
- package/skills/cyberaudit/mobile/frameworks/FLUTTER.md +338 -0
- package/skills/cyberaudit/mobile/frameworks/IONIC.md +248 -0
- package/skills/cyberaudit/mobile/frameworks/REACT-NATIVE.md +479 -0
- package/skills/cyberaudit/mobile/vulnerabilities/AUTH-MOBILE.md +160 -0
- package/skills/cyberaudit/mobile/vulnerabilities/BINARY-ANALYSIS.md +193 -0
- package/skills/cyberaudit/mobile/vulnerabilities/CRYPTO-MOBILE.md +192 -0
- package/skills/cyberaudit/mobile/vulnerabilities/IPC-DEEPLINKS.md +231 -0
- package/skills/cyberaudit/mobile/vulnerabilities/NETWORK-MOBILE.md +165 -0
- package/skills/cyberaudit/mobile/vulnerabilities/PERMISSIONS.md +180 -0
- package/skills/cyberaudit/mobile/vulnerabilities/RUNTIME-MOBILE.md +214 -0
- package/skills/cyberaudit/mobile/vulnerabilities/STORAGE.md +197 -0
- package/skills/cyberaudit/reports/EXECUTIVE-SUMMARY-TEMPLATE.md +188 -0
- package/skills/cyberaudit/reports/REPORT-TEMPLATE-MOBILE.md +410 -0
- package/skills/cyberaudit/reports/REPORT-TEMPLATE-WEB.md +222 -0
- package/skills/cyberaudit/shared/COMPLIANCE.md +307 -0
- package/skills/cyberaudit/shared/CVSS-GUIDE.md +175 -0
- package/skills/cyberaudit/shared/OWASP-MAPPER.md +130 -0
- package/skills/cyberaudit/shared/SEVERITY-SCORING.md +102 -0
- package/skills/cyberaudit/shared/THREAT-MODELING.md +112 -0
- package/skills/cyberaudit/web/WEB-CHECKLIST.md +222 -0
- package/skills/cyberaudit/web/WEB-PHILOSOPHY.md +308 -0
- package/skills/cyberaudit/web/WEB-REMEDIATION-LIBRARY.md +665 -0
- package/skills/cyberaudit/web/WEB-THREAT-MODELS.md +460 -0
- package/skills/cyberaudit/web/frameworks/ANGULAR.md +169 -0
- package/skills/cyberaudit/web/frameworks/EXPRESS.md +185 -0
- package/skills/cyberaudit/web/frameworks/LARAVEL.md +371 -0
- package/skills/cyberaudit/web/frameworks/NESTJS.md +337 -0
- package/skills/cyberaudit/web/frameworks/NEXTJS.md +352 -0
- package/skills/cyberaudit/web/frameworks/REACT.md +346 -0
- package/skills/cyberaudit/web/frameworks/VUE.md +205 -0
- package/skills/cyberaudit/web/vulnerabilities/AUTH-AUTHZ.md +117 -0
- package/skills/cyberaudit/web/vulnerabilities/BUSINESS-LOGIC.md +603 -0
- package/skills/cyberaudit/web/vulnerabilities/CORS.md +117 -0
- package/skills/cyberaudit/web/vulnerabilities/CSRF.md +131 -0
- package/skills/cyberaudit/web/vulnerabilities/DESERIALIZATION.md +96 -0
- package/skills/cyberaudit/web/vulnerabilities/HEADERS.md +105 -0
- package/skills/cyberaudit/web/vulnerabilities/IDOR-BOLA.md +153 -0
- package/skills/cyberaudit/web/vulnerabilities/INJECTION.md +165 -0
- package/skills/cyberaudit/web/vulnerabilities/SECRETS.md +119 -0
- package/skills/cyberaudit/web/vulnerabilities/SSRF.md +124 -0
- package/skills/cyberaudit/web/vulnerabilities/SUPPLY-CHAIN.md +142 -0
- package/skills/cyberaudit/web/vulnerabilities/XSS.md +133 -0
- package/skills/cyberaudit/web/vulnerabilities/XXE.md +94 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# 🌐 NETWORK MOBILE — VULNERABILITY GUIDE
|
|
2
|
+
# Network security for mobile applications
|
|
3
|
+
|
|
4
|
+
═══════════════════════════════════════════════════════════════
|
|
5
|
+
MOBILE NETWORK THREAT MODEL
|
|
6
|
+
═══════════════════════════════════════════════════════════════
|
|
7
|
+
|
|
8
|
+
THE MOBILE NETWORK ENVIRONMENT IS HOSTILE BY DEFINITION
|
|
9
|
+
─────────────────────────────────────────────────────────
|
|
10
|
+
Mobile users connect via:
|
|
11
|
+
→ Public WiFi (cafés, hotels, airports) → trivial MitM
|
|
12
|
+
→ Corporate networks with TLS inspection → MitM by design
|
|
13
|
+
→ 4G/5G mobile networks → harder interception
|
|
14
|
+
→ Personal hotspots → lower risk
|
|
15
|
+
|
|
16
|
+
AN ATTACKER ON THE SAME NETWORK CAN:
|
|
17
|
+
→ See all cleartext HTTP traffic
|
|
18
|
+
→ Decrypt HTTPS traffic without certificate pinning
|
|
19
|
+
(via malicious CA installation + proxy)
|
|
20
|
+
→ Inject content into HTTP responses
|
|
21
|
+
→ Redirect traffic to a malicious server
|
|
22
|
+
|
|
23
|
+
═══════════════════════════════════════════════════════════════
|
|
24
|
+
DETAILED NETWORK VULNERABILITIES
|
|
25
|
+
═══════════════════════════════════════════════════════════════
|
|
26
|
+
|
|
27
|
+
VULN-NET-001 — Cleartext HTTP traffic
|
|
28
|
+
Severity: CRITICAL (CVSS 8.1)
|
|
29
|
+
MASVS : MASVS-NETWORK-1
|
|
30
|
+
|
|
31
|
+
Detection:
|
|
32
|
+
→ http:// in hardcoded URLs
|
|
33
|
+
→ android:usesCleartextTraffic="true"
|
|
34
|
+
→ NSExceptionAllowsInsecureHTTPLoads = true (iOS)
|
|
35
|
+
→ No Network Security Config (Android)
|
|
36
|
+
|
|
37
|
+
Fix:
|
|
38
|
+
Android — Network Security Config:
|
|
39
|
+
<network-security-config>
|
|
40
|
+
<base-config cleartextTrafficPermitted="false" />
|
|
41
|
+
</network-security-config>
|
|
42
|
+
|
|
43
|
+
iOS — App Transport Security:
|
|
44
|
+
(Enabled by default since iOS 9, do not disable)
|
|
45
|
+
Remove any NSAllowsArbitraryLoads exception
|
|
46
|
+
|
|
47
|
+
VULN-NET-002 — No Certificate Pinning
|
|
48
|
+
Severity: HIGH (CVSS 7.4)
|
|
49
|
+
MASVS : MASVS-NETWORK-2
|
|
50
|
+
|
|
51
|
+
Explanation:
|
|
52
|
+
Without pinning, the app accepts any certificate
|
|
53
|
+
signed by a trusted system CA.
|
|
54
|
+
|
|
55
|
+
An attacker can:
|
|
56
|
+
1. Convince the user to install a custom CA
|
|
57
|
+
(social engineering, corporate MDM)
|
|
58
|
+
2. Compromise a legitimate CA (rare but documented)
|
|
59
|
+
3. Use a preinstalled malicious CA (rare)
|
|
60
|
+
|
|
61
|
+
With a proxy (mitmproxy, Burp Suite):
|
|
62
|
+
HTTPS traffic intercepted in minutes.
|
|
63
|
+
|
|
64
|
+
Exploitation scenario:
|
|
65
|
+
1. Attacker on same WiFi network
|
|
66
|
+
2. ARP spoofing to redirect traffic
|
|
67
|
+
3. mitmproxy with generated CA
|
|
68
|
+
4. If no pinning: traffic decrypted in cleartext
|
|
69
|
+
5. Extraction of Bearer tokens from headers
|
|
70
|
+
|
|
71
|
+
VULN-NET-003 — Certificate validation disabled
|
|
72
|
+
Severity: CRITICAL (CVSS 9.1)
|
|
73
|
+
MASVS : MASVS-NETWORK-1
|
|
74
|
+
|
|
75
|
+
Detection:
|
|
76
|
+
// React Native — ignore SSL errors
|
|
77
|
+
// (often left by mistake from development)
|
|
78
|
+
fetch(url, {
|
|
79
|
+
// Some configs allow SSL bypass
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// Flutter — badCertificateCallback always returns true
|
|
83
|
+
client.badCertificateCallback = (cert, host, port) => true
|
|
84
|
+
|
|
85
|
+
// Android — TrustManager that accepts everything
|
|
86
|
+
TrustManager {
|
|
87
|
+
override fun checkServerTrusted(...) {} // EMPTY = accepts all
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// iOS — URLSessionDelegate
|
|
91
|
+
func urlSession(..., didReceive challenge: ...) {
|
|
92
|
+
completionHandler(.useCredential, ...) // Accepts all
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Fix:
|
|
96
|
+
Never disable SSL validation.
|
|
97
|
+
Use certificate pinning instead.
|
|
98
|
+
In development: use a properly configured
|
|
99
|
+
self-signed certificate, not total bypass.
|
|
100
|
+
|
|
101
|
+
VULN-NET-004 — Sensitive data in Query Parameters
|
|
102
|
+
Severity: HIGH (CVSS 7.5)
|
|
103
|
+
MASVS : MASVS-NETWORK-1
|
|
104
|
+
|
|
105
|
+
Explanation:
|
|
106
|
+
Query parameters appear in:
|
|
107
|
+
→ Server logs (access.log)
|
|
108
|
+
→ Proxy logs
|
|
109
|
+
→ Browser history (if WebView)
|
|
110
|
+
→ Referer headers sent to third-party services
|
|
111
|
+
→ Analytics and monitoring
|
|
112
|
+
|
|
113
|
+
Detection:
|
|
114
|
+
GET /api/users?token=eyJhbGc...
|
|
115
|
+
GET /api/data?password=secret
|
|
116
|
+
GET /api/reset?key=abc123
|
|
117
|
+
|
|
118
|
+
Fix:
|
|
119
|
+
Tokens and secrets → HTTP Authorization headers
|
|
120
|
+
Sensitive data → Request body (POST)
|
|
121
|
+
|
|
122
|
+
// ❌ Vulnerable
|
|
123
|
+
fetch(`/api/data?token=${token}`)
|
|
124
|
+
|
|
125
|
+
// ✅ Correct
|
|
126
|
+
fetch('/api/data', {
|
|
127
|
+
headers: {
|
|
128
|
+
Authorization: `Bearer ${token}`,
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
VULN-NET-005 — No network timeout
|
|
133
|
+
Severity: MEDIUM (CVSS 5.3)
|
|
134
|
+
MASVS : MASVS-NETWORK-1
|
|
135
|
+
|
|
136
|
+
Explanation:
|
|
137
|
+
Without timeout, a request can block indefinitely.
|
|
138
|
+
An attacker can:
|
|
139
|
+
→ Make requests to a slow-responding server
|
|
140
|
+
→ Exhaust app resources (threads, memory)
|
|
141
|
+
→ Cause degraded experience
|
|
142
|
+
|
|
143
|
+
Fix:
|
|
144
|
+
// React Native fetch
|
|
145
|
+
const controller = new AbortController()
|
|
146
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000)
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const response = await fetch(url, {
|
|
150
|
+
signal: controller.signal,
|
|
151
|
+
})
|
|
152
|
+
} finally {
|
|
153
|
+
clearTimeout(timeoutId)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Axios
|
|
157
|
+
axios.create({
|
|
158
|
+
timeout: 10000, // 10 seconds
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// Dio (Flutter)
|
|
162
|
+
Dio(BaseOptions(
|
|
163
|
+
connectTimeout: Duration(seconds: 5),
|
|
164
|
+
receiveTimeout: Duration(seconds: 30),
|
|
165
|
+
))
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# 🔐 PERMISSIONS — MOBILE VULNERABILITY GUIDE
|
|
2
|
+
# Mobile permissions audit
|
|
3
|
+
|
|
4
|
+
═══════════════════════════════════════════════════════════════
|
|
5
|
+
PERMISSIONS PHILOSOPHY
|
|
6
|
+
═══════════════════════════════════════════════════════════════
|
|
7
|
+
|
|
8
|
+
EVERY PERMISSION IS A PROMISE TO THE USER
|
|
9
|
+
────────────────────────────────────────────────────
|
|
10
|
+
By requesting a permission, you promise:
|
|
11
|
+
→ I will use this capability ONLY for what I told you
|
|
12
|
+
→ I will access your data ONLY when necessary
|
|
13
|
+
→ I will not share your data without your consent
|
|
14
|
+
|
|
15
|
+
An unnecessary permission = a promise you won't keep.
|
|
16
|
+
|
|
17
|
+
SENSITIVE PERMISSIONS AND THEIR RISKS
|
|
18
|
+
────────────────────────────────────────
|
|
19
|
+
CAMERA
|
|
20
|
+
Risk: Camera access at any time
|
|
21
|
+
Legitimate use: QR scan, profile photo
|
|
22
|
+
Possible abuse: Non-consensual surveillance
|
|
23
|
+
|
|
24
|
+
MICROPHONE
|
|
25
|
+
Risk: Audio recording in background
|
|
26
|
+
Legitimate use: Voice calls, audio notes
|
|
27
|
+
Possible abuse: Conversation eavesdropping
|
|
28
|
+
|
|
29
|
+
LOCATION
|
|
30
|
+
Risk: Real-time movement tracking
|
|
31
|
+
Legitimate use: Navigation, delivery
|
|
32
|
+
Possible abuse: Surveillance, profiling
|
|
33
|
+
Fine vs Coarse: Choose the least precise possible
|
|
34
|
+
|
|
35
|
+
CONTACTS
|
|
36
|
+
Risk: Access to entire address book
|
|
37
|
+
Legitimate use: Invite friends
|
|
38
|
+
Possible abuse: Email harvesting, spam
|
|
39
|
+
|
|
40
|
+
STORAGE / FILES
|
|
41
|
+
Risk: Access to all device files
|
|
42
|
+
Legitimate use: Select a photo
|
|
43
|
+
Possible abuse: Document theft, private photos
|
|
44
|
+
Android 13+: Photo Picker without storage permission
|
|
45
|
+
|
|
46
|
+
BACKGROUND LOCATION
|
|
47
|
+
Risk: Permanent tracking even app closed
|
|
48
|
+
Legitimate use: GPS navigation in background
|
|
49
|
+
Possible abuse: 24/7 surveillance
|
|
50
|
+
|
|
51
|
+
READ_CALL_LOG / SEND_SMS
|
|
52
|
+
Risk: Access to communications
|
|
53
|
+
Legitimate use: Very rare
|
|
54
|
+
Possible abuse: OTP SMS theft, surveillance
|
|
55
|
+
|
|
56
|
+
═══════════════════════════════════════════════════════════════
|
|
57
|
+
VULNERABLE PERMISSIONS PATTERNS
|
|
58
|
+
═══════════════════════════════════════════════════════════════
|
|
59
|
+
|
|
60
|
+
VULN-PERM-001 — Excessive declared permissions
|
|
61
|
+
Severity: MEDIUM (CVSS 4.3)
|
|
62
|
+
MASVS : MASVS-PLATFORM-7
|
|
63
|
+
|
|
64
|
+
Detection:
|
|
65
|
+
AndroidManifest.xml:
|
|
66
|
+
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
|
67
|
+
<uses-permission android:name="android.permission.SEND_SMS"/>
|
|
68
|
+
<uses-permission android:name="android.permission.CAMERA"/>
|
|
69
|
+
→ Verify if each is ACTUALLY used in the code
|
|
70
|
+
|
|
71
|
+
Fix:
|
|
72
|
+
1. List all declared permissions
|
|
73
|
+
2. For each permission:
|
|
74
|
+
- Search for its usage in code
|
|
75
|
+
- If not found → remove
|
|
76
|
+
3. Use less invasive alternatives:
|
|
77
|
+
- Storage → SAF (Storage Access Framework) Android
|
|
78
|
+
- Photo → Photo Picker (Android 13+, iOS 14+)
|
|
79
|
+
- Location → Coarse if Fine not needed
|
|
80
|
+
|
|
81
|
+
VULN-PERM-002 — Permission requested at startup (UX and security)
|
|
82
|
+
Severity: LOW (CVSS 2.0)
|
|
83
|
+
MASVS : MASVS-PLATFORM-7
|
|
84
|
+
|
|
85
|
+
Explanation:
|
|
86
|
+
Asking all permissions at startup:
|
|
87
|
+
→ Poor UX (user reflexively refuses)
|
|
88
|
+
→ Impossible to justify contextually
|
|
89
|
+
→ User doesn't understand why
|
|
90
|
+
→ High refusal rate = broken features
|
|
91
|
+
|
|
92
|
+
Fix:
|
|
93
|
+
// Request at time of need with explanation
|
|
94
|
+
|
|
95
|
+
const requestCameraPermission = async () => {
|
|
96
|
+
// 1. Explain why BEFORE asking
|
|
97
|
+
const shouldRequest = await showExplanationDialog({
|
|
98
|
+
title: 'Camera access',
|
|
99
|
+
message: 'To scan your ticket QR code, '
|
|
100
|
+
+ 'we need access to your camera.',
|
|
101
|
+
confirmText: 'Allow',
|
|
102
|
+
cancelText: 'Not now',
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
if (!shouldRequest) return false
|
|
106
|
+
|
|
107
|
+
// 2. Request permission
|
|
108
|
+
const { status } = await Camera.requestCameraPermissionsAsync()
|
|
109
|
+
|
|
110
|
+
// 3. Handle refusal gracefully
|
|
111
|
+
if (status !== 'granted') {
|
|
112
|
+
showAlternativeOptions() // Offer an alternative
|
|
113
|
+
return false
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
VULN-PERM-003 — App crash if permission denied
|
|
120
|
+
Severity: MEDIUM (CVSS 4.0)
|
|
121
|
+
MASVS : MASVS-PLATFORM-7
|
|
122
|
+
|
|
123
|
+
Detection:
|
|
124
|
+
// No handling for "permission denied" case
|
|
125
|
+
const { status } = await requestPermission()
|
|
126
|
+
// Direct usage without checking status
|
|
127
|
+
const photo = await takePicture() // Crash if denied
|
|
128
|
+
|
|
129
|
+
Fix:
|
|
130
|
+
const handleCameraPermission = async () => {
|
|
131
|
+
const { status, canAskAgain } =
|
|
132
|
+
await Camera.requestCameraPermissionsAsync()
|
|
133
|
+
|
|
134
|
+
switch (status) {
|
|
135
|
+
case 'granted':
|
|
136
|
+
// Continue normally
|
|
137
|
+
openCamera()
|
|
138
|
+
break
|
|
139
|
+
|
|
140
|
+
case 'denied':
|
|
141
|
+
if (canAskAgain) {
|
|
142
|
+
// Explain and offer to re-request
|
|
143
|
+
showPermissionRationale()
|
|
144
|
+
} else {
|
|
145
|
+
// Direct to settings
|
|
146
|
+
showGoToSettingsDialog()
|
|
147
|
+
}
|
|
148
|
+
break
|
|
149
|
+
|
|
150
|
+
case 'undetermined':
|
|
151
|
+
// Don't force, wait for user action
|
|
152
|
+
break
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
VULN-PERM-004 — Background Location without justification
|
|
157
|
+
Severity: HIGH (CVSS 6.5)
|
|
158
|
+
MASVS : MASVS-PLATFORM-7
|
|
159
|
+
|
|
160
|
+
Detection:
|
|
161
|
+
AndroidManifest.xml:
|
|
162
|
+
<uses-permission
|
|
163
|
+
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
|
164
|
+
|
|
165
|
+
Info.plist:
|
|
166
|
+
NSLocationAlwaysAndWhenInUseUsageDescription
|
|
167
|
+
NSLocationAlwaysUsageDescription
|
|
168
|
+
|
|
169
|
+
Questions to ask:
|
|
170
|
+
→ Does the app REALLY need background location?
|
|
171
|
+
→ An active delivery app: YES
|
|
172
|
+
→ An e-commerce app: NO
|
|
173
|
+
→ A fitness tracking app: YES but with explicit consent
|
|
174
|
+
|
|
175
|
+
Fix:
|
|
176
|
+
→ If background location unnecessary: remove
|
|
177
|
+
→ If necessary: clear justification in privacy policy
|
|
178
|
+
→ Request only when user activates tracking
|
|
179
|
+
→ Provide a way to easily disable
|
|
180
|
+
→ Visible indicator when location is active
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# ⚡ RUNTIME MOBILE — VULNERABILITY GUIDE
|
|
2
|
+
# Runtime security for mobile applications
|
|
3
|
+
|
|
4
|
+
═══════════════════════════════════════════════════════════════
|
|
5
|
+
RUNTIME SECURITY — CONCEPT
|
|
6
|
+
═══════════════════════════════════════════════════════════════
|
|
7
|
+
|
|
8
|
+
RUNTIME SECURITY PROTECTS THE APP DURING EXECUTION
|
|
9
|
+
────────────────────────────────────────────────────────
|
|
10
|
+
Unlike static security (code, config),
|
|
11
|
+
runtime security protects against:
|
|
12
|
+
→ App behavior modifications (Frida, hooking)
|
|
13
|
+
→ Execution in a compromised environment (root, jailbreak)
|
|
14
|
+
→ Unauthorised debugging
|
|
15
|
+
→ Binary modification (repackaging)
|
|
16
|
+
→ Emulation (for apps requiring a real device)
|
|
17
|
+
|
|
18
|
+
RUNTIME PROTECTION LEVELS
|
|
19
|
+
───────────────────────────────
|
|
20
|
+
LEVEL 1 — Detection and information
|
|
21
|
+
→ Detect root/jailbreak
|
|
22
|
+
→ Inform the user of the risk
|
|
23
|
+
→ Limit sensitive features
|
|
24
|
+
(Appropriate for most apps)
|
|
25
|
+
|
|
26
|
+
LEVEL 2 — Detection and restriction
|
|
27
|
+
→ Detect root/jailbreak + Frida
|
|
28
|
+
→ Refuse to run in degraded mode
|
|
29
|
+
→ Delete sensitive data from device
|
|
30
|
+
(Banking, health apps)
|
|
31
|
+
|
|
32
|
+
LEVEL 3 — Active protection
|
|
33
|
+
→ All of level 2
|
|
34
|
+
→ Advanced anti-debug
|
|
35
|
+
→ Detection code obfuscation
|
|
36
|
+
→ Binary integrity verification
|
|
37
|
+
(Government, defence apps)
|
|
38
|
+
|
|
39
|
+
═══════════════════════════════════════════════════════════════
|
|
40
|
+
RUNTIME VULNERABILITIES
|
|
41
|
+
═══════════════════════════════════════════════════════════════
|
|
42
|
+
|
|
43
|
+
VULN-RUNTIME-001 — No Root/Jailbreak Detection
|
|
44
|
+
Severity: MEDIUM to HIGH depending on context
|
|
45
|
+
MASVS : MASVS-RESILIENCE-1
|
|
46
|
+
|
|
47
|
+
Impact by app type:
|
|
48
|
+
Banking app : HIGH (financial data at risk)
|
|
49
|
+
Health app : HIGH (medical data at risk)
|
|
50
|
+
General public app: MEDIUM (reduce attack surface)
|
|
51
|
+
Gaming app : LOW (anti-cheat primarily)
|
|
52
|
+
|
|
53
|
+
React Native fix:
|
|
54
|
+
// npm install react-native-device-info
|
|
55
|
+
import DeviceInfo from 'react-native-device-info'
|
|
56
|
+
|
|
57
|
+
// npm install jail-monkey
|
|
58
|
+
import JailMonkey from 'jail-monkey'
|
|
59
|
+
|
|
60
|
+
export const checkDeviceSecurity = async () => {
|
|
61
|
+
const isJailBroken = JailMonkey.isJailBroken()
|
|
62
|
+
const isOnExternalStorage = JailMonkey.isOnExternalStorage()
|
|
63
|
+
const canMockLocation = JailMonkey.canMockLocation()
|
|
64
|
+
const hasHooks = JailMonkey.hookDetected()
|
|
65
|
+
|
|
66
|
+
const isCompromised =
|
|
67
|
+
isJailBroken ||
|
|
68
|
+
isOnExternalStorage ||
|
|
69
|
+
hasHooks
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
isCompromised,
|
|
73
|
+
reasons: {
|
|
74
|
+
isJailBroken,
|
|
75
|
+
isOnExternalStorage,
|
|
76
|
+
canMockLocation,
|
|
77
|
+
hasHooks,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Usage at app startup
|
|
83
|
+
const { isCompromised, reasons } = await checkDeviceSecurity()
|
|
84
|
+
|
|
85
|
+
if (isCompromised) {
|
|
86
|
+
// For non-critical apps: warning
|
|
87
|
+
Alert.alert(
|
|
88
|
+
'Security',
|
|
89
|
+
'Your device appears to be modified. '
|
|
90
|
+
+ 'Your data security may be reduced.',
|
|
91
|
+
[{ text: 'Continue', style: 'destructive' }]
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
// For critical apps: block
|
|
95
|
+
Alert.alert(
|
|
96
|
+
'Access denied',
|
|
97
|
+
'The application cannot run '
|
|
98
|
+
+ 'on a rooted/jailbroken device.',
|
|
99
|
+
[{
|
|
100
|
+
text: 'Exit',
|
|
101
|
+
onPress: () => RNExitApp.exitApp(),
|
|
102
|
+
}]
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
VULN-RUNTIME-002 — No Frida Detection
|
|
107
|
+
Severity: HIGH for critical apps
|
|
108
|
+
MASVS : MASVS-RESILIENCE-3
|
|
109
|
+
|
|
110
|
+
What is Frida?
|
|
111
|
+
Frida is a dynamic instrumentation framework.
|
|
112
|
+
It can hook app functions at runtime
|
|
113
|
+
and modify their behavior.
|
|
114
|
+
|
|
115
|
+
Examples of attacks via Frida:
|
|
116
|
+
→ Bypass biometric verification
|
|
117
|
+
→ Key extraction from Keychain
|
|
118
|
+
→ Bypass root detection
|
|
119
|
+
→ Modify transaction amounts
|
|
120
|
+
|
|
121
|
+
Fix:
|
|
122
|
+
// Basic detection via Frida port (27042)
|
|
123
|
+
// and characteristic process names
|
|
124
|
+
|
|
125
|
+
// For serious protection:
|
|
126
|
+
// → Use a commercial protection library
|
|
127
|
+
// (Guardsquare DexGuard, Arxan, Appdome)
|
|
128
|
+
// → Or implement native checks (NDK)
|
|
129
|
+
// as JavaScript checks are more easily bypassed
|
|
130
|
+
|
|
131
|
+
// Basic detection (can be bypassed):
|
|
132
|
+
import JailMonkey from 'jail-monkey'
|
|
133
|
+
|
|
134
|
+
const hasFridaDetected = JailMonkey.hookDetected()
|
|
135
|
+
|
|
136
|
+
// ⚠️ This detection alone is insufficient
|
|
137
|
+
// for highly critical apps
|
|
138
|
+
// An advanced attacker can bypass JailMonkey
|
|
139
|
+
|
|
140
|
+
VULN-RUNTIME-003 — Sensitive Data in Memory
|
|
141
|
+
Severity: MEDIUM
|
|
142
|
+
MASVS : MASVS-STORAGE-1
|
|
143
|
+
|
|
144
|
+
Explanation:
|
|
145
|
+
On a rooted device, app memory can be dumped.
|
|
146
|
+
Sensitive data held in memory too long is at risk.
|
|
147
|
+
|
|
148
|
+
Particularly critical for:
|
|
149
|
+
→ Encryption keys
|
|
150
|
+
→ Entered passwords
|
|
151
|
+
→ Biometric data (templates)
|
|
152
|
+
→ Auth tokens
|
|
153
|
+
|
|
154
|
+
Best practices:
|
|
155
|
+
→ Clear sensitive data after use
|
|
156
|
+
→ Use data types that support clearing
|
|
157
|
+
→ Do not cache sensitive data
|
|
158
|
+
→ Cryptographic keys: let Keystore handle them
|
|
159
|
+
(it never exposes them in application memory)
|
|
160
|
+
|
|
161
|
+
// React Native — Clear sensitive data
|
|
162
|
+
// Note: JavaScript does not guarantee memory clearing
|
|
163
|
+
// For real protection → native code (NDK/NDK)
|
|
164
|
+
|
|
165
|
+
let sensitiveData = await getPassword()
|
|
166
|
+
try {
|
|
167
|
+
// Use the data
|
|
168
|
+
await doSensitiveOperation(sensitiveData)
|
|
169
|
+
} finally {
|
|
170
|
+
// "Clear" — limited in JS but better than nothing
|
|
171
|
+
sensitiveData = null
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
VULN-RUNTIME-004 — Detectable Debug Mode
|
|
175
|
+
Severity: MEDIUM
|
|
176
|
+
MASVS : MASVS-CODE-2
|
|
177
|
+
|
|
178
|
+
Detection:
|
|
179
|
+
An attacker can detect if an app is in debug
|
|
180
|
+
to adapt their attack.
|
|
181
|
+
|
|
182
|
+
BuildConfig.DEBUG = true (Android)
|
|
183
|
+
→ Attacker knows the app is in debug mode
|
|
184
|
+
→ Debug features may be active
|
|
185
|
+
→ Logs are probably verbose
|
|
186
|
+
|
|
187
|
+
Fix:
|
|
188
|
+
// React Native — Ensure __DEV__ = false in prod
|
|
189
|
+
// Test with release build
|
|
190
|
+
|
|
191
|
+
console.log('DEV mode:', __DEV__)
|
|
192
|
+
// Must be false in release
|
|
193
|
+
|
|
194
|
+
// Android — Verify in build.gradle
|
|
195
|
+
// release { debuggable false }
|
|
196
|
+
|
|
197
|
+
// Runtime check
|
|
198
|
+
if (__DEV__) {
|
|
199
|
+
console.warn('Application in development mode')
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
═══════════════════════════════════════════════════════════════
|
|
203
|
+
COMPLETE RUNTIME CHECKLIST
|
|
204
|
+
═══════════════════════════════════════════════════════════════
|
|
205
|
+
|
|
206
|
+
□ Root/Jailbreak detection implemented ?
|
|
207
|
+
□ Defined behavior if compromise detected ?
|
|
208
|
+
□ Frida detection (if critical app) ?
|
|
209
|
+
□ Anti-debug implemented (if very critical app) ?
|
|
210
|
+
□ Sensitive data cleared from memory after use ?
|
|
211
|
+
□ Debug mode disabled in production build ?
|
|
212
|
+
□ Binary integrity verification (if critical app) ?
|
|
213
|
+
□ Emulator behavior defined ?
|
|
214
|
+
□ Production build tested with active protections ?
|