# CVE-2019-1698
- Check the diff code betwween ver has vuln and ver of code with fix vuln:
**Code reference 1:** <https://plugins.trac.wordpress.org/changeset/3040809/notificationx/trunk/includes/Core/Rest/Analytics.php>

**Code reference 2:** <https://plugins.trac.wordpress.org/changeset/3040809/notificationx/trunk/includes/Core/Database.php>

Therefore, the following file is relevant to this CVE:
```
wp-content/plugins/notificationx/includes/Core/Rest/Analytics.php
```
Now, we will check the file might have vuln code:

Focus on the `insert_analytics()` function:

It receives the `$request` (coming from the user) and extracts the `type` parameter.
Then, this value is then passed to the `CoreAnalytics::get_instance()->insert_analytics()` function:

To trigger this code, we can notice the mapped route (from the `Analytics` class, inside the `register_routes()` function):
```
$this->namespace . '/' . $this->rest_base
```
And the constructor for the `Analytics` class reveals the values for the `namespace` and `rest_base` variables:
```
public function __construct() {
$this->namespace = 'notificationx/v1';
$this->rest_base = 'analytics';
add_action('rest_api_init', [$this, 'register_routes']);
}
```
So, the relevant (vulnerable) code that accepts the user-supplied `type` parameter, can be reached via the following route:
```
notificationx/v1/analytics
```
But what's the method for exploiting and where is the SQL query for injection?
Since the user-supplied `type` parameter is passed to:
```
CoreAnalytics::get_instance()->insert_analytics( absint( $params['nx_id'] ), $type );
```
Locating this function:

Let's check this function code in the highlighted file:
`wp-content/plugins/notificationx/includes/Core/Analytics.php`**:**

If you are thinking that it the vulnerability lies in the `increment_count()` function, then you are absolutely on the right track!
Here's the `increment_count` function (and it has the `$type` parameter coming from the user):

This function in-turn calls `update_analytics()` function. Let's address for it:


[4.0K] /data/pocs/4d79dd15d03fd0324a482246bf00e2bc4a04a8c8
└── [2.9K] README.md
0 directories, 1 file