nativekeel 0.1.14 → 0.1.16
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 +37 -27
- package/package.json +1 -1
- package/src/analyze.js +2 -2
- package/src/native.js +3 -2
- package/src/plan.js +1 -1
- package/src/project.js +32 -0
- package/src/report-html.js +2 -1
- package/src/security.js +92 -1
package/README.md
CHANGED
|
@@ -6,36 +6,46 @@ Health check for React Native and Expo apps. One command, no install, no account
|
|
|
6
6
|
npx nativekeel
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
**What's new in 0.1.
|
|
10
|
-
|
|
11
|
-
It answers the questions that decide whether your app can still ship:
|
|
12
|
-
|
|
13
|
-
- **Is your React Native / Expo version still supported?** React Native supports the latest minor and the two before it.
|
|
14
|
-
- **Can you upgrade at all?** The legacy architecture was removed in 0.82. If the New Architecture is off, you are stuck at 0.81.
|
|
15
|
-
- **Which packages block the upgrade?** Native modules without New Architecture support, unmaintained or with no release in years, with known alternatives. Outdated "unmaintained" flags are cross-checked against the latest npm release.
|
|
16
|
-
- **What can you simply delete?** Packages that are installed but never imported, referenced natively or required by another package. Every one you remove is one you never upgrade.
|
|
17
|
-
- **Will the stores accept your next build?** Google Play `targetSdk` and 16 KB page size (it opens your built APK/AAB and checks the alignment of every native library), and the iOS privacy manifest.
|
|
18
|
-
- **Are secrets shipped inside your app?** AWS, Stripe, OpenAI, Anthropic, GitHub, Slack, SendGrid, Twilio, Shopify, Google OAuth keys, private keys and Supabase `service_role` keys (anon keys are fine), plus `.env` values that `react-native-config` or `EXPO_PUBLIC_` compile into the bundle, and secrets in Expo `extra` or `eas.json`. Server-side folders are reported separately.
|
|
19
|
-
- **Is transport security off?** Cleartext HTTP or `debuggable` in the release Android manifest, `NSAllowsArbitraryLoads` on iOS.
|
|
20
|
-
- **Do you ship known vulnerabilities?** Advisories from the GitHub Advisory Database for the exact versions in your lockfile or `node_modules`. Advisories that only affect Node.js servers are kept, at low severity.
|
|
21
|
-
- **Can someone break in?** Grouped by OWASP MASVS: Firebase Realtime Database/Firestore/Storage rules open to anyone (or in test mode), TLS certificate checks turned off in native code, hardcoded encryption keys, MD5/SHA-1 on passwords, ECB mode, `Math.random` for nonces and salts. These are static checks: they catch the common, detectable mistakes, not everything a penetration test of the running app would.
|
|
22
|
-
- **Can someone read your users' data?** Passwords that flow into crash reports, analytics, remote databases or plain AsyncStorage (followed through intermediate variables), WebViews that let page scripts read local files or load HTTP into HTTPS, Android backups that copy tokens, Android components any app can start, API calls over plain HTTP, auth tokens in unencrypted storage.
|
|
23
|
-
- **Is it slow or heavy?** A FlatList inside a ScrollView (no virtualization), animations with `useNativeDriver: false`, `console.log` left in release builds, whole-library `lodash`/`moment` imports, images over 500 KB that the app requires. Static signs to measure on a device, not a profiler.
|
|
24
|
-
- **Can it be taken apart?** Source maps packaged into the app, Hermes or R8 off in release (OWASP MASVS-RESILIENCE). Obfuscation only slows an attacker down; keep secrets and checks on the server.
|
|
25
|
-
- **Will it crash at runtime?** Reanimated without its Babel plugin or `react-native-worklets`, mixed `@react-native-firebase/*` or `@react-navigation/*` majors, a second copy of React or React Native inside a dependency, Kotlin modules that cannot load through the New Architecture interop layer, AppDelegate setups that crash in Release, camera/photos/location access without the Info.plist description iOS requires, imports of APIs removed from React Native core (`AsyncStorage`, `Picker`, `ViewPropTypes`, …).
|
|
26
|
-
- **Leftovers from old templates?** Flipper, JavaScriptCore instead of Hermes.
|
|
9
|
+
**What's new in 0.1.16:** deep-link checks: unverified Android App Links, and the template `myapp://` scheme that other apps can claim (MASVS-PLATFORM). **0.1.15:** run it at a monorepo root and it lists the app folders to scan. **0.1.14:** secrets in Expo config (`extra`, `EXPO_PUBLIC_`, `eas.json`) and imports of APIs removed from React Native core. Recent releases added a *Start here* list in every report, hacking risks mapped to OWASP MASVS, crash and performance checks. Every check is tuned on 450+ open-source React Native and Expo apps to keep false alarms out. [All releases →](https://nativekeel.com/changelog)
|
|
27
10
|
|
|
28
11
|
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Likely upgrade blocker. Alternatives: expo-image.
|
|
12
|
+
Summary 4 critical · 5 high · 4 medium · 6 low
|
|
13
|
+
Security (OWASP MASVS) crypto 1 · network 1 · 7 groups checked
|
|
14
|
+
|
|
15
|
+
Start here
|
|
16
|
+
1. Revoke the AWS access key ID in src/App.js:6 at the provider today.
|
|
17
|
+
2. Set targetSdkVersion = 36 and compileSdkVersion = 36 in android/build.gradle.
|
|
18
|
+
3. Run pod install, commit the generated PrivacyInfo.xcprivacy, and add your data types.
|
|
37
19
|
```
|
|
38
20
|
|
|
21
|
+
## What it checks
|
|
22
|
+
|
|
23
|
+
**Upgrade**
|
|
24
|
+
- **Is your React Native / Expo version still supported?** React Native supports the latest three minors; in Expo projects React Native moves with the SDK.
|
|
25
|
+
- **Can you upgrade at all?** The legacy architecture was removed in 0.82. If the New Architecture is off (it is off by default before 0.76), you are stuck at 0.81.
|
|
26
|
+
- **Which packages block the upgrade?** Native modules without New Architecture support (cross-checked with the package's own codegen spec), unmaintained or with no release in years, with verified alternatives and renamed packages. Library versions for each step come from the libraries' own compatibility tables.
|
|
27
|
+
- **What can you simply delete?** Installed packages that nothing imports, references natively, requires or patches.
|
|
28
|
+
|
|
29
|
+
**Store**
|
|
30
|
+
- **Will Google Play and the App Store accept your next build?** `targetSdk`, 16 KB memory pages (it also opens your built APK/AAB and checks every native library), the iOS privacy manifest, and missing Info.plist usage descriptions.
|
|
31
|
+
|
|
32
|
+
**Crashes**
|
|
33
|
+
- **Will it crash at runtime?** Reanimated without its Babel plugin or `react-native-worklets`, mixed `@react-native-firebase/*` or `@react-navigation/*` majors, a second copy of React or React Native inside a dependency, Kotlin modules that cannot load through the New Architecture interop layer, AppDelegate setups that crash in Release, camera/photos/location access without the Info.plist text iOS requires, imports of APIs removed from React Native core (`AsyncStorage`, `Picker`, `ViewPropTypes`, …), and traps learned from real upgrades.
|
|
34
|
+
|
|
35
|
+
**Security, grouped by OWASP MASVS**
|
|
36
|
+
- **Secrets in the app or the repo:** AWS, Stripe, OpenAI, Anthropic, GitHub, Slack, SendGrid, Twilio, Shopify, Google OAuth and Supabase `service_role` keys, private keys, `.env` values compiled into the bundle, Expo `extra`/`EXPO_PUBLIC_`/`eas.json` secrets, signing keys and passwords.
|
|
37
|
+
- **Data on the device:** passwords that flow into crash reports, analytics, databases or plain AsyncStorage (followed through variables), auth tokens in unencrypted storage, Android backups that copy them.
|
|
38
|
+
- **Network:** TLS certificate checks turned off in native code, cleartext HTTP, `NSAllowsArbitraryLoads`, plain-HTTP API calls, user-installed CAs in release.
|
|
39
|
+
- **Backend rules:** Firebase Realtime Database, Firestore and Storage rules open to anyone or in test mode.
|
|
40
|
+
- **Cryptography:** hardcoded encryption keys, MD5/SHA-1 on passwords, ECB mode, `Math.random` for nonces and salts.
|
|
41
|
+
- **Platform:** WebViews that read local files or load HTTP into HTTPS, Android components any app can start, unverified deep links and the template `myapp://` URL scheme.
|
|
42
|
+
- **Dependencies and reverse engineering:** known vulnerabilities in the exact versions you ship (GitHub Advisory Database), source maps in the app, Hermes or R8 off.
|
|
43
|
+
|
|
44
|
+
These are static checks: they catch the common, detectable mistakes, not everything a penetration test of the running app and backend would.
|
|
45
|
+
|
|
46
|
+
**Performance**
|
|
47
|
+
- **Is it slow or heavy?** A FlatList inside a ScrollView (no virtualization), animations with `useNativeDriver: false`, `console.log` left in release builds, whole-library `lodash`/`moment` imports, images over 500 KB that the app requires.
|
|
48
|
+
|
|
39
49
|
## Usage
|
|
40
50
|
|
|
41
51
|
```sh
|
|
@@ -54,7 +64,7 @@ Everything is free. The scan exits with code `1` when it finds a critical issue,
|
|
|
54
64
|
|
|
55
65
|
### Upgrade plan
|
|
56
66
|
|
|
57
|
-
`nativekeel plan` turns the report into ordered work: stop leaks
|
|
67
|
+
`nativekeel plan` turns the report into ordered work: stop leaks, set up a safety net of UI flows, fix crash risks, meet store deadlines, close security gaps, replace blocking packages, switch on the New Architecture at the right point, then upgrade React Native (or the Expo SDK) in small, reviewable hops with links to the Upgrade Helper diffs and the library versions each hop needs. Performance fixes and routine updates come last.
|
|
58
68
|
|
|
59
69
|
### GitHub Action
|
|
60
70
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nativekeel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Health check for React Native and Expo apps: upgrade blockers, store deadlines, crash risks, vulnerable dependencies and leaked secrets, with a step-by-step upgrade plan.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/analyze.js
CHANGED
|
@@ -6,7 +6,7 @@ import { scanSecrets } from './secrets.js';
|
|
|
6
6
|
import { nativeChecks } from './native.js';
|
|
7
7
|
import { stabilityChecks } from './stability.js';
|
|
8
8
|
import { performanceChecks } from './performance.js';
|
|
9
|
-
import { vulnerableDependencies, passwordLeaks, webViewRisks, androidBackup, exportedComponents, plainHttpCalls, cloudRules, insecureTls, weakCrypto, tokenStorage, reverseEngineering, expoConfigSecrets, masvsOf, MASVS_GROUPS } from './security.js';
|
|
9
|
+
import { vulnerableDependencies, passwordLeaks, webViewRisks, androidBackup, exportedComponents, plainHttpCalls, cloudRules, insecureTls, weakCrypto, tokenStorage, reverseEngineering, expoConfigSecrets, deepLinks, masvsOf, MASVS_GROUPS } from './security.js';
|
|
10
10
|
import { lockedVersions } from './lockfile.js';
|
|
11
11
|
import { findUnused, filesImportingWith } from './usage.js';
|
|
12
12
|
import { matchKnownIssues, compareVersions } from './known-issues.js';
|
|
@@ -408,7 +408,7 @@ export async function analyze(project, { get, now = new Date(), offline: forcedO
|
|
|
408
408
|
for (const f of performanceChecks(project)) add(f);
|
|
409
409
|
|
|
410
410
|
// Security beyond leaked keys.
|
|
411
|
-
for (const f of [...passwordLeaks(project.root), ...webViewRisks(project.root), ...androidBackup(project.root), ...exportedComponents(project.root), ...plainHttpCalls(project.root), ...cloudRules(project.root, project.deps, now), ...insecureTls(project.root), ...weakCrypto(project.root), ...tokenStorage(project.root), ...reverseEngineering(project.root, project), ...expoConfigSecrets(project.root)]) add(f);
|
|
411
|
+
for (const f of [...passwordLeaks(project.root), ...webViewRisks(project.root), ...androidBackup(project.root), ...exportedComponents(project.root), ...plainHttpCalls(project.root), ...cloudRules(project.root, project.deps, now), ...insecureTls(project.root), ...weakCrypto(project.root), ...tokenStorage(project.root), ...reverseEngineering(project.root, project), ...expoConfigSecrets(project.root), ...deepLinks(project.root, project.deps)]) add(f);
|
|
412
412
|
if (!forcedOffline) {
|
|
413
413
|
// Exact versions only (installed, else the lockfile): a range would be a guess.
|
|
414
414
|
const locked = lockedVersions(project.root, project.deps);
|
package/src/native.js
CHANGED
|
@@ -200,7 +200,8 @@ export function nativeChecks(project, { rnLatest = null, now = new Date() } = {}
|
|
|
200
200
|
patched.push({ file: f, pkg, version });
|
|
201
201
|
const text = read(path.join(patchDir, f)) || '';
|
|
202
202
|
const buildPaths = (text.match(/^diff --git a\/node_modules\/\S+?\/(?:android|ios)\/(?:build|\.cxx|\.gradle)\//gm) || []).length;
|
|
203
|
-
|
|
203
|
+
// Finder/Explorer junk (.DS_Store, Thumbs.db) caught in a patch is harmless noise.
|
|
204
|
+
const binary = text.split(/^diff --git /m).some((part) => /^GIT binary patch|^Binary files /m.test(part) && !/^\S*?(?:\.DS_Store|Thumbs\.db)\b/.test(part));
|
|
204
205
|
if (buildPaths || binary) {
|
|
205
206
|
add({
|
|
206
207
|
id: `patch-artifacts:${f}`,
|
|
@@ -400,7 +401,7 @@ export function nativeChecks(project, { rnLatest = null, now = new Date() } = {}
|
|
|
400
401
|
return false;
|
|
401
402
|
}
|
|
402
403
|
};
|
|
403
|
-
const signing = tracked.filter((f) => /\.(jks|keystore)$/i.test(f) && !/debug/i.test(path.basename(f)) && nonEmpty(f));
|
|
404
|
+
const signing = tracked.filter((f) => /\.(jks|keystore)$/i.test(f) && !/debug|fake|dummy/i.test(path.basename(f)) && !/(?:^|\/)(?:__tests__|tests?|e2e|fixtures?)\//.test(f) && nonEmpty(f));
|
|
404
405
|
for (const f of signing) {
|
|
405
406
|
add({
|
|
406
407
|
id: `signing-keystore:${f}`,
|
package/src/plan.js
CHANGED
|
@@ -586,7 +586,7 @@ export function buildPlan(result) {
|
|
|
586
586
|
export function planToMarkdown(result, plan) {
|
|
587
587
|
const p = result.project;
|
|
588
588
|
const lines = [
|
|
589
|
-
`# Upgrade plan: ${p.name || 'your app'}`,
|
|
589
|
+
`# ${plan.phases.some((ph) => /^Upgrade (React Native|Expo SDK)/.test(ph.title)) ? 'Upgrade plan' : 'Action plan'}: ${p.name || 'your app'}`,
|
|
590
590
|
'',
|
|
591
591
|
`Generated by NativeKeel on ${result.scannedAt.slice(0, 10)}. `,
|
|
592
592
|
`React Native ${p.reactNative || '-'}${p.expo ? ` · Expo ${p.expo}` : ''} → latest ${result.latest.reactNative || '-'}. `,
|
package/src/project.js
CHANGED
|
@@ -126,6 +126,10 @@ export function loadProject(root) {
|
|
|
126
126
|
const devDeps = resolveCatalogRefs({ ...(pkg.devDependencies || {}) }, catalogs);
|
|
127
127
|
const declared = (name) => deps[name] || devDeps[name];
|
|
128
128
|
if (!declared('react-native') && !declared('expo')) {
|
|
129
|
+
const apps = findAppFolders(root);
|
|
130
|
+
if (apps.length) {
|
|
131
|
+
throw new Error(`This folder is not a React Native app, but it contains ${apps.length === 1 ? 'one' : apps.length}:\n${apps.slice(0, 8).map((a) => ` npx nativekeel ${a}`).join('\n')}${apps.length > 8 ? '\n …' : ''}`);
|
|
132
|
+
}
|
|
129
133
|
throw new Error('This does not look like a React Native app (no react-native or expo dependency). Run it inside your app folder.');
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -193,3 +197,31 @@ function detectAndroid(root) {
|
|
|
193
197
|
};
|
|
194
198
|
return { targetSdk: num('targetSdk'), compileSdk: num('compileSdk'), minSdk: num('minSdk') };
|
|
195
199
|
}
|
|
200
|
+
|
|
201
|
+
// React Native / Expo app folders below `root` (monorepos: apps/mobile, packages/app, …), as
|
|
202
|
+
// relative paths. Libraries (react-native as a peer) are left out.
|
|
203
|
+
export function findAppFolders(root, maxDepth = 3) {
|
|
204
|
+
const out = [];
|
|
205
|
+
const skip = new Set(['node_modules', '.git', 'Pods', 'build', 'dist', '.expo', 'android', 'ios', 'vendor', 'example', 'examples', 'docs', 'website', 'e2e', 'test', 'tests']);
|
|
206
|
+
const visit = (dir, depth) => {
|
|
207
|
+
if (depth > maxDepth) return;
|
|
208
|
+
let entries = [];
|
|
209
|
+
try {
|
|
210
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
211
|
+
} catch {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
for (const e of entries) {
|
|
215
|
+
if (!e.isDirectory() || skip.has(e.name) || e.name.startsWith('.')) continue;
|
|
216
|
+
const sub = path.join(dir, e.name);
|
|
217
|
+
const pkg = readJson(path.join(sub, 'package.json'));
|
|
218
|
+
const deps = pkg ? { ...pkg.dependencies, ...pkg.devDependencies } : {};
|
|
219
|
+
const isApp = pkg && (deps['react-native'] || deps.expo) && !(pkg.peerDependencies && pkg.peerDependencies['react-native']) &&
|
|
220
|
+
['android', 'ios', 'app.json', 'app.config.js', 'app.config.ts'].some((f) => fs.existsSync(path.join(sub, f)));
|
|
221
|
+
if (isApp) out.push(path.relative(root, sub));
|
|
222
|
+
else visit(sub, depth + 1);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
visit(root, 1);
|
|
226
|
+
return out.sort();
|
|
227
|
+
}
|
package/src/report-html.js
CHANGED
|
@@ -32,7 +32,7 @@ export function htmlReport(result, { brand = null, plan = null } = {}) {
|
|
|
32
32
|
: '';
|
|
33
33
|
|
|
34
34
|
const planHtml = plan
|
|
35
|
-
? `<section><h2
|
|
35
|
+
? `<section><h2>${plan.phases.some((ph) => /^Upgrade (React Native|Expo SDK)/.test(ph.title)) ? 'Upgrade plan' : 'Action plan'} <small>scope: ${esc(plan.complexity.size)}</small></h2>${plan.phases
|
|
36
36
|
.map((ph, i) => `<h3>${i + 1}. ${esc(ph.title)}</h3><p class="why">${esc(ph.why)}</p><ul>${ph.steps.map((s) => `<li>${rich(s)}</li>`).join('')}</ul>`)
|
|
37
37
|
.join('')}</section>`
|
|
38
38
|
: '';
|
|
@@ -60,6 +60,7 @@ h1{font-size:26px;margin:0 0 4px}h2{font-size:19px;margin:32px 0 12px}h2 small{f
|
|
|
60
60
|
.stat.critical b{color:var(--critical)}.stat.high b{color:var(--high)}
|
|
61
61
|
.facts{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:12px 16px;margin-top:12px;display:flex;flex-wrap:wrap;gap:6px 24px;font-size:14px}
|
|
62
62
|
ul.list{list-style:none;padding:0;margin:0;display:grid;gap:8px}
|
|
63
|
+
main{overflow-wrap:anywhere}code{overflow-wrap:anywhere;word-break:break-word}.f>div,.sg,.stats>*{min-width:0}.facts{display:flex;flex-wrap:wrap;gap:6px 16px}
|
|
63
64
|
.start{background:var(--card);border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:8px;padding:6px 18px 10px;margin-top:20px}.start h2{margin:10px 0 6px}.start li{margin:6px 0}
|
|
64
65
|
.secgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.sg{background:var(--card);border:1px solid var(--line);border-radius:8px;padding:10px 12px;display:flex;flex-direction:column}.sg b{font-size:20px}.sg.ok b{color:var(--accent)}.sg.bad b{color:var(--critical)}.sg small{color:var(--muted)}@media (max-width:560px){.secgrid{grid-template-columns:1fr 1fr}}
|
|
65
66
|
details.bumps{margin-top:8px;background:var(--card);border:1px solid var(--line);border-left:4px solid var(--low);border-radius:8px;padding:10px 14px}details.bumps summary{cursor:pointer;font-weight:600}details.bumps table{width:100%;border-collapse:collapse;margin-top:10px;font-size:14px}details.bumps th,details.bumps td{text-align:left;padding:4px 8px;border-top:1px solid var(--line)}.muted{color:var(--muted);font-weight:400}
|
package/src/security.js
CHANGED
|
@@ -591,7 +591,7 @@ export function masvsOf(id) {
|
|
|
591
591
|
if (/^(secret:|env-bundled|crypto-|expo-secret)/.test(id)) return 'CRYPTO';
|
|
592
592
|
if (/^(password-leak|token-unencrypted|android-allow-backup)/.test(id)) return 'STORAGE';
|
|
593
593
|
if (/^(insecure-tls|user-certificates|plain-http|ios-ats|android-cleartext)/.test(id)) return 'NETWORK';
|
|
594
|
-
if (/^(webview-|android-exported)/.test(id)) return 'PLATFORM';
|
|
594
|
+
if (/^(webview-|android-exported|deeplink-)/.test(id)) return 'PLATFORM';
|
|
595
595
|
if (/^firebase-/.test(id)) return 'AUTH';
|
|
596
596
|
if (/^(vuln:|signing-|android-debuggable)/.test(id)) return 'CODE';
|
|
597
597
|
if (/^(sourcemap-in-app|easy-reverse-engineering)/.test(id)) return 'RESILIENCE';
|
|
@@ -711,3 +711,94 @@ export function expoConfigSecrets(root) {
|
|
|
711
711
|
}
|
|
712
712
|
return findings;
|
|
713
713
|
}
|
|
714
|
+
|
|
715
|
+
// Deep links (MASVS-PLATFORM). A web link (https://your.domain/...) opens the app only when the
|
|
716
|
+
// domain is verified (autoVerify + assetlinks.json); without it Android 12+ opens the browser,
|
|
717
|
+
// and older Android lets any app that registers the same link receive it. Custom URL schemes can
|
|
718
|
+
// be registered by any app, so the template scheme "myapp" is shared with every other app that
|
|
719
|
+
// kept it, and an OAuth redirect to it can land in the wrong app.
|
|
720
|
+
const TEMPLATE_SCHEMES = new Set(['myapp', 'my-app', 'myscheme', 'your-app-scheme', 'yourappscheme']);
|
|
721
|
+
const SENSITIVE_LINK = /auth|login|signin|sign-in|reset|verify|magic|invite|oauth|callback|token/i;
|
|
722
|
+
const OAUTH_DEPS = ['expo-auth-session', '@clerk/clerk-expo', 'react-native-app-auth', '@react-native-community/oauth', 'react-native-auth0'];
|
|
723
|
+
|
|
724
|
+
export function deepLinks(root, deps = {}) {
|
|
725
|
+
const findings = [];
|
|
726
|
+
const unverified = new Map(); // host -> sensitive?
|
|
727
|
+
const schemes = new Set();
|
|
728
|
+
const realHost = (h) => h && !/[*$@{]/.test(h) && h.includes('.') && !/^(?:localhost|127\.|10\.|192\.168\.)/.test(h);
|
|
729
|
+
|
|
730
|
+
// autoVerify on any one filter makes Android verify every web host in the manifest.
|
|
731
|
+
const manifest = read(path.join(root, 'android', 'app', 'src', 'main', 'AndroidManifest.xml')) || '';
|
|
732
|
+
const anyVerified = /<intent-filter\b[^>]*android:autoVerify\s*=\s*"true"/.test(manifest);
|
|
733
|
+
for (const m of manifest.matchAll(/<intent-filter\b([^>]*)>([\s\S]*?)<\/intent-filter>/g)) {
|
|
734
|
+
const body = m[2];
|
|
735
|
+
if (!/android\.intent\.category\.BROWSABLE/.test(body)) continue;
|
|
736
|
+
const found = [...body.matchAll(/android:scheme\s*=\s*"([^"]+)"/g)].map((x) => x[1]);
|
|
737
|
+
for (const s of found) if (!/^https?$/.test(s)) schemes.add(s.toLowerCase());
|
|
738
|
+
if (anyVerified || !found.some((s) => /^https?$/.test(s))) continue;
|
|
739
|
+
const paths = [...body.matchAll(/android:path(?:Prefix|Pattern)?\s*=\s*"([^"]+)"/g)].map((x) => x[1]).join(' ');
|
|
740
|
+
for (const h of body.matchAll(/android:host\s*=\s*"([^"]+)"/g)) {
|
|
741
|
+
if (realHost(h[1])) unverified.set(h[1], unverified.get(h[1]) || SENSITIVE_LINK.test(`${h[1]} ${paths}`));
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
let app = null;
|
|
746
|
+
try {
|
|
747
|
+
app = JSON.parse(read(path.join(root, 'app.json')) || 'null');
|
|
748
|
+
} catch {
|
|
749
|
+
// not JSON
|
|
750
|
+
}
|
|
751
|
+
const expo = (app && (app.expo || app)) || {};
|
|
752
|
+
for (const s of [].concat(expo.scheme || [])) if (typeof s === 'string') schemes.add(s.toLowerCase());
|
|
753
|
+
for (const f of ['app.config.js', 'app.config.ts']) {
|
|
754
|
+
const text = read(path.join(root, f)) || '';
|
|
755
|
+
for (const m of text.matchAll(/\bscheme\s*:\s*['"`]([\w.+-]+)['"`]/g)) schemes.add(m[1].toLowerCase());
|
|
756
|
+
}
|
|
757
|
+
const expoFilters = (expo.android && expo.android.intentFilters) || [];
|
|
758
|
+
for (const filter of expoFilters.some((f) => f && f.autoVerify) ? [] : expoFilters) {
|
|
759
|
+
if (!filter || ![].concat(filter.category || []).includes('BROWSABLE')) continue;
|
|
760
|
+
for (const d of [].concat(filter.data || [])) {
|
|
761
|
+
if (d && /^https?$/.test(d.scheme || '') && realHost(d.host)) {
|
|
762
|
+
unverified.set(d.host, unverified.get(d.host) || SENSITIVE_LINK.test(`${d.host} ${d.pathPrefix || ''} ${d.path || ''} ${d.pathPattern || ''}`));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
let iosDirs = [];
|
|
767
|
+
try {
|
|
768
|
+
iosDirs = fs.readdirSync(path.join(root, 'ios'), { withFileTypes: true }).filter((e) => e.isDirectory() && !/^(?:Pods|build)$|Tests$|\.xc/.test(e.name));
|
|
769
|
+
} catch {
|
|
770
|
+
// no ios folder
|
|
771
|
+
}
|
|
772
|
+
for (const d of iosDirs) {
|
|
773
|
+
const plist = read(path.join(root, 'ios', d.name, 'Info.plist')) || '';
|
|
774
|
+
for (const block of plist.match(/<key>CFBundleURLSchemes<\/key>\s*<array>[\s\S]*?<\/array>/g) || []) {
|
|
775
|
+
for (const s of block.matchAll(/<string>([^<$]+)<\/string>/g)) schemes.add(s[1].toLowerCase());
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
if (unverified.size) {
|
|
780
|
+
const hosts = [...unverified.keys()];
|
|
781
|
+
const sensitive = hosts.filter((h) => unverified.get(h));
|
|
782
|
+
findings.push({
|
|
783
|
+
id: 'deeplink-unverified',
|
|
784
|
+
severity: sensitive.length ? 'medium' : 'low',
|
|
785
|
+
area: 'security',
|
|
786
|
+
title: `Web links to ${hosts.slice(0, 2).join(', ')}${hosts.length > 2 ? ` and ${hosts.length - 2} more` : ''} are not verified (no autoVerify)`,
|
|
787
|
+
detail: `On Android 12+ these links open in the browser instead of the app, and on older Android any installed app that registers the same links can receive them${sensitive.length ? ', including the login/reset/invite links that carry tokens' : ''}. For domains you own, add android:autoVerify="true" to the intent filter and publish /.well-known/assetlinks.json with your signing certificate. (OWASP MASVS-PLATFORM)`,
|
|
788
|
+
fix: { kind: 'security', step: `Add \`android:autoVerify="true"\` to the https intent filters for ${hosts.slice(0, 3).map((h) => `\`${h}\``).join(', ')} and serve \`https://${hosts[0]}/.well-known/assetlinks.json\`.` },
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
const template = [...schemes].filter((s) => TEMPLATE_SCHEMES.has(s));
|
|
792
|
+
if (template.length) {
|
|
793
|
+
const oauth = OAUTH_DEPS.filter((d) => deps[d]);
|
|
794
|
+
findings.push({
|
|
795
|
+
id: 'deeplink-template-scheme',
|
|
796
|
+
severity: oauth.length ? 'medium' : 'low',
|
|
797
|
+
area: 'security',
|
|
798
|
+
title: `The app still uses the template URL scheme "${template[0]}://"`,
|
|
799
|
+
detail: `Many other apps kept the same scheme, so ${template[0]}:// links can open a different app${oauth.length ? `, and the sign-in redirect of ${oauth.join(', ')} can be delivered to it` : ''}. Pick a scheme unique to your app (for example your bundle identifier). (OWASP MASVS-PLATFORM)`,
|
|
800
|
+
fix: { kind: 'security', step: `Replace the "${template[0]}" scheme with one unique to the app (app.json \`scheme\`, AndroidManifest and Info.plist), and update redirect URIs registered with your sign-in providers.` },
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
return findings;
|
|
804
|
+
}
|