I'm modifying the search module of prestashop in order to be able to search strings containing dots : .
Prestashop uses its own sanitize functions against mysql injection vulnerability (yeah...) and uses a list of characters (almost entierly copied from Drupal search module) to filter:


So here, I just removed the \x{2e} char (corresponding to the .) to make it work.
I assume it was here for a good reason (or not), so I am basically making the prestashop less safe ?

Prestashop's search class source code

  • Prestashop's approach is what Marcus Ranum has called "enumerating badness." It is in general not secure because of the difficulty of being sure you've identified all the badness. As Abe Miessler says in his answer, you get protection against SQL injection by using parameterized queries. (Probably you don't want to tear into the guts of Prestashop to fix this, but you should at least worry about it a bit.)
    – Bob Brown
    Dec 2, 2014 at 10:16
  • 1
    Well, just by getting a bit into prestashop's code gives me pimples... I am fully aware of it. Yet, at least in France, it is the most used ecommerce solution (by 48%). So it is very commonly required for our customers... As a developer, be sure I'm looking for other cleaner solutions to propose
    – Brewal
    Dec 2, 2014 at 10:28

1 Answer 1


I don't think it will open you up to SQL Injection.

That said - while I am not an expert on Prestashop or it's code base, I got the impression that the sanitize function you linked to is not just used to prevent SQL Injection, but multiple kinds of vulnerabilities (notice the call to strip_tags on line 102). If this is true you should be careful that you aren't opening yourself up for other types of vulnerabilities. The first one that comes to mind by allowing . is directory traversal.

Ideally, allowing the . character as input wouldn't open you up to this type of attack, but without doing a security audit of the code I can't say for sure.

Also - if they aren't using parameterization for protection from SQL Injection I would be very concerned about the overall security of their code. The concept of rolling your own SQL Injection protection has been discussed at great length in the security community and the consensus is that it is almost never a good idea.

So in summary - I don't think the . opens you up to SQL Injection, watch out for other vulnerabilities and be wary of Pretashop's approach to security.

  • Thanks. The string is only used for sql query. That is why I first focused only on sql injection. I am sadly aware of prestashop's security issues or bad coding...
    – Brewal
    Dec 1, 2014 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .