Clipboard (computing) explained

The clipboard is a buffer that some operating systems provide for short-term storage and transfer within and between application programs. The clipboard is usually temporary and unnamed, and its contents reside in the computer's RAM.[1]

The clipboard provides an application programming interface by which programs can specify cut, copy and paste operations. It is left to the program to define methods for the user to command these operations, which may include keybindings and menu selections. When an element is copied or cut, the clipboard must store enough information to enable a sensible result no matter where the element is pasted. Application programs may extend the clipboard functions that the operating system provides. A clipboard manager may give the user additional control over the clipboard. Specific clipboard semantics vary among operating systems, can also vary between versions of the same system, and can sometimes be changed by programs and by user preferences.

Windows, Linux and macOS support a single clipboard transaction.[2] [3]

History

Clipboards as buffers for small text snippets were first used by Pentti Kanerva when he used it to store deleted texts in order to restore them.[4] Since one could delete a text in one place and restore it in another, the term "delete" wasn't what one would expect in this case. Larry Tesler renamed this in 1973 as cut, copy, and paste and coined the term "clipboard" for this buffer, since these techniques need a clipboard for temporary saving the copied or cut data.[5]

Data formats

Applications communicate through the clipboard by providing either serialized representations of an object, or a promise (for larger objects).[6] In some circumstances, the transfer of certain common data formats may be achieved opaquely through the use of an abstract factory; for example, Mac OS X uses a class called NSImage to provide access to image data stored on the clipboard, though the actual format of the image data backing the object is hidden. The sending and receiving application negotiate the formats which can be transferred in between them, oftentimes with the active GUI widget responsible for providing acceptable type transformations. The pasteboard allows for transfer of common items such as URLs, colors, images, strings, attributed strings (Rich text), and sounds. The operating system and GUI toolkit may provide some common conversions, for example converting from rich text to plain text and vice versa. Various type identifiers for data transfer are supported by modern operating systems, which may automatically provide acceptable mappings between type systems, such as between MIME and Uniform Type Identifier.[7] [8]

Computer security

Clipboard hijacking or clipboard injection is an exploit in which a person's clipboard's content is replaced by malicious data, such as a link to a malicious web site.[9] For example, if a user copies a cryptocurrency receiving address into the clipboard, a hijacking program can overwrite it with an address controlled by the hijacker, so that when the user pastes the address their cryptocurrency is transmitted to the hijacker instead of the intended recipient.[10] While some security-holes were patched, JavaScript can still be used to modify clipboard content via an attack dubbed 'pastejacking'.[11] [12] Dylan Ayrey who developed the attack set up a website that demonstrates how this exploit can be used to trick a user into running commands they didn't want to run.[13]

There have been exploits where web pages grab clipboard data. In early 2013 researchers exposed risks stemming from Android-based password managers and documented how passwords in 21 of the most popular of these apps could be accessed by any other app on an Android device including those with extremely low-level privileges.[14] Joe Siegrist notes that this is an "OS-level issue that impacts everything running on Android".[15]

Clipboard management and extensions

See also: Snippet management. Clipboard manager extensions add functionality to the integrated clipboard functions of an operating system. They are applications that enable the user to manipulate the clipboard. On platforms such as Linux that use multiple incompatible GUI toolkits, clipboard managers are often used to transfer data between applications using different such frameworks.

When a clipboard manager provides multiple cut and paste transactions, the clipboard is treated as a stack or scrap book, with new cuts and copies being placed on a list of recent transactions. The standard paste operation copies the most recent transaction, while specialized pastes provide access to the other stored transactions. These managers generally also provide a window that displays the transaction history and allows the user to select earlier copies, edit them, change their format and even search amongst them.

