Exactly! That’s where Entitlements and Services come in.
Since the walls are high, an app can’t just grab the photo. It has to ask the Operating System to pass it through a secure window.
- Explicit Services: If an app wants data from another app (like Photos or Contacts), it has to use specific system services provided by OS. It can’t go direct.
- Entitlements: This is the keycard system. Developers have to sign their apps with specific Entitlements (key-value pairs) that declare what they intend to do (e.g., I need to access the camera).
If an app tries to access the camera but doesn’t have that specific entitlement signed into its code, the system blocks it immediately. And even if it does have the entitlement, iOS will usually throw up that pop-up we all know: “App X would like to access your Photos.” That is the TCC (Transparency, Consent, and Control) framework in action.
Bonus security point:
Apple also uses something called ASLR (Address Space Layout Randomization). Every time an app launches, its memory locations are shuffled. So even if a hacker found a way to inject code, they wouldn’t know where in the memory to put it because the address changes every time.
Hope that helps!