🔒 Fix JPQL injection vulnerability in findByFilter methods - #191
Conversation
Adds an allowlist regex check for the `property` parameter in `findByFilter` methods before concatenating it into a JPQL query string to prevent arbitrary JPQL injection. Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What:
Fixed a JPQL injection vulnerability present in the
findByFilter(String property, String value)method across 8 different JSF backing bean controllers:OpdPreBillController.javaBillController.javaOpdBatchBillCancellationController.javaOpdTabPreBillController.javaCollectingCentreBillController.javaOpticianRepairBillController.javaOpdBillController.javaOpdOrderController.javaThe
findByFiltermethod constructed a JPQL query using direct string concatenation:String sql = "Select b From Bill b where b.retired=false and upper(b." + property + ") like :val";Since column/property names cannot be parameterized in JPQL, an attacker who could control the
propertyargument (e.g., via manipulating request parameters in the UI) could inject arbitrary JPQL syntax. This could potentially allow them to bypass security controls, exfiltrate data, or cause Denial of Service by constructing expensive queries.🛡️ Solution:
Added a strict allowlist regex validation check at the beginning of the
findByFiltermethod in all affected controllers.If the
propertystring contains any characters other than alphanumeric characters, underscores, or dots (which are valid for property traversal likepatient.person.name), the method immediately returnsfalsewithout executing the query, safely mitigating the injection risk.PR created automatically by Jules for task 16725718353099065624 started by @manupawickramasinghe