← Java / Spring · Contents

JAVA-079 / Intermediate

Using LIMIT ${size} in MyBatis mappers

A03:2021 Injection · CWE-89 · CWE-770

Why is this a problem?

Pagination-value injection and unlimited retrieval.

How to fix it

xml
SELECT * FROM post LIMIT #{size} OFFSET #{offset}   <!-- Verify driver binding support and cap size -->

Further reading