mcp-maestro-mobile-ai 1.1.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.
@@ -0,0 +1,573 @@
1
+ # Security Model
2
+
3
+ > **Maestro MCP Server** - Security Documentation
4
+
5
+ This document describes the security architecture, execution boundaries, threat model, and security best practices for Maestro MCP.
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [Security Philosophy](#security-philosophy)
12
+ 2. [Trust Model](#trust-model)
13
+ 3. [Execution Boundaries](#execution-boundaries)
14
+ 4. [Safe Mode](#safe-mode)
15
+ 5. [Input Validation](#input-validation)
16
+ 6. [Data Security](#data-security)
17
+ 7. [Threat Model](#threat-model)
18
+ 8. [Security Best Practices](#security-best-practices)
19
+ 9. [Incident Response](#incident-response)
20
+ 10. [Security Checklist](#security-checklist)
21
+
22
+ ---
23
+
24
+ ## Security Philosophy
25
+
26
+ ### Core Principles
27
+
28
+ 1. **Local-First**: All execution happens on the local machine
29
+ 2. **Least Privilege**: Minimum permissions required for operation
30
+ 3. **Defense in Depth**: Multiple layers of validation
31
+ 4. **Fail Secure**: On error, fail to a safe state
32
+ 5. **Transparency**: Clear documentation of all capabilities
33
+
34
+ ### Security Boundaries
35
+
36
+ ```
37
+ ┌─────────────────────────────────────────────────────────────┐
38
+ │ TRUSTED ZONE │
39
+ │ ┌─────────────────────────────────────────────────────┐ │
40
+ │ │ Local Machine │ │
41
+ │ │ ┌───────────────┐ ┌───────────────┐ │ │
42
+ │ │ │ MCP Server │ │ Maestro │ │ │
43
+ │ │ │ (Node.js) │◄─┤ CLI │ │ │
44
+ │ │ └───────────────┘ └───────────────┘ │ │
45
+ │ │ │ │ │ │
46
+ │ │ ▼ ▼ │ │
47
+ │ │ ┌───────────────────────────────────────────┐ │ │
48
+ │ │ │ Android Device / Emulator │ │ │
49
+ │ │ │ (via ADB - local connection) │ │ │
50
+ │ │ └───────────────────────────────────────────┘ │ │
51
+ │ └─────────────────────────────────────────────────────┘ │
52
+ └─────────────────────────────────────────────────────────────┘
53
+
54
+ │ ❌ NO EXTERNAL CONNECTIONS
55
+
56
+ ┌─────────────────────────────────────────────────────────────┐
57
+ │ UNTRUSTED ZONE │
58
+ │ │
59
+ │ • No cloud services │
60
+ │ • No external APIs │
61
+ │ • No telemetry endpoints │
62
+ │ • No remote storage │
63
+ │ │
64
+ └─────────────────────────────────────────────────────────────┘
65
+ ```
66
+
67
+ ---
68
+
69
+ ## Trust Model
70
+
71
+ ### Trust Hierarchy
72
+
73
+ | Entity | Trust Level | Validation |
74
+ |--------|-------------|------------|
75
+ | User | Fully Trusted | N/A (local) |
76
+ | AI Client | Trusted with Validation | YAML validation |
77
+ | MCP Server | Trusted | Process isolation |
78
+ | Maestro CLI | Trusted | Command allowlist |
79
+ | ADB | Restricted | Safe Mode enforcement |
80
+ | Device | Sandboxed | App-level isolation |
81
+
82
+ ### AI Client Trust
83
+
84
+ The AI client (Claude, Copilot) generates Maestro YAML that is:
85
+
86
+ 1. **Validated** before execution
87
+ 2. **Restricted** to allowed commands
88
+ 3. **Logged** for audit purposes
89
+ 4. **Rejectable** if suspicious
90
+
91
+ ```
92
+ AI Client → Generated YAML → [VALIDATION GATE] → Execution
93
+
94
+ └── Reject if:
95
+ • Invalid syntax
96
+ • Blocked commands
97
+ • Suspicious patterns
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Execution Boundaries
103
+
104
+ ### Allowed Operations
105
+
106
+ #### Maestro Commands
107
+
108
+ | Command | Status | Purpose |
109
+ |---------|--------|---------|
110
+ | `maestro test <file>` | ✅ Allowed | Run test flow |
111
+ | `maestro validate <file>` | ✅ Allowed | Validate YAML |
112
+ | `maestro screenshot <path>` | ✅ Allowed | Capture screen |
113
+ | `maestro --version` | ✅ Allowed | Version check |
114
+
115
+ #### ADB Commands
116
+
117
+ | Command | Safe Mode | Full Mode | Purpose |
118
+ |---------|-----------|-----------|---------|
119
+ | `adb devices` | ✅ | ✅ | List devices |
120
+ | `adb -s <id> shell pm list packages` | ✅ | ✅ | Check app |
121
+ | `adb -s <id> shell input tap` | ✅ | ✅ | UI interaction |
122
+ | `adb -s <id> shell input text` | ✅ | ✅ | Text input |
123
+ | `adb install` | ❌ | ✅ | Install APK |
124
+ | `adb uninstall` | ❌ | ✅ | Remove app |
125
+ | `adb shell rm` | ❌ | ❌ | **BLOCKED** |
126
+ | `adb shell settings` | ❌ | ❌ | **BLOCKED** |
127
+ | `adb shell am start -a android.intent.action.DELETE` | ❌ | ❌ | **BLOCKED** |
128
+
129
+ ### Blocked Operations
130
+
131
+ The following are **always blocked** regardless of mode:
132
+
133
+ ```
134
+ ❌ BLOCKED OPERATIONS
135
+ ├── File system modifications (rm, mv, cp)
136
+ ├── System settings changes
137
+ ├── Package management (install/uninstall in Safe Mode)
138
+ ├── Device wipe / factory reset
139
+ ├── Root / superuser commands
140
+ ├── Network configuration changes
141
+ ├── Arbitrary shell commands
142
+ └── Binary execution
143
+ ```
144
+
145
+ ### File System Access
146
+
147
+ | Path | Access | Purpose |
148
+ |------|--------|---------|
149
+ | `output/` | Read/Write | Test results, screenshots |
150
+ | `.temp/` | Read/Write | Temporary YAML files |
151
+ | `prompts/` | Read | Prompt files |
152
+ | Project root | Read | Configuration files |
153
+ | System paths | ❌ Denied | Security |
154
+
155
+ ---
156
+
157
+ ## Safe Mode
158
+
159
+ ### Overview
160
+
161
+ Safe Mode is a security feature that restricts operations to read-only and non-destructive actions.
162
+
163
+ ```
164
+ SAFE_MODE=true (DEFAULT - Recommended)
165
+ SAFE_MODE=false (Full access - Use with caution)
166
+ ```
167
+
168
+ ### Safe Mode Restrictions
169
+
170
+ | Category | Safe Mode ON | Safe Mode OFF |
171
+ |----------|--------------|---------------|
172
+ | Run tests | ✅ | ✅ |
173
+ | Take screenshots | ✅ | ✅ |
174
+ | List devices | ✅ | ✅ |
175
+ | Check app installed | ✅ | ✅ |
176
+ | Install APK | ❌ | ✅ |
177
+ | Uninstall app | ❌ | ✅ |
178
+ | Clear app data | ❌ | ✅ |
179
+ | Device settings | ❌ | ❌ |
180
+
181
+ ### Enabling Safe Mode
182
+
183
+ ```bash
184
+ # Environment variable
185
+ SAFE_MODE=true
186
+
187
+ # In .env file
188
+ SAFE_MODE=true
189
+
190
+ # In MCP config
191
+ {
192
+ "env": {
193
+ "SAFE_MODE": "true"
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### Safe Mode Enforcement
199
+
200
+ ```javascript
201
+ // Pseudocode for Safe Mode enforcement
202
+ function executeAdbCommand(command) {
203
+ if (SAFE_MODE) {
204
+ if (isDestructiveCommand(command)) {
205
+ throw new SecurityError(
206
+ "Operation blocked in Safe Mode",
207
+ "SAFE_MODE_VIOLATION"
208
+ );
209
+ }
210
+ }
211
+
212
+ if (isAlwaysBlocked(command)) {
213
+ throw new SecurityError(
214
+ "Operation not allowed",
215
+ "BLOCKED_OPERATION"
216
+ );
217
+ }
218
+
219
+ return execute(command);
220
+ }
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Input Validation
226
+
227
+ ### YAML Validation
228
+
229
+ All AI-generated YAML is validated before execution:
230
+
231
+ ```yaml
232
+ # Validation checks:
233
+ ✅ Valid YAML syntax
234
+ ✅ Required fields present (appId)
235
+ ✅ Known Maestro commands only
236
+ ✅ No shell escape attempts
237
+ ✅ No path traversal attempts
238
+ ```
239
+
240
+ ### Validation Layers
241
+
242
+ ```
243
+ Layer 1: Syntax Validation
244
+
245
+
246
+ Layer 2: Schema Validation
247
+
248
+
249
+ Layer 3: Command Allowlist
250
+
251
+
252
+ Layer 4: Pattern Detection
253
+
254
+
255
+ Layer 5: Safe Mode Check
256
+
257
+
258
+ ✅ Execute
259
+ ```
260
+
261
+ ### Blocked Patterns
262
+
263
+ | Pattern | Reason | Example |
264
+ |---------|--------|---------|
265
+ | Shell injection | Command execution | `; rm -rf /` |
266
+ | Path traversal | File access | `../../../etc/passwd` |
267
+ | Environment expansion | Info disclosure | `$HOME`, `${PATH}` |
268
+ | Command substitution | Execution | `` `command` ``, `$(command)` |
269
+
270
+ ### Input Sanitization
271
+
272
+ ```javascript
273
+ // All user inputs are sanitized
274
+ function sanitizeInput(input) {
275
+ // Remove null bytes
276
+ input = input.replace(/\0/g, '');
277
+
278
+ // Escape shell metacharacters
279
+ input = escapeShellArg(input);
280
+
281
+ // Validate against allowlist
282
+ if (!isAllowed(input)) {
283
+ throw new ValidationError("Input not allowed");
284
+ }
285
+
286
+ return input;
287
+ }
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Data Security
293
+
294
+ ### Data Classification
295
+
296
+ | Data Type | Classification | Handling |
297
+ |-----------|---------------|----------|
298
+ | Prompt files | Internal | User-controlled |
299
+ | Generated YAML | Internal | Temporary, deleted |
300
+ | Test results | Internal | Local storage |
301
+ | Screenshots | Potentially Sensitive | Local storage |
302
+ | Logs | Internal | Local storage |
303
+
304
+ ### Sensitive Data Handling
305
+
306
+ #### Screenshots
307
+
308
+ Screenshots may contain sensitive information:
309
+
310
+ ```
311
+ ⚠️ WARNING: Screenshots may capture:
312
+ • Personal data on screen
313
+ • Authentication credentials (if visible)
314
+ • Financial information
315
+ • Health information
316
+ • Business confidential data
317
+
318
+ RECOMMENDATION:
319
+ • Review screenshot contents before sharing
320
+ • Implement screenshot cleanup policy
321
+ • Use dedicated test accounts
322
+ • Mask sensitive data in test apps
323
+ ```
324
+
325
+ #### Test Results
326
+
327
+ ```json
328
+ {
329
+ "runId": "run-123-1704067200000",
330
+ "timestamp": "2025-01-01T00:00:00.000Z",
331
+ "tests": [{
332
+ "name": "Login test",
333
+ "success": true,
334
+ "duration": "3.2s"
335
+ // No credentials stored
336
+ // No PII stored
337
+ }]
338
+ }
339
+ ```
340
+
341
+ ### Data Retention
342
+
343
+ | Data Type | Default Retention | Configurable |
344
+ |-----------|------------------|--------------|
345
+ | Results | Last 50 runs | `MAX_RESULTS` |
346
+ | Screenshots | Same as results | Linked |
347
+ | Logs | Manual cleanup | No |
348
+ | Temp files | Immediate delete | No |
349
+
350
+ ### Data Deletion
351
+
352
+ ```bash
353
+ # Manual cleanup via MCP tool
354
+ cleanup_results --keepLast 10 --deleteScreenshots true
355
+
356
+ # Or via file system
357
+ rm -rf output/results/*
358
+ rm -rf output/screenshots/*
359
+ ```
360
+
361
+ ---
362
+
363
+ ## Threat Model
364
+
365
+ ### Threat Actors
366
+
367
+ | Actor | Motivation | Capability |
368
+ |-------|------------|------------|
369
+ | Malicious AI Output | Unintended | Limited by validation |
370
+ | Compromised Dependency | Supply chain | Package integrity |
371
+ | Local Attacker | Various | Full local access |
372
+ | Network Attacker | Remote access | None (no network) |
373
+
374
+ ### Attack Vectors
375
+
376
+ #### 1. Malicious YAML Injection
377
+
378
+ **Threat**: AI generates malicious YAML that escapes sandbox
379
+
380
+ **Mitigations**:
381
+ - ✅ YAML syntax validation
382
+ - ✅ Command allowlist
383
+ - ✅ Pattern detection
384
+ - ✅ Safe Mode restrictions
385
+
386
+ **Risk Level**: Low (multiple validation layers)
387
+
388
+ #### 2. Dependency Compromise
389
+
390
+ **Threat**: Malicious code in npm dependencies
391
+
392
+ **Mitigations**:
393
+ - ✅ Minimal dependencies (5 direct)
394
+ - ✅ Well-known, audited packages
395
+ - ✅ Lock file for version pinning
396
+ - ⚠️ Regular dependency updates
397
+
398
+ **Risk Level**: Low-Medium (standard npm risk)
399
+
400
+ #### 3. Path Traversal
401
+
402
+ **Threat**: Access files outside allowed directories
403
+
404
+ **Mitigations**:
405
+ - ✅ Path validation
406
+ - ✅ Restricted to output/ directory
407
+ - ✅ No user-controlled paths in execution
408
+
409
+ **Risk Level**: Low
410
+
411
+ #### 4. Command Injection
412
+
413
+ **Threat**: Execute arbitrary commands via input
414
+
415
+ **Mitigations**:
416
+ - ✅ No shell interpolation
417
+ - ✅ Parameterized command execution
418
+ - ✅ Input sanitization
419
+
420
+ **Risk Level**: Low
421
+
422
+ ### Security Assumptions
423
+
424
+ 1. **Local execution is trusted** - User has full machine access
425
+ 2. **AI client is semi-trusted** - Output is validated
426
+ 3. **No network threats** - No external connections
427
+ 4. **Device isolation** - Android sandbox is intact
428
+
429
+ ---
430
+
431
+ ## Security Best Practices
432
+
433
+ ### For Users
434
+
435
+ ```
436
+ ✅ DO:
437
+ • Keep Safe Mode enabled (default)
438
+ • Use dedicated test devices/emulators
439
+ • Use test accounts with fake data
440
+ • Review generated YAML before execution
441
+ • Regularly clean up screenshots
442
+ • Keep dependencies updated
443
+
444
+ ❌ DON'T:
445
+ • Disable Safe Mode without understanding risks
446
+ • Use production devices for testing
447
+ • Test with real user credentials
448
+ • Store screenshots in version control
449
+ • Ignore security warnings
450
+ ```
451
+
452
+ ### For CI/CD
453
+
454
+ ```yaml
455
+ # Recommended CI configuration
456
+ jobs:
457
+ test:
458
+ runs-on: ubuntu-latest
459
+ env:
460
+ SAFE_MODE: "true"
461
+ MAX_RESULTS: "10"
462
+ steps:
463
+ - name: Run tests
464
+ run: maestro-mcp run --ci --prompt-file tests.txt
465
+
466
+ - name: Cleanup
467
+ if: always()
468
+ run: |
469
+ rm -rf output/screenshots/*
470
+ rm -rf output/results/*
471
+ ```
472
+
473
+ ### For Enterprise
474
+
475
+ | Practice | Recommendation |
476
+ |----------|---------------|
477
+ | Network isolation | Run in isolated network segment |
478
+ | Device management | Use dedicated test device pool |
479
+ | Credential management | Use test accounts only |
480
+ | Audit logging | Enable verbose logging |
481
+ | Access control | Restrict who can run tests |
482
+ | Review process | Review AI-generated tests |
483
+
484
+ ---
485
+
486
+ ## Incident Response
487
+
488
+ ### Security Issues
489
+
490
+ If you discover a security vulnerability:
491
+
492
+ 1. **DO NOT** open a public GitHub issue
493
+ 2. **Email**: security@example.com (or create private issue)
494
+ 3. **Include**: Description, reproduction steps, impact
495
+ 4. **Wait**: For acknowledgment before disclosure
496
+
497
+ ### Response Timeline
498
+
499
+ | Phase | Timeframe |
500
+ |-------|-----------|
501
+ | Acknowledgment | 24-48 hours |
502
+ | Initial assessment | 72 hours |
503
+ | Fix development | 1-2 weeks |
504
+ | Public disclosure | After fix release |
505
+
506
+ ### Severity Levels
507
+
508
+ | Level | Description | Response |
509
+ |-------|-------------|----------|
510
+ | Critical | Remote code execution | Immediate patch |
511
+ | High | Local privilege escalation | 48-hour patch |
512
+ | Medium | Information disclosure | Next release |
513
+ | Low | Minor issues | Scheduled fix |
514
+
515
+ ---
516
+
517
+ ## Security Checklist
518
+
519
+ ### Pre-Deployment
520
+
521
+ ```
522
+ □ Safe Mode enabled
523
+ □ APP_ID configured correctly
524
+ □ ANDROID_HOME set (not relying on PATH)
525
+ □ Test device is dedicated/isolated
526
+ □ No production credentials in test data
527
+ □ Screenshot directory is not synced
528
+ □ Log level appropriate for environment
529
+ ```
530
+
531
+ ### Ongoing
532
+
533
+ ```
534
+ □ Dependencies updated monthly
535
+ □ Security advisories monitored
536
+ □ Screenshot cleanup scheduled
537
+ □ Result retention policy enforced
538
+ □ Access logs reviewed
539
+ □ Test accounts rotated
540
+ ```
541
+
542
+ ### Audit
543
+
544
+ ```
545
+ □ All test runs have audit trail
546
+ □ YAML content preserved for review
547
+ □ Device IDs logged
548
+ □ Timestamps accurate
549
+ □ No sensitive data in logs
550
+ ```
551
+
552
+ ---
553
+
554
+ ## Version History
555
+
556
+ | Version | Date | Changes |
557
+ |---------|------|---------|
558
+ | 1.0.0 | Jan 2025 | Initial security documentation |
559
+
560
+ ---
561
+
562
+ ## Contact
563
+
564
+ For security inquiries:
565
+
566
+ - **Security Issues**: security@example.com
567
+ - **General Questions**: [GitHub Issues](https://github.com/krunal-mahera/mcp-maestro-mobile-ai/issues)
568
+
569
+ ---
570
+
571
+ *This document is part of the Maestro MCP security program.*
572
+ *Last Updated: January 2025*
573
+
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "mcp-maestro-mobile-ai",
3
+ "version": "1.1.0",
4
+ "private": false,
5
+ "description": "MCP Server for AI-Assisted Mobile Automation using Maestro - Run mobile tests with natural language prompts",
6
+ "main": "src/mcp-server/index.js",
7
+ "type": "module",
8
+ "bin": {
9
+ "maestro-mcp": "./src/mcp-server/index.js"
10
+ },
11
+ "files": [
12
+ "src/",
13
+ "prompts/",
14
+ "templates/",
15
+ "docs/",
16
+ "README.md",
17
+ "LICENSE",
18
+ "CHANGELOG.md",
19
+ "ROADMAP.md",
20
+ "CONTRIBUTING.md"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/krunal-mahera/mcp-maestro-mobile-ai.git"
25
+ },
26
+ "homepage": "https://github.com/krunal-mahera/mcp-maestro-mobile-ai#readme",
27
+ "bugs": {
28
+ "url": "https://github.com/krunal-mahera/mcp-maestro-mobile-ai/issues"
29
+ },
30
+ "scripts": {
31
+ "start": "node src/mcp-server/index.js",
32
+ "dev": "node --watch src/mcp-server/index.js",
33
+ "test:flow": "maestro test",
34
+ "lint": "eslint src/",
35
+ "prepublishOnly": "npm run lint"
36
+ },
37
+ "keywords": [
38
+ "mcp",
39
+ "model-context-protocol",
40
+ "mobile-automation",
41
+ "maestro",
42
+ "react-native",
43
+ "ai-testing",
44
+ "android",
45
+ "ios",
46
+ "copilot",
47
+ "claude",
48
+ "cursor",
49
+ "testing",
50
+ "automation",
51
+ "ai"
52
+ ],
53
+ "author": "Krunal Mahera <krunal.mahera@gmail.com>",
54
+ "license": "MIT",
55
+ "dependencies": {
56
+ "@modelcontextprotocol/sdk": "^1.0.0",
57
+ "dotenv": "^16.4.5",
58
+ "js-yaml": "^4.1.0",
59
+ "winston": "^3.17.0",
60
+ "zod": "^3.23.8"
61
+ },
62
+ "devDependencies": {
63
+ "@eslint/js": "^9.39.2",
64
+ "eslint": "^9.16.0"
65
+ },
66
+ "engines": {
67
+ "node": ">=18.0.0"
68
+ }
69
+ }
@@ -0,0 +1,9 @@
1
+ # Login Test Suite
2
+ # Each line below is a separate test prompt
3
+
4
+ Test that user can login with valid email and password and see the dashboard
5
+ Test that login fails when user enters incorrect password
6
+ Test that login button is disabled when email field is empty
7
+ Test that user sees error message when entering invalid email format
8
+ Test forgot password link navigates to password reset screen
9
+
@@ -0,0 +1,8 @@
1
+ # YouTube Test Suite
2
+ # Example prompts for testing YouTube app
3
+
4
+ Test that user can open YouTube and search for TechGuru
5
+ Test that user can play the first video in search results
6
+ Test that user can pause and resume a playing video
7
+ Test that user can subscribe to a channel
8
+