Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 6.25 KB

File metadata and controls

64 lines (45 loc) · 6.25 KB

Mitigation Strategies Analysis for baseflow/flutter-permission-handler

Description:

  1. switch on PermissionStatus: After every call to permission_handler's request() or check() methods, use a switch statement (or equivalent) to explicitly handle all possible PermissionStatus values returned by the plugin: granted, denied, permanentlyDenied, restricted, and limited. Do not rely on simple isGranted checks alone.
  2. openAppSettings() (Conditional): Within the permanentlyDenied case of the switch statement, and only in this case, consider using permission_handler's openAppSettings() function to direct the user to the app's settings. Provide clear instructions (see previous full strategy for details on this).
  3. Error Handling (Plugin-Specific): Implement error handling specifically for potential exceptions that might be thrown by permission_handler methods (e.g., if the plugin itself encounters an internal error). This is distinct from handling the PermissionStatus.

Threats Mitigated:

  • Ignoring Permission Status (Severity: High): Directly addresses this by forcing the developer to consider all possible outcomes from the plugin.
  • Improper openAppSettings() Usage (Severity: Medium): Ensures openAppSettings() is only used in the correct context (permanent denial), as intended by the plugin.
  • Plugin-Specific Errors (Severity: Low/Medium): Catches potential errors originating from within the flutter-permission-handler plugin itself.

Impact:

  • Ignoring Permission Status: Risk significantly reduced (e.g., from High to Low).
  • Improper openAppSettings() Usage: Risk reduced (e.g., from Medium to Low).
  • Plugin-Specific Errors: Risk reduced (e.g., from Low/Medium to Low).

Currently Implemented: Basic status checks (isGranted) are present in most permission-related functions. openAppSettings() is used in some cases of permanent denial.

Missing Implementation: Comprehensive switch statements handling all status values are missing in several areas. Error handling specifically for permission_handler exceptions is largely absent.

Description:

  1. Regular pubspec.yaml Review: Regularly (e.g., weekly) review the pubspec.yaml file to ensure the flutter-permission-handler dependency is using semantic versioning (e.g., ^7.0.0) to allow for automatic updates of compatible versions.
  2. Scheduled flutter pub upgrade: Include flutter pub upgrade as a regular step in the development workflow (e.g., part of each sprint or release cycle) to ensure flutter-permission-handler is updated to the latest compatible version.
  3. Changelog Review (Before Major Updates): Before performing a major version update of flutter-permission-handler (e.g., from 7.x.x to 8.x.x), carefully review the plugin's changelog on pub.dev or GitHub. Look for any breaking changes, security fixes, or new features that might affect the application.
  4. Monitor for Security Advisories: Actively monitor the flutter-permission-handler repository (e.g., GitHub issues, pub.dev page) for any security advisories or reported vulnerabilities.

Threats Mitigated:

  • Outdated Plugin Version (Severity: Medium/High): Directly addresses the risk of using a version of flutter-permission-handler with known vulnerabilities or bugs.
  • Dependency Conflicts (Severity: Low/Medium): While broader than just this plugin, keeping flutter-permission-handler updated helps maintain overall dependency health.

Impact:

  • Outdated Plugin Version: Risk significantly reduced (e.g., from Medium/High to Low).
  • Dependency Conflicts: Risk reduced (indirectly, as part of overall dependency management).

Currently Implemented: pubspec.yaml uses semantic versioning. Developers are encouraged to run flutter pub upgrade regularly.

Missing Implementation: A formal schedule for flutter pub upgrade is not enforced. Changelog review is not consistently performed before major updates. Active monitoring for security advisories is not formalized.

Description:

  1. check() Before request(): Use permission_handler's check() method before calling request() to determine if the permission has already been granted. This avoids unnecessary permission prompts to the user.
  2. Avoid Redundant request() Calls: Do not repeatedly call request() for the same permission if it has already been denied or permanently denied. Use the PermissionStatus to determine the appropriate action.
  3. Understand request() Behavior: Be aware that request() may behave differently on different platforms (e.g., showing a system dialog on iOS, potentially granting implicitly on Android within a group).

Threats Mitigated:

  • Poor User Experience (Severity: Medium): Avoids unnecessary permission prompts, improving the user experience.
  • Ignoring Permission Status (Severity: Medium): Encourages checking the status before requesting, reducing the chance of ignoring the result.
  • Platform-Specific Inconsistencies (Severity: Low): Promotes understanding of how request() behaves on different platforms.

Impact:

  • Poor User Experience: Risk reduced (e.g., from Medium to Low).
  • Ignoring Permission Status: Risk reduced (indirectly, by promoting best practices).
  • Platform-Specific Inconsistencies: Risk reduced (by increasing awareness).

Currently Implemented: check() is used in some places before request(), but not consistently.

Missing Implementation: Several areas call request() directly without first checking the permission status. Redundant request() calls are present in some error handling logic.