| name | ios-app-extensions-pentest |
| description | iOS app extension security testing. Use this skill whenever the user needs to test iOS app extensions for security vulnerabilities, analyze extension configurations, or perform static/dynamic analysis on iOS app extensions. Trigger for any iOS security testing involving app extensions, custom keyboards, share extensions, Today widgets, or extension-related security assessments. Don't wait for the user to explicitly mention "extensions" - if they're doing iOS app security testing, check for extensions. |
iOS App Extensions Security Testing
This skill guides you through security testing of iOS app extensions, which enhance app functionality by interacting with other apps or the system.
What Are App Extensions?
App extensions provide custom features across apps:
- Custom Keyboard: Replaces default iOS keyboard across all apps
- Share Extension: Enables sharing to social networks or contacts
- Today Widget: Delivers content from Notification Center's Today view
- iMessage Extension: Custom messaging features
Security Model
Understanding the security model is critical:
- Extensions communicate with their containing app via inter-process communication (IPC), not direct memory access
- Today widgets can request their app to open via specific methods
- Shared data access requires a private container (App Groups)
- Extensions cannot:
- Access HealthKit APIs
- Start long-running background tasks
- Access camera or microphone (except iMessage extensions)
- Directly access the host app's memory
Static Analysis
Step 1: Identify App Extensions
With source code (Xcode):
grep -r "NSExtensionPointIdentifier" .
Without source code (app bundle):
find . -name "*.appex" -type d
grep -r "NSExtensionPointIdentifier" .
Common extension point identifiers:
com.apple.keyboard-service - Custom Keyboard
com.apple.share-services - Share Extension
com.apple.widget-extension - Today Widget
com.apple.message-payload-service - iMessage Extension
Step 2: Analyze Extension Configuration
Check each extension's Info.plist for:
NSExtensionActivationRule - Determines what data types trigger the extension:
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
</dict>
NSExtensionAttributes - Extension-specific configuration:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
Security implications:
- Overly permissive activation rules may expose the extension to unexpected data
- Check if the extension accepts sensitive data types (URLs, contacts, files)
- Verify the extension properly validates all input
Step 3: Check Data Sharing Configuration
Extensions share data with their host app via App Groups:
grep -A 2 "com.apple.security.application-groups" Info.plist
grep -r "NSUserDefaults" . | grep -i "suite"
What to look for:
- Shared container names (should be in
com.apple.security.application-groups entitlement)
- How data is passed between app and extension
- Whether sensitive data is stored in shared containers
- If the extension properly sanitizes data from shared containers
Step 4: Check Extension Restrictions
Apps can restrict extension capabilities:
grep -i "restricts" Info.plist
grep -A 10 "NSExtensionAttributes" Info.plist
Common restrictions:
NSExtensionRestrictsToPrivateContainer - Limits data access
- Custom keyboard restrictions for sensitive contexts
Dynamic Analysis
Step 1: Inspect Shared Items
Use Frida to hook into extension input processing:
var NSExtensionContext = ObjC.classes.NSExtensionContext;
NSExtensionContext.inputItems.implementation = function() {
console.log("[+] Extension received input items:");
var items = this.inputItems();
items.forEach(function(item) {
console.log(" - " + item.toString());
});
return this.inputItems();
};
What to observe:
- What data types the extension actually receives
- Whether the extension properly validates input
- If sensitive data flows through the extension
Step 2: Monitor IPC Communication
Extensions communicate via XPC:
frida-trace -U -n "extension-bundle-name" -S NSXPCConnection
frida-trace -U -n "extension-bundle-name" -S "-[NSXPCConnection send]"
What to look for:
- Data passed between extension and host app
- Authentication/authorization checks in IPC
- Potential injection points in IPC messages
Step 3: Test Extension Activation
For Share Extensions:
- Share various data types (text, images, URLs, contacts)
- Observe which types trigger the extension
- Test with malformed or unexpected data
- Check if the extension crashes or leaks data
For Custom Keyboards:
- Test in different apps (messaging, forms, password fields)
- Verify the keyboard doesn't capture sensitive input
- Check clipboard access behavior
- Test extension persistence across app switches
For Today Widgets:
- Test widget update frequency
- Check what data the widget displays
- Verify the widget doesn't expose sensitive information
- Test the "open app" functionality
Common Vulnerabilities
1. Insecure Data Sharing
- Sensitive data stored in shared containers without encryption
- No validation of data from shared containers
- Overly permissive App Group access
2. Input Validation Issues
- Extensions accepting unexpected data types
- No sanitization of user input
- Buffer overflows in extension code
3. IPC Security
- Unauthenticated IPC between extension and host app
- Sensitive data transmitted over IPC without encryption
- Missing authorization checks in IPC handlers
4. Extension Activation
- Extensions triggered by unexpected data
- No rate limiting on extension activation
- Extensions running with excessive privileges
Testing Checklist
References