iOS UIPasteboard

Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Data sharing within and across applications on iOS devices is facilitated by the UIPasteboard mechanism, which is divided into two primary categories:

  • Systemwide general pasteboard: This is used for sharing data with any application and is designed to persist data across device restarts and app uninstallations, a feature that has been available since iOS 10.

  • Custom / Named pasteboards: These are specifically for data sharing within an app or with another app that shares the same team ID, and are not designed to persist beyond the life of the application process that creates them, following changes introduced in iOS 10.

Security considerations play a significant role when utilizing pasteboards. For instance:

  • There is no mechanism for users to manage app permissions to access the pasteboard.

  • To mitigate the risk of unauthorized background monitoring of the pasteboard, access is restricted to when the application is in the foreground (since iOS 9).

  • The use of persistent named pasteboards is discouraged in favor of shared containers due to privacy concerns.

  • The Universal Clipboard feature introduced with iOS 10, allowing content to be shared across devices via the general pasteboard, can be managed by developers to set data expiration and disable automatic content transfer.

Ensuring that sensitive information is not inadvertently stored on the global pasteboard is crucial. Additionally, applications should be designed to prevent the misuse of global pasteboard data for unintended actions, and developers are encouraged to implement measures to prevent copying of sensitive information to the clipboard.

Static Analysis

For static analysis, search the source code or binary for:

  • generalPasteboard to identify usage of the systemwide general pasteboard.

  • pasteboardWithName:create: and pasteboardWithUniqueName for creating custom pasteboards. Verify if persistence is enabled, though this is deprecated.

Dynamic Analysis

Dynamic analysis involves hooking or tracing specific methods:

  • Monitor generalPasteboard for system-wide usage.

  • Trace pasteboardWithName:create: and pasteboardWithUniqueName for custom implementations.

  • Observe deprecated setPersistent: method calls to check for persistence settings.

Key details to monitor include:

  • Pasteboard names and contents (for instance, checking for strings, URLs, images).

  • Number of items and data types present, leveraging standard and custom data type checks.

  • Expiry and local-only options by inspecting the setItems:options: method.

An example of monitoring tool usage is objection's pasteboard monitor, which polls the generalPasteboard every 5 seconds for changes and outputs the new data.

Here's a simple JavaScript script example, inspired by the objection's approach, to read and log changes from the pasteboard every 5 seconds:

const UIPasteboard = ObjC.classes.UIPasteboard;
const Pasteboard = UIPasteboard.generalPasteboard();
var items = "";
var count = Pasteboard.changeCount().toString();

setInterval(function () {
  const currentCount = Pasteboard.changeCount().toString();
  const currentItems = Pasteboard.items().toString();

  if (currentCount === count) { return; }

  items = currentItems;
  count = currentCount;

  console.log('[* Pasteboard changed] count: ' + count +
  ' hasStrings: ' + Pasteboard.hasStrings().toString() +
  ' hasURLs: ' + Pasteboard.hasURLs().toString() +
  ' hasImages: ' + Pasteboard.hasImages().toString());

}, 1000 * 5);


Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert)!

Other ways to support HackTricks:

Last updated