Least privilege and privacy APIs

Security Junior Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

An app requests READ_MEDIA_IMAGES just so users can choose a profile photo. Better approach?

Options
Hint 1 of 1

Is there a picker that needs no permission?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Use the Photo Picker with PickVisualMedia, which needs no permission

Correct. The user picks one image; the app sees only that.

Why not the others?
  • B Request MANAGE_EXTERNAL_STORAGE. Far broader and restricted on Play.
  • C Ask at first launch. Still more access than needed.
  • D Copy all images to app storage. Needs the permission and wastes space.

30-second answer

Ask only for what a feature needs, at the moment it's used. Prefer privacy-friendly alternatives: the Photo Picker instead of storage permissions, approximate location when precise isn't needed, Activity Result contracts like TakePicture that need no camera permission, and Credential Manager instead of reading accounts. Audit merged manifests, since libraries can add permissions.

Practise saying it · 30 s. No recording, just a timer

Explain least privilege.

Say your answer out loud, then check which of these points you covered:

  • Ask at time of use
  • Photo Picker, approximate location
  • Result contracts
  • Audit merged manifest

Deep dive

tools:node="remove" drops a permission a library adds if you don't need it.

Android 14 lets users grant access to selected photos only; handle partial access.

Play's Data safety form must match what you collect.

Removing a permission in an update needs no user action.

Common mistakes

  • Requesting every permission at first launch.
  • Not checking the merged manifest.
  • Requesting storage access just to pick one image.

Senior take & follow-ups

Give concrete swaps: picker, approximate location, result contracts.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you find permissions added by libraries?

    Show hint

    Check the merged manifest in Android Studio.

  2. Which permission does the Photo Picker need?

    Show hint

    None.

Similar on iOS: Privacy manifests iOS declares data use in privacy manifests; Play has the Data safety form.

Suggest a fix if something here is wrong or out of date.