Since most operating systems (e.g. Windows, macOS, Linux, X11, Android, iOS) do not save the clipboard contents to any persistent storage – when a user logs out or reboots the system the clipboard contents are deleted – an added functionality is to save the clipboard persistently. Another example is making the local clipboard work with online applications by saving the clipboard data to the online location upon a copy or cut event, making this data available to online applications for pasting. Clipboard managers can also serve as tools to overcome the limitation of software not supporting copying and pasting (for example, while logging into remote Windows server, one cannot copy and paste their user name and password).

Operating system-specific clipboards

AmigaOS

The Amiga operating system uses 256 units, so one has multiple clipboards at the same time.[16]

Android

Android provides a clipboard that can hold up to one clip object and is accessible system-wide. Simple text is stored directly in the clipboard; complex data are stored by reference. The clip object has one of three formats: text string, URI object, or intent.[17]

To interact with the clipboard, an app uses the class ClipboardManager[18] and system calls to cut, copy, and paste objects.

In Android 8.0, the clipboard first appears in the user interface: In a situation where the user prepares to paste from the clipboard, a "Clipboard" option appears that gives the user access to many objects copied or cut to the clipboard in the past. Apart from that, and in earlier versions, the user has no access to the clipboard except in apps that make it available to the user.

iOS

The clipboard is called "pasteboard" in iOS similar to OS X. Apps on this operating system can create additional pasteboards, called instances of the UIPasteboard class, which can be public or private. One instance can hold a single item or multiple items in different formats.[19]

The formats are identified by Uniform Type Identifiers (UTI).[20]

The data contained in the pasteboard cannot be accessed via the GUI but only from the system and applications

macOS

The clipboard in macOS holds one item in multiple available formats.

The contents of the clipboard can be viewed by selecting the Show Clipboard menu item from the Finder's Edit menu. The raw data and the stored formats can be seen using the ClipboardViewer.[21]

Using the following commands the clipboard can be accessed from the command line:[22] [23] $ # to copy data into the clipboard:$ echo 'hello world' | pbcopy$ # to paste from the clipboard:$ pbpastehello world

Microsoft Windows and ReactOS

clip
Developer:Microsoft, ReactOS Contributors
Operating System:Windows, ReactOS
Genre:Command
License:Windows: Proprietary commercial software
ReactOS: GNU General Public License

The clipboard in Microsoft Windows and ReactOS holds one item in multiple available formats.

Every item has at least one clipboard format, but can have different types of format of the same data. The three different types of possible formats are:[24]

Up to and including Windows XP the clipboard could be accessed via the ClipBook Viewer application.[27] In newer versions of Windows the content can be accessed via clipboard managers.

Data can be stored to the Windows[28] and ReactOS[29] clipboard via command line using the clip command:[30]

$ # to paste the content of a folder to the clipboard:$ dir | clip

The clipboard can also be accessed via PowerShell:[31] [32]

  1. to paste the content of a directory to the clipboard

Set-Clipboard -Path "C:\directory\"

  1. to get the content of the clipboard

Get-ClipboardWindows 10 and Windows 11 include the Clipboard application, allowing for the storage of multiple text-based clipboard items. It can be accessed by pressing Windows+V.

X Window System

The X Window System commonly used on Unix and Linux systems provides three clipboards, which are named "CLIPBOARD", "PRIMARY" and "SECONDARY".[33] The usage and handling of various selections is not standardized. However, most modern toolkits and desktop environments, such as GNOME or KDE, follow a widely accepted convention, outlined in the freedesktop.org specification.[34] One selection, CLIPBOARD, is used for traditional clipboard semantics, with shortcuts identical to Windows. Another selection, PRIMARY, is an X11-specific mechanism. Data is "copied" immediately upon highlighting and pasted with the third (middle) mouse button.[35] This copied data is usually separated from the CLIPBOARD selection and does not change its contents.[36] SECONDARY was planned as an alternative to PRIMARY but is only used inconsistently.

There are two command line tools (xsel and xclip) which can access the clipboard:[37] $ # to paste standard output to the clipboard using xclip$ echo text | xclip -in -selection clipboard$ # to paste standard output to the clipboard using xsel$ echo text | xsel --clipboard

