BISHENG: SQL Injection in the ORDER BY Clause of the Knowledge Space File Listing
An authenticated user with read access to a knowledge space injects SQL into the file listing through the order_field and order_sort parameters and reads the entire application database.
Advisory ID: TP-2026-136
Product: BISHENG (open-source platform for LLM applications and enterprise knowledge bases)
Vulnerability type: SQL injection in the ORDER BY clause (CWE-89)
CVE: not requested
CVSS 3.1: 8.1 (High) · CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N
Vendor advisory: GHSA-hhmh-3fj8-f53v (closed by the vendor without publication)
Affected versions: up to and including v2.6.0-fix2 (verified live: v2.5.0, verified in source: v2.6.0-fix2)
Fixed in: v3.0.0
Reported: 10 June 2026
Summary
BISHENG is an open-source platform for LLM applications; users store files in knowledge spaces, which assistants and workflows use as a knowledge source. The file listing of a knowledge space accepts the query parameters order_field and order_sort and places both into the ORDER BY clause of the database query without any check. There is no allow list for the sort column or the sort direction, and the backend returns the database error message in the HTTP response. An authenticated user with read access to one knowledge space reads the entire MySQL database of the application this way, including the password hashes of all accounts.
Root cause
Line numbers refer to v2.6.0-fix2. SpaceFileDao.order_field_text appends order_field and order_sort to the sort expression with an f-string (src/backend/bisheng/knowledge/domain/models/knowledge_space_file.py:283), and the file_type branch also inserts order_sort unchanged (src/backend/bisheng/knowledge/domain/models/knowledge_space_file.py:276-280).
The callers pass the result through text() straight into order_by (src/backend/bisheng/knowledge/domain/models/knowledge_space_file.py:234, src/backend/bisheng/knowledge/domain/models/knowledge_space_file.py:239, src/backend/bisheng/knowledge/domain/models/knowledge_file.py:538).
Both values are query parameters of type str on the endpoints GET /api/v1/knowledge/space/{space_id}/children and GET /api/v1/knowledge/space/{space_id}/search (src/backend/bisheng/knowledge/api/endpoints/knowledge_space.py:278-279, src/backend/bisheng/knowledge/api/endpoints/knowledge_space.py:315-316).
The neighbouring branch of the same function orders by a fixed column reference (src/backend/bisheng/knowledge/domain/models/knowledge_file.py:539-540); order_field and order_sort are not bound to known values in that way.
The only gate is _require_read_permission, which requires the view_space permission (src/backend/bisheng/knowledge/domain/services/knowledge_space_service.py:1308-1315, called at src/backend/bisheng/knowledge/domain/services/knowledge_space_service.py:2699); in the test an account without administrator rights held it on a released public space.
Proof of Concept
GET /api/v1/knowledge/space/<space_id>/children?order_field=extractvalue(1,concat(0x7e,version())) HTTP/1.1
Cookie: access_token_cookie=<token of an account with read access>
HTTP/1.1 500
... XPATH syntax error: '~8.0.46' ...
order_field becomes the sort expression, MySQL evaluates extractvalue and reports the result of the embedded query as an XPath error, which the backend returns in the response. Verified on v2.5.0 in the default configuration: an account with the Viewer role used the same technique to read the list of 70 tables and the administrator's password hash from the user table.
Impact
- Read access to the entire application database for every authenticated account with read access to a knowledge space.
- Password hashes of all users, administrators included, are exposed and open to offline attack.
- With a cracked administrator hash the attacker logs in as administrator and changes data and settings of the platform.
- Data of other tenants is readable, because the injected subquery is not bound to the tenant filter of the file listing.
References
Is Something Like This in Your Software?
Our team found this vulnerability during its work. Have your applications tested by the same specialists, with a penetration test from turingpoint.
