| 제목 | YiSha YiShaAdmin ba04d5072885447553e372bb87e372b55a90780c SQL Injection |
|---|
| 설명 | YiShaAdmin builds paginated SQL queries by concatenating the user-controlled pagination "Sort" value directly into the ORDER BY clause.
Sink: YiSha.Data/YiSha.Data/Extension/DatabasePageExtension.cs (SqlServerPageSql / OraclePageSql / MySqlPageSql): orderBy = " ORDER BY " + sort;
Source: YiSha.Data/YiSha.Data.Repository/Repository.cs — FindList/FindTable pass pagination.Sort (bound from the list request) to the page builder.
Filter: YiSha.Util/YiSha.Util/SecurityHelper.cs — IsSafeSqlParam() is a character blocklist: Regex "[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']". It rejects quotes, parentheses, commas, semicolons and comment characters, blocking classic payloads, but ORDER BY boolean-blind injection does not require any of those characters.
Bypass payload (passes the filter):
CASE WHEN 1=1 THEN id ELSE name END
It is injected into "ORDER BY <payload>", letting an authenticated attacker control the result ordering with an arbitrary boolean condition and read data through an ordering oracle, e.g. "CASE WHEN secret > name THEN name ELSE id END".
Proof of concept (against any paginated admin list endpoint, authenticated):
sort = CASE WHEN 1=1 THEN id ELSE name END -> one ordering
sort = CASE WHEN 1=2 THEN id ELSE name END -> a different ordering
Different orderings confirm the injected condition is evaluated by the database.
Verified with the project's own IsSafeSqlParam filter and DatabasePageExtension ORDER BY logic executed on SQLite: classic payloads (id;DROP, (SELECT 1), id-- -, name') are rejected, while "CASE WHEN ..." passes and controls output ordering; ordering by a secret-dependent expression leaks data.
Impact: Authenticated boolean-blind SQL injection in every paginated list query. Direct exfiltration of arbitrary tables is constrained because the filter blocks subqueries, functions, string literals and stacked/time-based payloads. Severity Medium.
Fix: Do not concatenate Sort into SQL. Validate against a per-entity allowlist of sortable column names and map SortType to a fixed ASC/DESC, or use the ORM typed ordering. |
|---|
| 원천 | ⚠️ https://github.com/liukuo362573/YiShaAdmin/blob/master/YiSha.Data/YiSha.Data/Extension/DatabasePageExtension.cs |
|---|
| 사용자 | canozal (UID 102350) |
|---|
| 제출 | 2026. 10. 22. PM 03:33 (29 날 ago) |
|---|
| 모더레이션 | 2026. 11. 20. PM 08:39 (29 days later) |
|---|
| 상태 | 수락 |
|---|
| VulDB 항목 | 441601 [liukuo362573 YiShaAdmin 까지 ba04d5072885447553e372bb87e372b55a90780c Pagination Sorting DatabasePageExtension.cs SqlServerPageSql/OraclePageSql/MySqlPageSql/ sort SQL 주입] |
|---|
| 포인트들 | 20 |
|---|