← Java / Spring · Contents

JAVA-005 / Intermediate

MyBatis ${} in LIKE searches

A03:2021 Injection · CWE-89 SQL Injection

Why is this a problem?

'%${kw}%' causes both injection and wildcard abuse.

How to fix it

xml
WHERE title LIKE CONCAT('%', #{keyword}, '%')

Further reading