Project

General

Profile

Actions

Feature #35073

closed

Escape values in LIKE statements to prevent injection of placeholders (_ or %)

Added by Jens Krämer over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Database
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

While not technically a security risk, LIKE queries with lots of placeholders can result in high database load, very slow query execution and therefore are a possible vector for denial of service attacks. Further, escaping the wildcard characters in actual query values now allows to actually search for values containing these characters.

The attached patches, which have been extracted from Planio are:

  • The first patch removes '%' signs from query strings used in the search test case. These did not matter until now since they just resulted in queries like field LIKE '%%value%%', but now would be looking for a value with literal percent signs. Tests pass before and after that change.
  • Patches 2-4 add sanitize_sql_like calls to the various places where we currrently generate sql LIKE statements. Corresponding tests are included.
  • The last patch is just a cosmetic change that replaces a .send with a direct call since the called method is now public.

Files


Related issues

Related to Redmine - Feature #13347: Filtering by issue subject with wildcardNew

Actions
Related to Redmine - Defect #19786: '%' and '_' are treated as SQL wildcards in issue filterClosed

Actions
Blocks Redmine - Feature #35764: Multiple search terms in the "contains" operator of text filtersClosedMarius BĂLTEANU

Actions
Actions

Also available in: Atom PDF