fix(desktop): bypass TCC permission check for screen recording and accessibility in debug builds#1723
Open
MinitJain wants to merge 1 commit intoCapSoftware:mainfrom
Open
Conversation
…cessibility in debug builds On macOS Sequoia, CGPreflightScreenCaptureAccess() always returns false for ad-hoc signed or unsigned binaries regardless of System Settings, making it impossible to test locally without a Developer ID certificate. Adding a debug_assertions early return for ScreenRecording and Accessibility allows contributors to run and test the app locally without being blocked by the permissions screen. Camera and microphone are unaffected as they prompt correctly without a signed binary. Fixes CapSoftware#1722 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
I've created #undefined with the requested changes. Please review and merge it into this PR when ready. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CGPreflightScreenCaptureAccess()always returnsfalsefor ad-hoc signed or unsigned debug binaries, regardless of what is granted in System Settings#[cfg(debug_assertions)]early return forScreenRecordingandAccessibilityinmacos_permission_status()— bypassing the TCC check only in debug buildsWhy only these two?
ScreenRecordingandAccessibilityuse OS APIs (CGPreflightScreenCaptureAccess,AXIsProcessTrusted) that require a binary signed with a valid Apple Developer ID on Sequoia. Camera and microphone use AVFoundation which prompts and grants correctly regardless of signing.Test plan
cargo buildand launch the debug binary — permissions screen should be skipped, app goes straight to main UIdebug_assertionsonly)Closes #1722
🤖 Generated with Claude Code
Greptile Summary
This PR adds a
#[cfg(debug_assertions)]early-return bypass inmacos_permission_statusforScreenRecordingandAccessibilitypermissions, addressing a macOS Sequoia regression whereCGPreflightScreenCaptureAccessandAXIsProcessTrustedalways returnfalsefor ad-hoc-signed or unsigned debug binaries regardless of System Settings grants. The bypass is tightly scoped to debug builds only and leaves release-build behavior, Camera, and Microphone checks untouched.Confidence Score: 5/5
Safe to merge — the bypass is compile-time gated to debug builds and has no effect on release binaries.
The change is a single, well-scoped early-return behind
#[cfg(debug_assertions)]. It correctly targets only the two permissions whose OS APIs fail for unsigned binaries on Sequoia, leaves Camera/Microphone and all non-macOS paths untouched, and cannot reach production. No P0/P1 findings were identified.No files require special attention.
Vulnerabilities
No security concerns identified. The bypass is gated behind
#[cfg(debug_assertions)], which is a compile-time flag stripped from release builds, so it cannot be triggered in production binaries.Important Files Changed
#[cfg(debug_assertions)]guard that short-circuitsmacos_permission_statusforScreenRecordingandAccessibility— clean, minimal change with no impact on release builds, Windows, or Camera/Microphone permissions.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[macos_permission_status called] --> B{cfg debug_assertions\nAND ScreenRecording\nOR Accessibility?} B -- Yes --> C[return Granted immediately\ndebug builds only] B -- No --> D{permission type} D -- ScreenRecording --> E[scap_screencapturekit::has_permission] D -- Camera --> F[AVFoundation authorization status] D -- Microphone --> G[AVFoundation authorization status] D -- Accessibility --> H[AXIsProcessTrusted] E --> I[Granted / Empty / Denied] F --> I G --> I H --> I C --> J[OSPermissionStatus::Granted] I --> K[OSPermissionStatus]Reviews (1): Last reviewed commit: "fix(desktop): bypass TCC permission chec..." | Re-trigger Greptile
(4/5) You can add custom instructions or style guidelines for the agent here!