Stored XSS on newsroom.uber.com admin panel / Stream WordPress plugin
The Stream WordPress plugin logged a redirect URL containing a file parameter without sanitising it, so an unauthenticated attacker could inject JavaScript into the admin activity log. When an administrator viewed the log, the script executed with admin privileges, potentially allowing PHP code injection on the server.
- Triaged in 4 days
- Fixed in 2 months
- Paid in 3 months
- Disclosed after 4 months
newsroom.uber.com uses a WordPress plugin called Stream to log user activity. In some cases the logged events aren't sanitized properly and can contain HTML tags and JavaScript. An unauthenticated user can produce such a log message to inject JavaScript in the admin panel. When an administrator views the log, the script would be evaluated with administrator privilegs and can (under normal setup) be further used to inject attacker-supplied PHP code on the server.
#Reproducing# The following command line can be used to inject JavaScript in the log with the curl tool:
curl -v -H 'Referer: /hello?plugin-editor.php&file=aaa%3cscript%3ealert(%27stored%20xss%27);%3c/script%3e' --data 'post-password=foo' 'https://newsroom.uber.com/wp-login.php?action=postpass'
Next, if an administrator clicks the Stream tab in the WordPress Dashboard, an alert box should pop up.
#Details# The Stream plugin hooks many WordPress events to log user activity. In the file connectors/installer.php there is a wp_redirect() hook - the plugin checks every URL redirection to see if it involved the plugin editor. The code, compacted a bit:
public static function callback_wp_redirect( $location ) {
if ( ! preg_match( '#(plugin)-editor.php#', $location, $match ) ) {
return $location;
}
$type = $match[1];
list( $url, $query ) = explode( '?', $location );
$query = wp_parse_args( $query );
$file = $query['file'];
if ( empty( $query['file'] ) ) {
return $location;
}
/* SNIP ... */ elseif ( 'plugin' === $type ) {
global $plugin, $plugins;
$plugin_base = current( explode( '/', $plugin ) );
foreach ( $plugins as $key => $plugin_data ) {
if ( $plugin_base === current( explode( '/', $key ) ) ) {
$name = $plugin_data['Name'];
break;
}
}
}
self::log(
_x(
'Edited %1$s: %2$s',
'Plugin/theme editing. 1: Type (plugin/theme), 2: Plugin/theme name',
'stream'
),
compact( 'type', 'name', 'file' ),null, array( $type . 's' => 'edited' ));
So if there is a redirect to a URL containing the string "plugin-editor.php" with a file query parameter, then the activity is logged. The file query parameter is included in the log entry.
The event is saved in Stream's database table and shown on the main tab of the plugin without sufficient HTML sanitizing.
There are many ways to generate an HTTP redirect in WordPress. The method used in the above example is requesting wp-login.php which, with appropriate arguments, redirects the browser back to the Referer: header's value.
#Impact# The JavaScript stored by an unauthenticated attacker would get executed with administrator privileges, thus having full control over the site contents. Under a normal WordPress setup it could also modify existing PHP files via the plugin or theme editors, leading to server-side compromise.
I tested this on my local test system with the latest WordPress and Stream 1.4.9.
Context
newsroom.uber.com ran WordPress, and like many WordPress installs it carried plugins that extend the dashboard. One of them was Stream, a plugin that records user activity: logins, edits, installs, redirects and similar events, each written to a database table and displayed on a tab in the WordPress Dashboard. The point of Stream is auditing, so administrators are expected to open that tab and read what happened. That makes the tab a trusted place where an administrator looks at data that, in principle, came from many sources, including unauthenticated visitors.
The report concerns the way Stream records one particular event, a redirect to the plugin editor, and the fact that part of the redirected URL ends up in the log without adequate HTML sanitising. The researcher tested against the latest WordPress and Stream 1.4.9 on a local test system.
Setup
No special access is needed on the attacker side. The whole injection is performed by an unauthenticated user with a single HTTP request. The only precondition is that an administrator later opens the Stream tab in the Dashboard. The researcher used curl to send the request and a local WordPress installation with Stream 1.4.9 to observe the result.
Finding it
The researcher's starting observation is that Stream logs events whose content is not always sanitised properly, and that some of those events can contain HTML tags and JavaScript. If an unauthenticated visitor can cause such an event to be written, the payload is stored and later rendered in the admin panel. When an administrator views the log, the script runs with administrator privileges.
The specific event is the plugin editor. Stream hooks many WordPress events, and in connectors/installer.php it registers a wp_redirect() hook. That hook inspects every URL redirection to see whether it involves the plugin editor, and if it does, it writes a log entry containing the file query parameter. Since the file parameter is attacker-influenced in some redirect flows, and the log entry is displayed without sufficient HTML sanitising, the value becomes stored markup in the admin panel.
Exploitation
Step 1: trigger a redirect that carries the payload
WordPress can generate HTTP redirects in many ways. The method used here is a request to wp-login.php which, with the appropriate arguments, redirects the browser back to the value of the Referer header. The researcher puts the payload in that header:
curl -v -H 'Referer: /hello?plugin-editor.php&file=aaa%3cscript%3ealert(%27stored%20xss%27);%3c/script%3e' --data 'post-password=foo' 'https://newsroom.uber.com/wp-login.php?action=postpass'
The Referer value contains the string plugin-editor.php, which is what the Stream hook matches on, followed by a file query parameter. The parameter value is URL-encoded: %3cscript%3e decodes to <script>, %27 to a single quote, and %3c/script%3e to </script>, so the decoded value is aaa<script>alert('stored xss');</script>. The request to wp-login.php with the appropriate arguments makes it redirect back to the Referer value.
Step 2: the plugin logs the event
The redirect passes through Stream's callback_wp_redirect(). The hook first checks whether the location matches the plugin editor:
public static function callback_wp_redirect( $location ) {
if ( ! preg_match( '#(plugin)-editor.php#', $location, $match ) ) {
return $location;
}
$type = $match[1];
list( $url, $query ) = explode( '?', $location );
$query = wp_parse_args( $query );
$file = $query['file'];
if ( empty( $query['file'] ) ) {
return $location;
}
/* SNIP ... */ elseif ( 'plugin' === $type ) {
global $plugin, $plugins;
$plugin_base = current( explode( '/', $plugin ) );
foreach ( $plugins as $key => $plugin_data ) {
if ( $plugin_base === current( explode( '/', $key ) ) ) {
$name = $plugin_data['Name'];
break;
}
}
}
self::log(
_x(
'Edited %1$s: %2$s',
'Plugin/theme editing. 1: Type (plugin/theme), 2: Plugin/theme name',
'stream'
),
compact( 'type', 'name', 'file' ),null, array( $type . 's' => 'edited' ));
The regular expression #(plugin)-editor.php# matches the string in the Referer value, so the hook does not return early. The location is split on ?, the query string is parsed with wp_parse_args(), and the file parameter is read. Because it is not empty, the code proceeds to the plugin branch and finally calls self::log() with compact( 'type', 'name', 'file' ). The file value, which is the attacker's decoded payload, is part of the logged context.
Step 3: the payload is stored and rendered
The event is saved in Stream's database table and shown on the main tab of the plugin without sufficient HTML sanitising. The researcher's next step is simply to have an administrator click the Stream tab in the WordPress Dashboard. At that point an alert box should pop up, which is the proof that the stored script executed in the administrator's browser.
Root cause
The mistake is a missing output encoding step on data that Stream treats as trusted log content. The file query parameter is taken from a redirect location, stored verbatim in the log record, and later rendered in the admin panel without sufficient HTML sanitising. The plugin's own check is only a pattern match on the location string to decide whether to log; it does not validate or encode the file value. Because the redirect can be produced by an unauthenticated request to wp-login.php using the Referer header, the attacker controls the value that ends up in the database.
Impact
The stored JavaScript executes with administrator privileges, which gives the attacker full control over the site contents. Under a normal WordPress setup it can also be used to modify existing PHP files through the plugin or theme editors, which leads to server-side compromise. The attacker needs no account: the log entry is produced by an unauthenticated request. The condition is that an administrator opens the Stream tab and the payload runs in their session.
Fix
The report does not describe a fix or a change made by the vendor. The corrective direction that follows from the root cause is to sanitise or encode the logged values, in particular the file parameter, before they are stored or rendered in the Stream admin panel, so that log content is displayed as text rather than markup.
Variants to test
- Other Stream connectors that log values derived from request data, such as redirects, installs or edits. A positive result is a log entry in the Stream tab that renders attacker-supplied markup when an administrator views it.
- Other WordPress redirect paths that reflect a header or parameter into a location, in the same way
wp-login.phpwithaction=postpassredirects to theReferervalue. A positive result is a redirect whose location contains the payload and reaches a logging hook. - Other plugins that record activity for administrators to review. A positive result is stored markup in an audit view that executes in the administrator's session.
Hunting notes
This kind of bug hides in audit and logging features: activity streams, event logs, dashboards and notification panels that display data originating from unauthenticated requests. During recon, the signals are a WordPress site with an activity-logging plugin, a dashboard tab that shows recent events, and any event type whose content includes a URL, a header value or a query parameter. The researcher showed impact by demonstrating script execution in the administrator's browser and by explaining the escalation path to PHP file modification through the plugin or theme editors,
What happened, in plain words
A website called newsroom.uber.com was built on WordPress. WordPress is a popular system for running websites and blogs; it comes with a control area called the Dashboard where the people who run the site log in to manage it. WordPress can be extended with small add-on programs called plugins, which add features. One of the plugins on this site was called Stream. Stream's job is to keep a record of what happens on the site: who logged in, who edited something, who was redirected somewhere, and so on. It writes each of these events into a database table and shows them on a tab in the Dashboard, so an administrator can open that tab and read the history.
That tab is a place an administrator trusts. They go there to read a log, not to run programs. The problem the researcher found is that Stream copied part of a web address into that log without cleaning it up first. If an ordinary visitor, with no account at all, could make the site write a log entry containing a piece of JavaScript (a small program that runs inside a web browser), then that program would be saved and later shown to the administrator. When the administrator opened the Stream tab, their browser would run the program as if the administrator had written it themselves. That is called stored cross-site scripting, or stored XSS: a script is stored on the server and later executed in someone else's browser.
Because the script runs with the administrator's powers, the attacker could take full control of the site's contents. On a normal WordPress setup it could also be used to change the site's own program files through the built-in editors, which means taking over the server, not just the website. The researcher tested this on a local test system with the latest WordPress and Stream version 1.4.9.
The pieces involved
Before the steps, here are the parts of the picture, explained from scratch.
- WordPress: the software that runs the site and its Dashboard. Administrators log in to the Dashboard with a username and password.
- Plugin: an add-on that adds features to WordPress. Stream is one.
- Stream: the activity log plugin. It records events and displays them on a tab in the Dashboard.
- Administrator: a user with the highest level of permission on the site. They can change content, install plugins and edit files.
- Unauthenticated user: a visitor with no account and no login. Anyone on the internet can be one.
- HTTP request: the message a browser (or a tool) sends to a server to ask for a page or to submit something. A request has a method (such as GET or POST), a URL, some headers and sometimes a body.
- Header: a small labelled field attached to a request or response, carrying extra information. The
Refererheader, for example, tells the server which page the browser came from. - Redirect: when a server answers a request by telling the browser to go somewhere else instead. The answer contains a location, and the browser follows it.
- Query parameter: the part of a URL after the
?, made of name and value pairs such asfile=something. It is a way of passing information in a URL. - URL encoding: a way of writing characters that are not allowed directly in a URL.
%3cmeans<,%3emeans>,%27means a single quote, and so on. The server decodes these back to the real characters when it reads the URL. - HTML: the language web pages are written in. Tags such as
<script>are instructions to the browser. - JavaScript: a programming language that runs inside the browser. A
<script>tag in a page tells the browser to run the JavaScript inside it. - Sanitising (or encoding): cleaning data before showing it, so that characters like
<are displayed as text instead of being treated as instructions. Without this step, data can become live markup. - Stored XSS: a vulnerability where an attacker gets a script saved on the server, and the script later runs in another user's browser when that user views the saved data.
- curl: a command-line tool for sending HTTP requests by hand. It lets you set headers, send a body and see the response.
- Database table: the structured storage inside a database where records are kept. Stream keeps its log entries in one.
- PHP: the programming language WordPress and its plugins are written in.
Setup
The attacker needs nothing special: no account, no password, no access to the server. The whole injection is done by an unauthenticated visitor with a single HTTP request. The only thing that has to happen afterwards is that an administrator opens the Stream tab in the Dashboard. The researcher used curl to send the request and a local WordPress installation with Stream 1.4.9 to watch the result.
Finding it
The researcher's starting observation is that Stream logs events whose content is not always cleaned up properly, and that some of those events can contain HTML tags and JavaScript. If a visitor with no account can cause such an event to be written, the payload is stored and later shown in the admin panel. When an administrator views the log, the script runs with administrator privileges.
The specific event is the plugin editor. Stream listens to many WordPress events, and in a file called connectors/installer.php it registers a hook on wp_redirect(). A hook is a way for a plugin to say "when this thing happens in WordPress, run my code". This hook inspects every URL redirection to see whether it involves the plugin editor, and if it does, it writes a log entry containing the file query parameter. Since the file parameter can be influenced by whoever triggers the redirect, and the log entry is displayed without sufficient HTML sanitising, the value becomes live markup in the admin panel.
Exploitation
Step 1: trigger a redirect that carries the payload
WordPress can produce HTTP redirects in many ways. The method used here is a request to wp-login.php which, with the appropriate arguments, redirects the browser back to the value of the Referer header. In other words, the site is told "go back to where I came from", and the attacker decides what "where I came from" says. The researcher puts the payload in that header:
curl -v -H 'Referer: /hello?plugin-editor.php&file=aaa%3cscript%3ealert(%27stored%20xss%27);%3c/script%3e' --data 'post-password=foo' 'https://newsroom.uber.com/wp-login.php?action=postpass'
Line by line:
curlis the tool sending the request.-vmeans verbose: curl prints the details of the request and response so the researcher can see what happened.-H 'Referer: ...'sets theRefererheader to the value in the quotes. That value is a fake address starting with/hello?and containingplugin-editor.phpand afileparameter.--data 'post-password=foo'sends a body with the request, containing the fieldpost-passwordset tofoo.- The final argument is the URL being requested:
https://newsroom.uber.com/wp-login.php?action=postpass. Theaction=postpassparameter tells WordPress which action to perform.
The Referer value contains the string plugin-editor.php, which is what the Stream hook matches on, followed by a file query parameter. The parameter value is URL-encoded: %3cscript%3e decodes to <script>, %27 to a single quote, and %3c/script%3e to </script>, so the decoded value is aaa<script>alert('stored xss');</script>. The request to wp-login.php with the appropriate arguments makes it redirect back to the Referer value. The alert('stored xss') part is a harmless demonstration: it makes the browser show a pop-up box with that text, which proves a script ran.
Why this step: the attacker needs the site to produce a redirect whose location contains the payload, because that is the event Stream will log. The Referer header is a convenient place to put it, because this WordPress request redirects back to that header's value.
Step 2: the plugin logs the event
The redirect passes through Stream's callback_wp_redirect(). The hook first checks whether the location matches the plugin editor:
public static function callback_wp_redirect( $location ) {
if ( ! preg_match( '#(plugin)-editor.php#', $location, $match ) ) {
return $location;
}
$type = $match[1];
list( $url, $query ) = explode( '?', $location );
$query = wp_parse_args( $query );
$file = $query['file'];
if ( empty( $query['file'] ) ) {
return $location;
}
/* SNIP ... */ elseif ( 'plugin' === $type ) {
global $plugin, $plugins;
$plugin_base = current( explode( '/', $plugin ) );
foreach ( $plugins as $key => $plugin_data ) {
if ( $plugin_base === current( explode( '/', $key ) ) ) {
$name = $plugin_data['Name'];
break;
}
}
}
self::log(
_x(
'Edited %1$s: %2$s',
'Plugin/theme editing. 1: Type (plugin/theme), 2: Plugin/theme name',
'stream'
),
compact( 'type', 'name', 'file' ),null, array( $type . 's' => 'edited' ));
Line by line:
public static function callback_wp_redirect( $location ) {declares the function that WordPress calls whenever a redirect happens.$locationis the address the browser is being sent to.if ( ! preg_match( '#(plugin)-editor.php#', $location, $match ) ) {uses a regular expression (a pattern matcher) to look for the textplugin-editor.phpinside the location. The!means "if it does not match".return $location;means: if the location is not about the plugin editor, do nothing and let the redirect continue unchanged.$type = $match[1];takes the captured word from the pattern, which isplugin.list( $url, $query ) = explode( '?', $location );splits the location at the?character, putting the part before it in$urland the part after it in$query.$query = wp_parse_args( $query );turns the query string into a list of name and value pairs, so individual parameters can be read.$file = $query['file'];reads thefileparameter. This is the attacker-controlled value.if ( empty( $query['file'] ) ) { return $location; }means: if there is nofileparameter, stop here and do not log.- The
elseif ( 'plugin' === $type ) {block looks up which plugin was being edited, so the log entry can include its name. The/* SNIP ... */marks code left out of the excerpt. self::log( ... )writes the log entry. The first argument is a translatable message template,Edited %1$s: %2$s, where the placeholders are filled with the type and the name.compact( 'type', 'name', 'file' )builds the data to log from those three variables. This is the crucial part:filegoes into the log as it is, with no cleaning.null, array( $type . 's' => 'edited' )adds extra information about the event category.
The regular expression #(plugin)-editor.php# matches the string in the Referer value, so the hook does not return early. The location is split on ?, the query string is parsed with wp_parse_args(), and the file parameter is read. Because it is not empty, the code proceeds to the plugin branch and finally calls self::log() with compact( 'type', 'name', 'file' ). The file value, which is the attacker's decoded payload, is part of the logged context.
Why this step matters: the plugin's only check is a pattern match to decide whether to log. It never checks whether the file value is safe, and it never encodes it. So the payload travels from the attacker's header, through the redirect, into the database, unchanged.
Step 3: the payload is stored and rendered
The event is saved in Stream's database table and shown on the main tab of the plugin without sufficient HTML sanitising. The researcher's next step is simply to have an administrator click the Stream tab in the WordPress Dashboard. At that point an alert box should pop up, which is the proof that the stored script executed in the administrator's browser.
Why this step: the attacker cannot run anything in the administrator's browser directly. They rely on the administrator doing the ordinary thing administrators do, opening the log. The stored script then runs in the administrator's session, which is what makes this a stored XSS rather than a one-off trick.
Root cause
The mistake is a missing output encoding step on data that Stream treats as trusted log content. The file query parameter is taken from a redirect location, stored verbatim in the log record, and later rendered in the admin panel without sufficient HTML sanitising. The plugin's own check is only a pattern match on the location string to decide whether to log; it does not validate or encode the file value. Because the redirect can be produced by an unauthenticated request to wp-login.php using the Referer header, the attacker controls the value that ends up in the database.
A simple comparison: it is like a receptionist writing down the name of every visitor on a noticeboard, exactly as the visitor says it, and the noticeboard being read by the manager. If a visitor says their name is a sentence that tells the manager to hand over the keys, the receptionist writes that sentence down and the manager reads it as an instruction.
Impact
The stored JavaScript executes with administrator privileges, which gives the attacker full control over the site contents. Under a normal WordPress setup it can also be used to modify existing PHP files through the plugin or theme editors, which leads to server-side compromise. The attacker needs no account: the log entry is produced by an unauthenticated request. The condition is that an administrator opens the Stream tab and the payload runs in their session.
Fix
The report does not describe a fix or a change made by the vendor. The corrective direction that follows from the root cause is to sanitise or encode the logged values, in particular the file parameter, before they are stored or rendered in the Stream admin panel, so that log content is displayed as text rather than markup.
Variants to test
- Other Stream connectors that log values derived from request data, such as redirects, installs or edits. A positive result is a log entry in the Stream tab that renders attacker-supplied markup when an administrator views it.
- Other WordPress redirect paths that reflect a header or parameter into a location, in the same way
wp-login.phpwithaction=postpassredirects to theReferervalue. A positive result is a redirect whose location contains the payload and reaches a logging hook. - Other plugins that record activity for administrators to review. A positive result is stored markup in an audit view that executes in the administrator's session.
Hunting notes
This kind of bug hides in audit and logging features: activity streams, event logs, dashboards and notification panels that display data originating from unauthenticated requests. During recon, the signals are a WordPress site with an activity-logging plugin, a dashboard tab that shows recent events, and any event type whose content includes a URL, a header value or a query parameter. The researcher showed impact by demonstrating script execution in the administrator's browser and by explaining the escalation path to PHP file modification through the plugin or theme editors,
Glossary
- WordPress: the software that runs a website and its admin Dashboard.
- Dashboard: the password-protected control area where administrators manage a WordPress site.
- Plugin: an add-on program that adds features to WordPress.
- Stream: the WordPress plugin that records site activity and shows it on a Dashboard tab.
- Administrator: a user with the highest permissions on the site.
- HTTP request: the message a browser or tool sends to a server to ask for something.
- Header: a labelled field attached to a request or response carrying extra information.
- Referer header: a header that tells the server which page the browser came from.
- Redirect: a server answer that tells the browser to go to a different address.
- Query parameter: a name and value pair after the
?in a URL. - URL encoding: writing special characters in a URL as
%codes, such as%3cfor<. - HTML: the language web pages are written in, using tags.
- Sanitising / encoding: cleaning data before display so it is shown as text, not treated as instructions.
- Stored XSS: a vulnerability where a script is saved on the server and later runs in another user's browser.
- Database table: structured storage inside a database where records are kept.
- Hook: a way for a plugin to run its own code when a particular event happens in WordPress.
- Regular expression: a pattern used to search for text.
wp_redirect(): the WordPress function that performs a redirect.wp-login.php: the WordPress login script, which also handles some other actions such aspostpass.action=postpass: the parameter that tellswp-login.phpto handle a password-protected page submission.self::log(): the Stream function that writes an event to the log.compact(): a PHP function that builds an array from named variables.- Self-XSS: a script that only runs in the browser of the person who injected it, with no effect on anyone else.