macOS TCC
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Basic Information
TCC (Transparency, Consent, and Control) is a security protocol focusing on regulating application permissions. Its primary role is to safeguard sensitive features like location services, contacts, photos, microphone, camera, accessibility, and full disk access. By mandating explicit user consent before granting app access to these elements, TCC enhances privacy and user control over their data.
Users encounter TCC when applications request access to protected features. This is visible through a prompt that allows users to approve or deny access. Furthermore, TCC accommodates direct user actions, such as dragging and dropping files into an application, to grant access to specific files, ensuring that applications have access only to what is explicitly permitted.
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2Frainforest.engineering%2Fimages%2Fposts%2Fmacos-tcc%2Ftcc-prompt.png%3F1620047855&width=768&dpr=4&quality=100&sign=8d9d3db0&sv=1)
TCC is handled by the daemon located in /System/Library/PrivateFrameworks/TCC.framework/Support/tccd
and configured in /System/Library/LaunchDaemons/com.apple.tccd.system.plist
(registering the mach service com.apple.tccd.system
).
There is a user-mode tccd running per logged in user defined in /System/Library/LaunchAgents/com.apple.tccd.plist
registering the mach services com.apple.tccd
and com.apple.usernotifications.delegate.com.apple.tccd
.
Here you can see the tccd running as system and as user:
Permissions are inherited from the parent application and the permissions are tracked based on the Bundle ID and the Developer ID.
TCC Databases
The allowances/denies then stored in some TCC databases:
The system-wide database in
/Library/Application Support/com.apple.TCC/TCC.db
.This database is SIP protected, so only a SIP bypass can write into it.
The user TCC database
$HOME/Library/Application Support/com.apple.TCC/TCC.db
for per-user preferences.This database is protected so only processes with high TCC privileges like Full Disk Access can write to it (but i't not protected by SIP).
The previous databases are also TCC protected for read access. So you won't be able to read your regular user TCC database unless it's from a TCC privileged process.
However, remember that a process with these high privileges (like FDA or kTCCServiceEndpointSecurityClient
) will be able to write the users TCC database
There is a third TCC database in
/var/db/locationd/clients.plist
to indicate clients allowed to access location services.The SIP protected file
/Users/carlospolop/Downloads/REG.db
(also protected from read access with TCC), contains the location of all the valid TCC databases.The SIP protected file
/Users/carlospolop/Downloads/MDMOverrides.plist
(also protected from read access with TCC), contains more TCC granted permissions.The SIP protected file
/Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist
(bu readable by anyone) is an allow list of applications that require a TCC exception.
The TCC database in iOS is in /private/var/mobile/Library/TCC/TCC.db
The notification center UI can make changes in the system TCC database:
However, users can delete or query rules with the tccutil
command line utility.
Query the databases
Checking both databases you can check the permissions an app has allowed, has forbidden, or doesn't have (it will ask for it).
The
service
is the TCC permission string representationThe
client
is the bundle ID or path to binary with the permissionsThe
client_type
indicates whether it’s a Bundle Identifier(0) or an absolute path(1)
The
auth_value
can have different values: denied(0), unknown(1), allowed(2), or limited(3).The
auth_reason
can take the following values: Error(1), User Consent(2), User Set(3), System Set(4), Service Policy(5), MDM Policy(6), Override Policy(7), Missing usage string(8), Prompt Timeout(9), Preflight Unknown(10), Entitled(11), App Type Policy(12)The csreq field is there to indicate how to verify the binary to execute and grant the TCC permissions:
For more information about the other fields of the table check this blog post.
You could also check already given permissions to apps in System Preferences --> Security & Privacy --> Privacy --> Files and Folders
.
Users can delete or query rules using tccutil
.
Reset TCC permissions
TCC Signature Checks
The TCC database stores the Bundle ID of the application, but it also stores information about the signature to make sure the App asking to use the a permission is the correct one.
Therefore, other applications using the same name and bundle ID won't be able to access granted permissions given to other apps.
Entitlements & TCC Permissions
Apps don't only need to request and have been granted access to some resources, they also need to have the relevant entitlements.
For example Telegram has the entitlement com.apple.security.device.camera
to request access to the camera. An app that doesn't have this entitlement won't be able to access the camera (and the user won't be be even asked for the permissions).
However, for apps to access to certain user folders, such as ~/Desktop
, ~/Downloads
and ~/Documents
, they don't need to have any specific entitlements. The system will transparently handle access and prompt the user as needed.
Apple's apps won’t generate prompts. They contain pre-granted rights in their entitlements list, meaning they will never generate a popup, nor they will show up in any of the TCC databases. For example:
This will avoid Calendar ask the user to access reminders, calendar and the address book.
Apart from some official documentation about entitlements it's also possible to find unofficial interesting information about entitlements in https://newosxbook.com/ent.jl
Some TCC permissions are: kTCCServiceAppleEvents, kTCCServiceCalendar, kTCCServicePhotos... There is no public list that defines all of them but you can check this list of known ones.
Sensitive unprotected places
$HOME (itself)
$HOME/.ssh, $HOME/.aws, etc
/tmp
User Intent / com.apple.macl
As mentioned previously, it possible to grant access to an App to a file by drag&dropping it to it. This access won't be specified in any TCC database but as an extended attribute of the file. This attribute will store the UUID of the allowed app:
It's curious that the com.apple.macl
attribute is managed by the Sandbox, not tccd.
Also note that if you move a file that allows the UUID of an app in your computer to a different compiter, because the same app will have different UIDs, it won't grant access to that app.
The extended attribute com.apple.macl
can’t be cleared like other extended attributes because it’s protected by SIP. However, as explained in this post, it's possible to disable it zipping the file, deleting it and unzipping it.
TCC Privesc & Bypasses
Insert into TCC
If at some point you manage to get write access over a TCC database you can use something like the following to add an entry (remove the comments):
TCC Payloads
If you managed to get inside an app with some TCC permissions check the following page with TCC payloads to abuse them:
macOS TCC PayloadsApple Events
Learn about Apple Events in:
macOS Apple EventsAutomation (Finder) to FDA*
The TCC name of the Automation permission is: kTCCServiceAppleEvents
This specific TCC permission also indicates the application that can be managed inside the TCC database (so the permissions doesn't allow just to manage everything).
Finder is an application that always has FDA (even if it doesn't appear in the UI), so if you have Automation privileges over it, you can abuse its privileges to make it do some actions.
In this case your app would need the permission kTCCServiceAppleEvents
over com.apple.Finder
.
You could abuse this to write your own user TCC database.
With this permission you will be able to ask finder to access TCC restricted folders and give you the files, but afaik you won't be able to make Finder execute arbitrary code to fully abuse his FDA access.
Therefore, you won't be able to abuse the full FDA habilities.
This is the TCC prompt to get Automation privileges over Finder:
![](https://book.hacktricks.xyz/~gitbook/image?url=https%3A%2F%2F129538173-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-L_2uGJGU7AVNRcqRvEi%252Fuploads%252F0zgOSu1C0KieOZsQo0PT%252Fimage.png%3Falt%3Dmedia%26token%3D87db7c44-82d1-49eb-9948-a5c853a19d24&width=768&dpr=4&quality=100&sign=36c916d8&sv=1)
Note that because the Automator app has the TCC permission kTCCServiceAppleEvents
, it can control any app, like Finder. So having the permission to control Automator you could also control the Finder with a code like the one below:
Same happens with Script Editor app, it can control Finder, but using an AppleScript you cannot force it to execute a script.
Automation (SE) to some TCC
System Events can create Folder Actions, and Folder actions can access some TCC folders (Desktop, Documents & Downloads), so a script like the following one can be used to abuse this behaviour:
Automation (SE) + Accessibility (kTCCServicePostEvent
|kTCCServiceAccessibility
) to FDA*
kTCCServicePostEvent
|kTCCServiceAccessibility
) to FDA*Automation on System Events
+ Accessibility (kTCCServicePostEvent
) allows to send keystrokes to processes. This way you could abuse Finder to change the users TCC.db or to give FDA to an arbitrary app (although password might be prompted for this).
Finder overwriting users TCC.db example:
kTCCServiceAccessibility
to FDA*
kTCCServiceAccessibility
to FDA*Check this page for some payloads to abuse the Accessibility permissions to privesc to FDA* or run a keylogger for example.
Endpoint Security Client to FDA
If you have kTCCServiceEndpointSecurityClient
, you have FDA. End.
System Policy SysAdmin File to FDA
kTCCServiceSystemPolicySysAdminFiles
allows to change the NFSHomeDirectory
attribute of a user that changes his home folder and therefore allows to bypass TCC.
User TCC DB to FDA
Obtaining write permissions over the user TCC database you **can'**t grant yourself FDA
permissions, only the one that lives in the system database can grant that.
But you can can give yourself Automation rights to Finder
, and abuse the previous technique to escalate to FDA*.
FDA to TCC permissions
Full Disk Access is TCC name is kTCCServiceSystemPolicyAllFiles
I don't thing this is a real privesc, but just in case you find it useful: If you controls a program with FDA you can modify the users TCC database and give yourself any access. This can be useful as a persistence technique in case you might lose your FDA permissions.
SIP Bypass to TCC Bypass
The system TCC database is protected by SIP, thats why only processes with the indicated entitlements are going to be able to modify it. Therefore, if an attacker finds a SIP bypass over a file (be able to modify a file restricted by SIP), he will be able to:
Remove the protection of a TCC database, and give himself all TCC permissions. He could abuse any of these files for example:
The TCC systems database
REG.db
MDMOverrides.plist
However, there is another option to abuse this SIP bypass to bypass TCC, the file /Library/Apple/Library/Bundles/TCC_Compatibility.bundle/Contents/Resources/AllowApplicationsList.plist
is an allow list of applications that require a TCC exception. Therefore, if an attacker can remove the SIP protection from this file and add his own application the application ill be able to bypass TCC.
For example to add terminal:
AllowApplicationsList.plist:
TCC Bypasses
macOS TCC BypassesReferences
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Last updated