1

Currently Wordpress seems to be scoring bad on SQL Injection through User Agent. The testing tools that are being used return that it's insecure because it returns HTTP responses (errors) when you manipulate the User Agent (example via https://medium.com/@frostnull/sql-injection-through-user-agent-44a1150f6888 ).

Example return: enter image description here

To combat this the data should be strictly validated to prevent response header injection attacks. In most situations, it will be appropriate to allow only short alphanumeric strings to be copied into headers, and any other input should be rejected. At a minimum, input containing any characters with ASCII codes less than 0x20 should be rejected.

My question is:

  • how real is this security problem?
  • how to score better on it?
  • if plugins are not available, can we assume that coding is needed?

Kr, Vincent

11
  • What makes you think WP is vulnerable to this attack? Never is WP mentioned in the article, it looks more like they are testing against some custom code.
    – kero
    Commented Jan 6, 2021 at 15:18
  • The security tools that an auditor is running flagged our WP instance as vulnerable because of the http error output which is showing in the example. Commented Jan 6, 2021 at 15:28
  • 1
    No error has taken place though, this is a warning about a theoretical attack vector from a generic scan. It is only an error in the sense that they consider it to be a higher priority item in their test suite
    – Tom J Nowell
    Commented Jan 6, 2021 at 15:29
  • @TomJNowell correct but now I will have to prove to them that WP is secure or to stop showing any errors. But I am clueless on both. Commented Jan 6, 2021 at 15:33
  • 1
    @FastSolutions OWASP isn't mentioned in your question and is unrelated. If you have a new question, create a new question for it, don't reuse the comments of this question. This is a Q&A site not a forum thread
    – Tom J Nowell
    Commented Jan 6, 2021 at 16:18

1 Answer 1

3

how real is this security problem?

You shouldn't be concerned by this unless you're retrieving user agents and making raw SQL queries. I recommend you avoid both of those, but for unrelated reasons.

If you are piping raw user agents into raw SQL queries, and you would know if you were doing this as it's a very specific thing to do, stop that.

Think of it as as a house inspector saying your house could be vulnerable to having a horde of rabid bats smash your awning, and they tested this by flying a bat and noticing it was not stopped by security measures. Does that mean you install anti-bat devices? Does your house even have an awning? Is a bat swarm high on your list of security concerns?

Tools like this are usually non-CMS specific, and may raise the alarm on issues that don't apply, or are purely theoretical.

how to score better on it?

You didn't mention the testing tools, it looks like they want you to maintain a whitelist of user agents and then only return HTML if your user agent matches. I wouldn't recommend this, as it's a big maintenance burden to protect against a theoretical attack you aren't vulnerable to.

if plugins are not available, can we assume that coding is needed?

I would be deeply suspicious of any plugins that try to solve this for you, although recommendations are off topic here anyway.

If you wanted to actually implement this, do it at the Apache/Nginx level.


My recommendation though? Ignore this. They've devised a solution to a theoretical attack, then wrote a test to see if you implemented it, then declared that you're vulnerable because you didn't use their specific solution to a problem that won't affect you unless you explicitly added the problem in.

Nobody can tell you that your site is secure, that isn't how security works, and nobody can say you are or are not vulnerable to a type of attack without actually running an exploit. Take the results of this scan with a hefty pinch of salt.

2
  • They came back that following measures will need to be implemented: cheatsheetseries.owasp.org/cheatsheets/… but am I wrong to say that this is per default implemented in Wordpress? Commented Jan 6, 2021 at 16:07
  • In core yes, in plugins who knows, you would have to ask plugin vendors, a lot of it simply doesn't apply. But that is a brand new question to ask. A comment is not the appropriate place
    – Tom J Nowell
    Commented Jan 6, 2021 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.