The main difference to OS X and Windows is that no data is actually stored in the CLIPBOARD-clipboard but only the reference to the copied or cut data. The application claims the ownership of the CLIPBOARD selection and communicates its ownership to the X Server. When pasting this data, the data and its available formats are requested from the application that owns the CLIPBOARD selection.[38]

APIs

Applications can access the clipboard or its data via APIs.

JavaScript

In JavaScript a class which detects changes in the users clipboard data (ClipboardEvent)[39] and functions to alter the content of a clipboard or read from it (clipboardData.getData, clipboardData.setData)[40] exist, but aren't supported by every browser since altering the clipboard of a user can represent a security issue.

Qt

In Qt a wrapper for every supported platform[41] exists. It provides access to window system clipboards with the use of the class QClipboard. This class facilitates access to common data types by functions.[42] The data type of the element stored in the clipboard is indicated via MIME and MIME data can also be put in the clipboard with help of functions from this class.

See also

Further reading

External links

Notes and References

  1. News: What is a Clipboard in Computing? - Definition from Techopedia. Techopedia.com. 2018-02-01. en. https://web.archive.org/web/20180202200114/https://www.techopedia.com/definition/4646/clipboard. 2018-02-02. live.
  2. Kimmatkar. Sarang B.. 2014. Extending functionalities of default clipboard.. (IJCSIT) International Journal of Computer Science and Information Technologies 5. 6.
  3. Book: Stephens, Rod. Visual Basic 2010 : programmer's reference. 2010. Indianapolis, IN : Wiley Pub., Inc.. Library Genesis. 978-0-470-49983-2. limited.
  4. Book: Moggridge, Bill. 2007. Designing interactions. Cambridge, Massachusetts. MIT Press. 65ff. 9780262134743. registration.
  5. Web site: Larry Tesler. A User Experience Retrospective. 23 January 2018. https://web.archive.org/web/20180202071746/http://www.nomodes.com/Larry_Tesler_Consulting/Retrospective/Pages/CHI_Retrospective.html. 2018-02-02. live.
  6. Web site: Dragging Files . developer.apple.com . 9 December 2018.
  7. Web site: NSPasteboard - AppKit Apple Developer Documentation . developer.apple.com . 9 December 2018 . https://web.archive.org/web/20180526202133/https://developer.apple.com/documentation/appkit/nspasteboard . 2018-05-26 . live .
  8. Web site: Adopting Uniform Type Identifiers . developer.apple.com . 9 December 2018 . https://web.archive.org/web/20180721122838/https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis.tasks/understand_utis_tasks.html#//apple_ref/doc/uid/TP40001319-CH203-BABHCIAC#//apple_ref/doc/uid/TP40001319-CH203-BABHCIAC . 2018-07-21 . live .
  9. Web site: What is clipboard hijack attack? - Definition from WhatIs.com. WhatIs.com. 4 January 2017. https://web.archive.org/web/20170105083320/http://whatis.techtarget.com/definition/clipboard-hijack-attack. 2017-01-05. live.
  10. Web site: 2023-03-28 . Clipboard injector distributed under the guise of Tor Browser . 2024-05-15 . securelist.com . en-US.
  11. Web site: Chirgwin. Richard. Pastejack attack turns your clipboard into a threat. The Register. 4 January 2017. https://web.archive.org/web/20170104235824/http://www.theregister.co.uk/2016/05/25/pastejack_attack_turns_your_clipboard_into_a_vector/. 2017-01-04. live.
  12. Web site: Researcher warns of 'pastejacking' hack attacks targeting users' clipboards. Graham Cluley. 4 January 2017. 26 May 2016. https://web.archive.org/web/20170105001104/https://www.grahamcluley.com/researcher-warns-pastejacking-hack-attacks-targeting-users-clipboards/. 2017-01-05. live.
  13. Web site: dxa4481/Pastejacking. GitHub. 4 January 2017. https://web.archive.org/web/20170104074050/https://github.com/dxa4481/Pastejacking. 2017-01-04. live.
  14. Book: Hey, You, Get Off of My Clipboard. 10.1007/978-3-642-39884-1_12. http://fc13.ifca.ai/proc/4-2.pdf. 4 January 2017. 7859. 144–161. https://web.archive.org/web/20170919070257/http://fc13.ifca.ai/proc/4-2.pdf. 2017-09-19. live. Financial Cryptography and Data Security. Lecture Notes in Computer Science. 2013. Fahl. Sascha. Harbach. Marian. Oltrogge. Marten. Muders. Thomas. Smith. Matthew. 978-3-642-39883-4.
  15. Web site: Using a password manager on Android? It may be wide open to sniffing attacks. 21 November 2014. Ars Technica. 4 January 2017. https://web.archive.org/web/20170104235202/http://arstechnica.com/security/2014/11/using-a-password-manager-on-android-it-may-be-wide-open-to-sniffing-attacks/. 2017-01-04. live.
  16. Web site: Clipboard Device - AmigaOS Documentation Wiki . live . https://web.archive.org/web/20180205000829/http://wiki.amigaos.net/wiki/Clipboard_Device#Multiple_Clips#Multiple_Clips . 2018-02-05 . 2018-02-03 . wiki.amigaos.net . en.
  17. Web site: Copy and Paste Android Developers . live . https://web.archive.org/web/20180207122225/https://developer.android.com/guide/topics/text/copy-paste.html . 2018-02-07 . 2018-02-06 . developer.android.com . en.
  18. Web site: ClipboardManager Android Developers . live . https://web.archive.org/web/20180207062710/https://developer.android.com/reference/android/text/ClipboardManager.html . 2018-02-07 . 2018-02-02 . developer.android.com . en.
  19. Web site: Pasteboard . live . https://web.archive.org/web/20180207063018/https://developer.apple.com/library/content/documentation/General/Conceptual/Devpedia-CocoaApp/Pasteboard.html . 2018-02-07 . 2018-02-01 . developer.apple.com . en.
  20. Web site: Uniform Type Identifier . live . https://web.archive.org/web/20180207062907/https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html#//apple_ref/doc/uid/TP40008195-CH60#//apple_ref/doc/uid/TP40008195-CH60 . 2018-02-07 . 2018-02-06 . developer.apple.com . en.
  21. Web site: ClipboardViewer . live . https://web.archive.org/web/20180207063107/https://developer.apple.com/library/content/samplecode/ClipboardViewer/Introduction/Intro.html . 2018-02-07 . 2018-02-06 . developer.apple.com . en.
  22. Web site: Copy to clipboard from terminal in OS X . dead . https://web.archive.org/web/20130815002844/http://blog.rogeriopvl.com/archives/copy-to-clipboard-from-terminal-in-os-x/ . 2013-08-15 . 2013-07-02 . rogeriopvl.com.
  23. Web site: pbcopy(1) Mac OS X Manual Page . live . https://web.archive.org/web/20140328023751/https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html . 2014-03-28 . 2013-07-02 . apple.com.
  24. Web site: Clipboard Formats (Windows). msdn.microsoft.com. en. 2018-02-03. https://web.archive.org/web/20180207122331/https://msdn.microsoft.com/en-us/library/windows/desktop/ms649013(v=vs.85).aspx. 2018-02-07. live.
  25. Web site: Standard Clipboard Formats (Windows). msdn.microsoft.com. en. 2018-02-03. https://web.archive.org/web/20180207122513/https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168(v=vs.85).aspx. 2018-02-07. live.
  26. Web site: HTML Clipboard Format (Internet Explorer). msdn.microsoft.com. en. 2018-02-03. https://web.archive.org/web/20180207122510/https://msdn.microsoft.com/en-us/library/aa767917(VS.85).aspx. 2018-02-07. live.
  27. News: View & Manage Clipboard In Windows 10/8/7. 2013-04-12. The Windows Club. 2018-02-06. en-US. https://web.archive.org/web/20180212151136/http://www.thewindowsclub.com/windows-clipboard-manager-viewer. 2018-02-12. live.
  28. Web site: clip | Microsoft Docs . Docs.microsoft.com . 2017-10-16 . 2019-09-26.
  29. Web site: reactos/base/applications/cmdutils/clip at master · reactos/reactos · GitHub . Github.com . 2019-09-26.
  30. Web site: How to Copy Command Line Output to the Windows Clipboard. www.labnol.org. en-US. 2018-02-06. https://web.archive.org/web/20180207122226/https://www.labnol.org/software/copy-command-output-to-clipboard/2506/. 2018-02-07. live.
  31. Web site: Get-Clipboard (Microsoft.PowerShell.Management). sdwheeler. docs.microsoft.com. en-us. 2018-02-06. https://web.archive.org/web/20180126105455/https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-clipboard?view=powershell-5.1. 2018-01-26. live.
  32. Web site: Set-Clipboard (Microsoft.PowerShell.Management). sdwheeler. docs.microsoft.com. en-us. 2018-02-06. https://web.archive.org/web/20180207122353/https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-clipboard?view=powershell-5.1. 2018-02-07. live.
  33. Web site: Clipboard - ArchWiki. wiki.archlinux.org. en. 2018-02-16. https://web.archive.org/web/20180217023932/https://wiki.archlinux.org/index.php/Clipboard. 2018-02-17. live.
  34. Web site: clipboards-spec . freedesktop.org . 2014-08-16 . https://web.archive.org/web/20141224001434/http://www.freedesktop.org/wiki/Specifications/clipboards-spec/ . 2014-12-24 . live .
  35. Web site: Copy & Paste, Drag & Drop [MI Wiki]]. wiki.mi.ur.de. de. 2018-02-16. https://web.archive.org/web/20180216204616/https://wiki.mi.ur.de/lehre/ss17/itt/copyandpaste. 2018-02-16. live.
  36. Web site: gnu.org. www.gnu.org. en. 2018-02-16. https://web.archive.org/web/20171224062228/http://www.gnu.org/software/emacs/manual/html_node/emacs/Primary-Selection.html. 2017-12-24. live.
  37. Web site: Copying and Pasting To and From the System Clipboard On The Command Line — Fernando Basso. fernandobasso.github.io. en. 2018-02-06. https://web.archive.org/web/20180207122218/https://fernandobasso.github.io/en/shell/copy-paste-from-command-line-xclip-xsel-clipboard.html#about-xclip-and-xsel. 2018-02-07. dead.
  38. Web site: X Selections, X Cut Buffers, and Emacs Kill Rings. www.jwz.org. 2018-02-02. https://web.archive.org/web/20180304195944/https://www.jwz.org/doc/x-cut-and-paste.html. 2018-03-04. live.
  39. Web site: Clipboard API and events – ClipboardEvent. www.w3.org. https://web.archive.org/web/20180128044120/https://www.w3.org/TR/clipboard-apis/#clipboard-events-and-interfaces#clipboard-events-and-interfaces. 2018-01-28. live. 2018-02-08.
  40. Web site: Clipboard API and events – Synchronous Clipboard API. www.w3.org. en. https://web.archive.org/web/20180128044120/https://www.w3.org/TR/clipboard-apis/#sync-clipboard-api#sync-clipboard-api. 2018-01-28. live. 2018-02-08.
  41. Web site: platforms\plugins\src - qt/qtbase.git - Qt Base (Core, Gui, Widgets, Network, ...). code.qt.io. en. 2018-02-02. https://web.archive.org/web/20180209064223/http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms. 2018-02-09. live.
  42. Web site: QClipboard Class Qt GUI 5.10. doc.qt.io. en. 2018-02-02. https://web.archive.org/web/20180202011104/http://doc.qt.io/qt-5/QClipboard.html. 2018-02-02. live.