Now a days in most of wordpress sites are being hacked due to lack of security, today I came with new topic related to wordpress security, here we discuss in detail about issues need to fix to avoid hacking. Let’s see 5 top WordPress site more vulnerable need to fix.
These Hacks Causes WordPress site more vulnerable
1. Os command injection
2. Eval injection
3. Sql injection
4. Use of a Broken or Risky Cryptographic Algorithm.
5. Cross site scripting issue.
1. OS command Injection:
Os command injection carries different meaning for different people, for someone it only refers that an attacker can injects the separators into arguments for an application controlled program that is being invoked. Let’s check small code example found in wordpress plugin, then how we can fix this error now.
Here in the above code $out=’$command’; which is a causing WordPress site more vulnerable,So we need to escape the output to avoid hacking, now let’s check below code how to fix this issue.
Here tag_escape() in wordpress , removes all characters other than a-zA-Z0-9_:, the set of valid HTML tag characters. Transforms letters to lowercase. String cleaned and escaped for output as an HTML tag.
2. Eval Injection:
In this kind of issues contains user supplied inputs, if this inputs can be modified by attacker, an arbitrary code can be executed in the server. So to avoid this issue we need to escape the output. Let’s check the code example to fix this issue.
In the above code preg_replace() method has three arguments , where second argument contains data from user inputs. Now fix this issue using stripslashes to escape the output .
stripslashes is used to Un-quotes a quoted string, here second argument treats as php code which come from incoming http request from the variable replace.
3. SQL Injection:
Here we use sql queries to retrieve data from the database, in this process we forget to escape the queries. if the query is not escaped then an attacker will pass the query string using http request to the server, when that query executes in the server , attacker can access the database and modify the data. To avoid these sql injections we had esc_sql() in wordpress before we pass the query we can escape the query using this method.
Now let’s check below code how to use esc_sql()
4. Use of a Broken or Risky Cryptography Algorithm:
In wordpress some of the plugins are not using good hashing techniques,
Recently Md5 cryptographic algorithm also are not up to the mark, attacker can break the algorithm ,so check below code using md5
In the above code md5 algorithm is used to encrypt the serialize arguments.We can also use sha256 algorithm instead of Md5 algorithm. Let’s check below code example using sha256 algorithm.
5. Cross site scripting:
Here in the wordpress we had pre-defined output escaping functions; let’s check some of the escaping functions below.
Most of the plugins are not taking care in output escaping, these may cause an attacker can break the code, so check the code example, how to use these function in wordpress.
In the above code value attribute is displaying the user data, so here there is possible WordPress site more vulnerable for being hacked ,in this case we need to use esc_attr() to escape the out
Let’s check the code below for reference.
If the data is directly displaying in the html we can use the code as below
All these five issues need to be fixed for better security in wordpress websites; it will protect your site from attackers.
Thanks for reading this article. For any queries please use comment system