MASWE-0030: Improper Use of the Clipboard
MAS Requirement
The app uses the clipboard securely and only with user consent.
Mappings
MASVS V2: MASVS-PLATFORM-1, MASVS-STORAGE-2
CWE: CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, CWE-668: Exposure of Resource to Wrong Sphere
Android Risks: secure-clipboard-handling
Overview¶
This weakness occurs when an app places sensitive data on the system clipboard, or handles clipboard content insecurely, exposing that data beyond the app's control.
The clipboard is a shared resource: other apps can read its contents, and on some platforms, clipboard content synchronizes to nearby devices (e.g. the iOS Universal Clipboard). Copying sensitive data such as passwords, one-time codes, card numbers, or tokens to the clipboard, failing to mark it as sensitive, or leaving it there indefinitely can leak that data to other apps and devices.
Modes of Introduction¶
- Sensitive Data Copyable Without User Consent: Copying sensitive values such as passwords, one-time codes, or card numbers to the clipboard without user consent.
- Clipboard Content Not Marked Sensitive: Not flagging copied sensitive content as sensitive where the platform supports it (e.g.
EXTRA_IS_SENSITIVEon Android), so previews and clipboard history show it in cleartext. - Universal Clipboard Not Restricted: Not restricting sensitive clipboard items to the local device or setting an expiration on iOS, letting them sync to other devices.
- Clipboard Not Cleared: Leaving sensitive content on the clipboard after it has served its purpose.
- Untrusted Clipboard Input: Processing pasted clipboard data without validation, even though any app can have written it.
Impact¶
- Compromise of Sensitive Data: Attackers can read personal or financial data from the clipboard, resulting in unauthorized disclosure of user data.
- Authentication or Authorization Bypass: Attackers can capture copied credentials or one-time codes, resulting in unauthorized access to the user's accounts.
Mitigations¶
- Avoid the Clipboard for Secrets: Disable copying for sensitive fields and provide secure alternatives such as auto-fill (see Lack of Auto-fill Support for Credential Providers) so users never need to copy secrets.
- Only Copy with User Consent: If copying is required, ask the user for consent before placing sensitive data on the clipboard, or only act as a result of a user-chosen action (e.g. a "Copy" button).
- Mark Clipboard Content as Sensitive: When sensitive content must be copied, flag it as sensitive so the platform masks previews and treats it accordingly.
- Specify an appropriate expiration: When sensitive content must be copied, set an expiration so it is removed from the clipboard after a short time.
- Restrict Clipboard Exposure: When copying, follow the platform's secure clipboard handling guidance on Android and mark the content using
ClipDescription.EXTRA_IS_SENSITIVEto obscure clipboard previews. On iOS, use pasteboard options such aslocalOnlyandexpirationDateto limit cross-device propagation and content lifetime. - Validate Pasted Data: Treat clipboard content as untrusted input and validate it before use.
Tests¶
No Tests Yet
The MASTG doesn't contain any tests for this weakness yet. If you have proposals or would like to work on some, please open an issue in https://github.com/OWASP/mastg/issues indicating the MASWE-0030 mapping, the test titles and a summary of the tests.