Skip to content
RCE Disclosed report Advanced

Unauthenticated RCE in Vaultpress

The VaultPress WordPress plugin's API signature check treats the return value of openssl_verify as a boolean, so an error result of -1 is accepted as a valid signature. An attacker who can reach the endpoint and bypass the firewall could forge a signed API call and reach a remote code execution method.

b258ea62bf297b02afa9854 Follow

Originally disclosed on HackerOne

Critical 9.9 View original
  • Disclosed after 3 months

Hitting wordpress instalattion with vaultpress on it with get parameter vaultpress=true attacker is one method away from RCE and that method is validate_api_signature.

In this method we have the following constraints:

  1. Firewall
  2. Usage (recomended) of openssl to validate API call

In case of disabled firewall or its bypass ( easy on many configurations, specially the ones behind proxy/balancer servers ) then in case of usage of openssl to verify the signature we have easy bypass because unsafe usage of openssl_verify PHP function.

if ( $this->can_use_openssl() ) {
			
			$sslsig = '';
			if ( isset( $post['sslsig'] ) ) {
				$sslsig = $post['sslsig'];
				unset( $post['sslsig'] );
			}
			if ( openssl_verify( serialize( array( 'uri' => $uri, 'post' => $post ) ), base64_decode( $sslsig ), $this->get_option( 'public_key' ) ) ) {
				return true;
			} else {
				$__vp_validate_error = array( 'error' => 'invalid_signed_data' );
				return false;
			}
		}

This function openssl_verify have 3 possible values as result value:

  • int(1) success
  • int(0) failure to verify
  • int(-1) error

but we all know that

if (-1) {echo "Hi RCE";}

will print Hi RCE

Proposed fix:

if ( openssl_verify( serialize( array( 'uri' => $uri, 'post' => $post ) ), base64_decode( $sslsig ), $this->get_option( 'public_key' ) ) ===1 ) {
				return true;
			} else {
				$__vp_validate_error = array( 'error' => 'invalid_signed_data' );
				return false;
			}

In order to get the idea how to cause openssl_verify to return -1all you need is to provide valid signature towards public key from different type. Check the uploaded files and execute them in the CMD in the following order:

php genkey1.php
php genkey2.php
php PoC.php

The original report as published on HackerOne, by b258ea62bf297b02afa9854. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code used the integer return of openssl_verify in a loose boolean context instead of comparing it strictly to 1, so the error value -1 passed the check.

Impact

An attacker could bypass signature validation and reach a remote code execution method, but only if the firewall is disabled or bypassed.

What the attacker needed

VaultPress plugin installed; Firewall disabled or bypassed; Network access to the endpoint

The fix

The check should be fixed by comparing the openssl_verify result strictly to 1 so that an error value is rejected.

How it was found

  1. Reach the WordPress installation with the vaultpress parameter set to true.
  2. Ensure the firewall is disabled or bypassed, for example behind a proxy or balancer.
  3. Send a request whose signature is valid for a different key type so openssl_verify returns an error.
  4. Run the provided key generation and proof-of-concept scripts in order to demonstrate the bypass.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A signature check is meant to prove a request really came from a trusted party. Here the check asks a PHP function whether a signature is valid, and that function can answer 'yes', 'no', or 'error'. The code only tested whether the answer was truthy, and in PHP the error value counts as true, so a broken signature was treated as a good one.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by b258ea62bf297b02afa9854

View all

8 more disclosed reports, best first.

More from Automattic

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.