Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 4.56 KB

File metadata and controls

52 lines (43 loc) · 4.56 KB

Attack Surface Analysis for marcuswestin/webviewjavascriptbridge

  • Description: Attackers on a compromised device intercept or alter messages exchanged between the native application and the webview via the bridge.
  • How webviewjavascriptbridge Contributes: The bridge is the communication channel, making this attack possible. It's distinct from webview HTTPS security.
  • Example: An attacker intercepts a message containing a user's session token sent from the native app to the webview, allowing them to impersonate the user.
  • Impact: Complete compromise of user accounts, data theft, unauthorized actions.
  • Risk Severity: Critical
  • Mitigation Strategies:
    • Cryptographic Message Integrity: Implement message signing (e.g., SHA-256 with a securely stored key). Verify signatures on both sides before processing.
    • Encryption of Bridge Messages: Encrypt the entire message payload (e.g., AES with a securely managed key).
    • Root/Jailbreak Detection: Detect compromised devices and limit/disable functionality.
    • Code Obfuscation & Anti-Tampering: Hinder reverse engineering of the bridge communication.
  • Description: Attackers inject malicious JavaScript that calls native functions exposed by the bridge with unexpected or malicious parameters.
  • How webviewjavascriptbridge Contributes: The bridge's core purpose is to expose native functions to JavaScript, creating this direct attack vector.
  • Example: An attacker injects JavaScript that calls a native function designed to delete user data, passing a wildcard to delete all data.
  • Impact: Data loss, denial of service, privilege escalation, execution of arbitrary native code.
  • Risk Severity: Critical
  • Mitigation Strategies:
    • Strict Input Validation: Thoroughly validate all input from JavaScript in every exposed native function. Use whitelisting.
    • Principle of Least Privilege: Expose only the absolute minimum necessary native functions.
    • Contextual Authorization: Verify the calling context (e.g., origin URL) before execution.
    • Rate Limiting: Limit the frequency of native function calls.
  • Description: Attackers inject JavaScript that overwrites or intercepts callbacks used by the bridge, stealing data or manipulating behavior.
  • How webviewjavascriptbridge Contributes: The bridge relies on JavaScript callbacks for asynchronous communication, making them a direct target.
  • Example: An attacker overwrites a callback receiving sensitive user data, redirecting it to their server.
  • Impact: Data theft, manipulation of application logic, potential for further attacks.
  • Risk Severity: High
  • Mitigation Strategies:
    • Callback Isolation: Use IIFEs or closures to isolate callback handling, preventing interference.
    • Minimize Callback Data: Return only essential data in callbacks.
    • Data Sanitization (on Native Side): Sanitize data before passing it to the JavaScript callback.
  • Description: Attackers exploit vulnerabilities in how the bridge handles message routing and function dispatch, potentially calling unintended native functions.
  • How webviewjavascriptbridge Contributes: The bridge's internal implementation of message handling and function dispatch can introduce these vulnerabilities if not designed securely.
  • Example: An attacker crafts a message with a manipulated function name that, due to a flaw in the bridge's logic, calls a privileged function not intended for exposure.
  • Impact: Execution of arbitrary native code, privilege escalation, data breaches.
  • Risk Severity: High
  • Mitigation Strategies:
    • Avoid String-Based Dispatch: Use secure dispatch (function pointers, static interfaces) instead of string-based names.
    • Strict Type Checking: Enforce rigorous type checking on all parameters and function identifiers.
    • Code Review: Thoroughly review the bridge implementation for reflection vulnerabilities.