[steam client] Opening a specific steam:// url overwrites files at an arbitrary location
The Steam client's handling of a devkit URL parameter allowed writing the response to an arbitrary file path, overwriting existing files. An attacker could trick a user into opening a crafted link to overwrite or wipe files the user can write to, such as SSH keys or documents.
- Triaged in 3 days
- Fixed in 9 months
- Paid in 9 months
- Disclosed after 14 months
Summary by the program
If a user opens steam://devkit-1/list-shortcuts?response=/tmp/testfile, a file /tmp/testfile will be created containing the response to this request. Another problem with this is that the file will be overwritten if it already exists.
The owner of the file will be the same as the user that runs the steam client. This also means that we can overwrite and wipe out files that the user cares about, e.g. ssh keys, documents etc as long as we know the full path to those files.
POC: (the URL may also be visited with an iframe and thus doesn't require any user interaction)
<html>
<head>
<title>Steam client POC</title>
</head>
<body>
<a href="steam://devkit-1/list-shortcuts?response=/tmp/testfile">Create /tmp/testfile</a>
<a href="steam://devkit-1/list-shortcuts?response=/home/ubuntu/.ssh/id_rsa">Overwrite /home/ubuntu/.ssh/id_rsa</a>
</body>
</html>
Impact
An attacker can overwrite and wipe out files at an arbitrary location, as long as the steam client is executed with a user that can write to those files.
A user's SSH keys, documents etc may be deleted as long as the attacker knows the full path to those files.
Context
The Steam client registers a steam:// URL scheme handler. Among the internal commands it exposes is devkit-1/list-shortcuts, which returns a list of shortcuts. The command accepts a response parameter that names a file path. When the client processes the URL, it writes the response of the request to that path.
The report is about what happens when that path is controlled by an attacker: the client creates the file, and if the file already exists it overwrites it. The file is owned by the user running the Steam client.
Setup
The report does not describe any account, role, tool or version. The only precondition is that the Steam client is running under a user that can write to the target path. The proof of concept is an HTML page with two links, which can also be loaded in an iframe so that no user interaction is required.
Finding it
The response parameter of the devkit-1/list-shortcuts command is used as a file path, and the client writes to it without restricting the location. The same parameter also causes the file to be overwritten when it already exists. Because the URL scheme is handled by the Steam client, a web page can trigger the command.
Exploitation
Step 1: Create a file at an arbitrary path
Open the following URL:
steam://devkit-1/list-shortcuts?response=/tmp/testfile
The response parameter is set to /tmp/testfile. The Steam client creates /tmp/testfile and writes the response to the list-shortcuts request into it. The file is owned by the user running the client.
Step 2: Overwrite an existing file
If the path already exists, the client overwrites it. The report gives the example of an SSH private key:
steam://devkit-1/list-shortcuts?response=/home/ubuntu/.ssh/id_rsa
After the URL is opened, /home/ubuntu/.ssh/id_rsa contains the response to the list-shortcuts request instead of the key.
Step 3: Deliver the URL from a web page
The researcher provides an HTML page with two links, one for each of the paths above:
<html>
<head>
<title>Steam client POC</title>
</head>
<body>
<a href="steam://devkit-1/list-shortcuts?response=/tmp/testfile">Create /tmp/testfile</a>
<a href="steam://devkit-1/list-shortcuts?response=/home/ubuntu/.ssh/id_rsa">Overwrite /home/ubuntu/.ssh/id_rsa</a>
</body>
</html>
The page can also be visited with an iframe, so the URL can be opened without any user interaction.
Root cause
The response parameter of the devkit-1/list-shortcuts command is used as the destination path for the response, with no restriction on the directory, and an existing file at that path is overwritten. The client therefore writes to any path the user can write to, and overwrites existing files. The report does not describe the code or the defences that were present, so the exact reason the path was not validated is not stated.
Impact
An attacker can overwrite and wipe out files at an arbitrary location, as long as the Steam client is executed by a user that can write to those files. A user's SSH keys, documents and similar files may be deleted as long as the attacker knows the full path to those files. The file is owned by the user running the client, so the write succeeds wherever that user has write permission.
Fix
A fix would need to stop the response parameter from being used as an arbitrary file path, for example by restricting the destination to a directory controlled by the client and refusing to overwrite existing files.
Variants to test
- Other
steam://commands that take a path-like parameter, such as a response file, a log file or a cache directory. A positive result is a file created or overwritten at a path you choose. - The same
responseparameter with a path outside the user's home directory, such as/tmp/testfilein the report. A positive result is a file created at that path. - The same URL loaded in an iframe. A positive result is the file being created without the user clicking a link.
- Paths to files the user cares about, such as SSH keys or documents, when the full path is known. A positive result is the file replaced by the response content.
Hunting notes
This kind of bug tends to hide in custom URL scheme handlers and in internal commands that accept a file path as a parameter. During recon, look for documentation or strings that mention a response, output, log or path parameter in a URL scheme, and for commands that write data to disk. The researcher showed creation of a new file, overwrite of an existing file and noted that the URL may also be visited with an iframe, and named the files a user could lose, such as SSH keys and documents.
What happened, in plain words
Steam is a program for buying and playing games. Like many programs, it can be opened from a link in a browser. Those links start with steam:// instead of https://, and the browser hands them to the Steam program installed on your computer. This is called a URL scheme handler: the program tells the operating system "links that start with steam:// are mine, give them to me".
Inside Steam there are internal commands that the program can run when it receives such a link. One of them is called devkit-1/list-shortcuts. It produces a list of shortcuts and, as part of its work, it can save that list to a file. The link can say where that file should go, using a parameter called response.
A parameter is a piece of information attached to a link after a question mark, like the address part of an envelope. In a normal web link, ?page=2 tells the website which page you want. Here, ?response=/tmp/testfile tells Steam which file to write the list into.
The problem is that Steam does not check where that file is. It takes whatever path the link gives it and writes there. If the file already exists, it replaces the contents. The file belongs to the same user account that is running Steam, so anything that user is allowed to change can be changed.
That means a web page can make Steam create a file in a place of the attacker's choosing, or wipe out a file the user cares about, such as an SSH key or a document, as long as the attacker knows the full path to it.
Context
The Steam client registers a steam:// URL scheme handler. A URL scheme is the first part of a link, before the ://. You already know http and https from browsing. Programs can register their own schemes so that clicking such a link opens them. When you click a steam:// link, the browser does not load a web page; it asks the operating system to pass the link to Steam.
Among the internal commands Steam exposes is devkit-1/list-shortcuts, which returns a list of shortcuts. The command accepts a response parameter that names a file path. When the client processes the URL, it writes the response of the request to that path.
A file path is the full address of a file on a computer, such as /tmp/testfile. On Linux and macOS, paths start at the root / and list folders separated by slashes. On Windows they look like C:\Users\.... The report uses Linux-style paths.
The report is about what happens when that path is controlled by an attacker: the client creates the file, and if the file already exists it overwrites it. The file is owned by the user running the Steam client. "Owned by" means the operating system records that user as the file's owner, and the user's permissions decide what can be done with it.
Setup
The report does not describe any account, role, tool or version. The only precondition is that the Steam client is running under a user that can write to the target path. In other words, the attack works only for files that the logged-in user is allowed to change. That is a wide range: your own documents, keys and settings are all fair game.
The proof of concept is an HTML page with two links, which can also be loaded in an iframe so that no user interaction is required. HTML is the language web pages are written in. An iframe is a small window inside a page that loads another page; a page can put a link inside an iframe and the browser may follow it without the visitor clicking anything.
Finding it
The response parameter of the devkit-1/list-shortcuts command is used as a file path, and the client writes to it without restricting the location. The same parameter also causes the file to be overwritten when it already exists. Because the URL scheme is handled by the Steam client, a web page can trigger the command.
This is a classic case of trusting input from outside. The link comes from a web page, which the attacker controls, but Steam treats the path inside it as if it were a safe, internal instruction. The vulnerability class here is a write-what-where condition: the attacker chooses what gets written (the response of the request) and where it gets written (the path in the parameter).
Exploitation
Step 1: Create a file at an arbitrary path
Open the following URL:
steam://devkit-1/list-shortcuts?response=/tmp/testfile
Line by line:
steam://tells the operating system that this link belongs to the Steam client, not to a website.devkit-1/list-shortcutsis the internal command Steam should run. It produces a list of shortcuts.?starts the parameters, the extra instructions for the command.response=/tmp/testfilesays: put the result of the command into the file/tmp/testfile.
The response parameter is set to /tmp/testfile. The Steam client creates /tmp/testfile and writes the response to the list-shortcuts request into it. The file is owned by the user running the client.
Why this step matters: it proves the attacker can choose any location. /tmp is a shared temporary folder on Linux, but the same trick works with any path the user can write to. The attacker does not need to know anything secret to create a new file; they only need a path that does not exist yet.
Step 2: Overwrite an existing file
If the path already exists, the client overwrites it. The report gives the example of an SSH private key:
steam://devkit-1/list-shortcuts?response=/home/ubuntu/.ssh/id_rsa
Line by line:
steam://devkit-1/list-shortcutsis the same command as before.response=/home/ubuntu/.ssh/id_rsapoints at an existing file instead of a new one.
An SSH key is a pair of files used to log in to servers without a password. The private key is the secret half and must never be shared or lost. If it is replaced by something else, the user can no longer log in with it, and the original key is gone unless there is a backup.
After the URL is opened, /home/ubuntu/.ssh/id_rsa contains the response to the list-shortcuts request instead of the key. The attacker does not need to read the key; destroying it is already damage. This is why the report calls the impact a wipe-out as well as an overwrite.
Step 3: Deliver the URL from a web page
The researcher provides an HTML page with two links, one for each of the paths above:
<html>
<head>
<title>Steam client POC</title>
</head>
<body>
<a href="steam://devkit-1/list-shortcuts?response=/tmp/testfile">Create /tmp/testfile</a>
<a href="steam://devkit-1/list-shortcuts?response=/home/ubuntu/.ssh/id_rsa">Overwrite /home/ubuntu/.ssh/id_rsa</a>
</body>
</html>
Line by line:
<html>and</html>wrap the whole page.<head>holds information about the page that is not shown in the body.<title>Steam client POC</title>sets the text shown in the browser tab. POC stands for proof of concept, a small demonstration that the problem is real.<body>holds what the visitor sees.- The first
<a href="...">is a link.hrefis the address the link points to, here thesteam://URL that creates/tmp/testfile. The text between the tags,Create /tmp/testfile, is what the visitor clicks. - The second
<a href="...">is the same idea for the SSH key path, with the visible textOverwrite /home/ubuntu/.ssh/id_rsa.
The page can also be visited with an iframe, so the URL can be opened without any user interaction. That means the URL may be opened without the victim clicking a link. The report does not say which browser or setting allows this; it simply states that the URL may be visited with an iframe.
Root cause
The response parameter of the devkit-1/list-shortcuts command is used as the destination path for the response, with no restriction on the directory, and an existing file at that path is overwritten. The client therefore writes to any path the user can write to, and overwrites existing files.
A useful comparison is a hotel receptionist who accepts any room number a guest gives and hands over the key without checking the booking. The guest is not supposed to choose the room, but nothing stops them. Here the "guest" is the web page and the "room number" is the file path.
Impact
An attacker can overwrite and wipe out files at an arbitrary location, as long as the Steam client is executed by a user that can write to those files. A user's SSH keys, documents and similar files may be deleted as long as the attacker knows the full path to those files. The file is owned by the user running the client, so the write succeeds wherever that user has write permission.
The limit is knowledge of the path. Common locations are predictable, such as home folders and the standard SSH key folder, but a document with a random name in a deep folder is harder to target. The damage is still serious because losing a key or a document can be permanent.
Fix
A fix would need to stop the response parameter from being used as an arbitrary file path, for example by restricting the destination to a directory controlled by the client and refusing to overwrite existing files. In plain terms: the program should decide where its own files live, not the link.
Variants to test
- Other
steam://commands that take a path-like parameter, such as a response file, a log file or a cache directory. A positive result is a file created or overwritten at a path you choose. - The same
responseparameter with a path outside the user's home directory, such as/tmp/testfilein the report. A positive result is a file created at that path. - The same URL loaded in an iframe. A positive result is the file being created without the user clicking a link.
- Paths to files the user cares about, such as SSH keys or documents, when the full path is known. A positive result is the file replaced by the response content.
Hunting notes
This kind of bug tends to hide in custom URL scheme handlers and in internal commands that accept a file path as a parameter. During recon, look for documentation or strings that mention a response, output, log or path parameter in a URL scheme, and for commands that write data to disk. Recon means the early exploration phase, where you look around a program and its links before trying anything.
The researcher showed creation of a new file, overwrite of an existing file and noted that the URL may also be visited with an iframe, and named the files a user could lose, such as SSH keys and documents.
Glossary
- URL scheme: the first part of a link, before
://, such ashttpsorsteam, which tells the computer which program should handle it. - URL scheme handler: a program that registers a scheme so the operating system passes matching links to it.
- Parameter: an extra piece of information attached to a link after a question mark, used to give instructions to the program.
- File path: the full address of a file on a computer, such as
/tmp/testfile. - Overwrite: replace the contents of an existing file with new contents, destroying what was there.
- File owner: the user account the operating system records as responsible for a file; permissions decide what that user can do with it.
- Write permission: the right to change a file or create files in a folder.
- HTML: the language used to write web pages.
- Iframe: a small window inside a web page that loads another page or link.
- Proof of concept (POC): a small demonstration that a problem is real and can be triggered.
- SSH key: a pair of files used to log in to servers without a password; the private key is the secret half.
- Write-what-where condition: a bug where an attacker can choose both the content written and the place it is written to.
- CVSS: a standard score from 0 to 10 that rates the severity of a security issue.
- Bounty: a payment a company gives a researcher for reporting a valid security problem.
- Recon: the early exploration of a program, its links and its behaviour before testing for problems.
- Root cause: the underlying reason a bug exists, as opposed to its visible symptoms.