I have a wordpress plugin that helps create an organization chart/tree and then generates a URL where the chart is available to be viewed by the public?
Inside the plugin's view in WordPress dashboard. After we create a chart, we click generate URL button to generate URL. The URL generated is: wordpressExampleApp.com/{key}
. Whenever a request comes we grab the key and check if it's the same as our db. The function for key validation is like this:
public function does_url_have_valid_key() {
return isset( $_GET['key'] ) && ( empty( $_GET['key'] ) || $_GET['key'] === $this->key() );
}
Is there any security vulnerability like direct object access
or injection
that this implementation is exposed to? I mean we never sanitized what's passed in the get request and directly check it, I have been asked to do a security vulnerability audit for this implementation. I'm learning securing applications so my question may be missing details, please let me know if you need any information to be added to the question.
Note: the key is generated using the wp_generate_password function and the key function definition is:
public function regenerate_key() {
update_option( self::OPTION_NAME, wp_generate_password( 8 ) );
}
public function key() {
return get_option( self::OPTION_NAME ) ?: 'secret';
}