You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can the issue be reproduced with the default theme (daylight/midnight)?
I was able to reproduce the issue with the default theme
Could the issue be due to extensions?
I've ruled out the possibility that the extension is causing the problem.
Describe the problem
An SQL injection vulnerability has been identified in version 3.1.11 of the Siyuan Note application in the notebook parameter of the POST /api/history/searchHistory endpoint. By sending a payload we can inject an sql query
POC
Steps to Reproduce:
Set up the Siyuan Note application version 3.1.11 in a local environment.
Send the following request to the /api/history/searchHistory endpoint:
Attaching to main-1
main-1 | Using existing group: siyuan (1000)
main-1 | Using existing user siyuan (PUID: 1000, PGID: 1000)
main-1 | Adjusting ownership of /opt/siyuan, /home/siyuan/, and /siyuan/workspace/
main-1 | Starting Siyuan with UID:1000 and GID:1000 in workspace /siyuan/workspace/
main-1 | I 2024/11/06 09:42:46 working.go:147:
main-1 | ___ ___ ___ ___
main-1 | / /\ ___ ___ //\ / /\ //
main-1 | / /:/_ / /\ //| \ :\ / /::\ \ :
main-1 | / /:/ /\ / /:/ | |:| \ :\ / /:/:\ \ :
main-1 | / /:/ /::\ //::\ | |:| ___ \ :\ / /://::\ __:
main-1 | //:/ /:/:\ _/:_ ||:| //\ __:\ //:/ /:/:\ /_/::::::::
main-1 | \ :/://:/ \ :/\ //::::\ \ :\ / /:/ \ :/:// \ :~~/
main-1 | \ ::/ /:/ _::/ ~:\ \ :\ /:/ \ ::/ \ :\ ~~~
main-1 | _/ /:/ //:/ \ :\ \ :/:/ \ :\ \ :
main-1 | //:/ _/ _/ \ ::/ \ :\ \ :
main-1 | _/ _/ _/ _/
main-1 | I 2024/11/06 09:42:46 runtime.go:79: kernel is booting:
main-1 | * ver [3.1.11]
main-1 | * arch [amd64]
main-1 | * os [alpine]
main-1 | * pid [1]
main-1 | * runtime mode [prod]
main-1 | * working directory [/opt/siyuan]
main-1 | * read only [false]
main-1 | * container [docker]
main-1 | * database [ver=20220501]
main-1 | * workspace directory [/siyuan/workspace/]
main-1 | I 2024/11/06 09:42:46 conf.go:130: loaded conf [/siyuan/workspace/conf/conf.json]
main-1 | I 2024/11/06 09:42:46 runtime.go:128: use network proxy [system]
main-1 | I 2024/11/06 09:42:46 serve.go:139: kernel [pid=1] http server [0.0.0.0:6806] is booting
main-1 | I 2024/11/06 09:42:46 conf.go:841: database size [7.65 MB], tree/block count [66/2297]
main-1 | I 2024/11/06 09:42:46 working.go:193: kernel booted
main-1 | I 2024/11/06 09:42:47 box.go:77: auto stat [trees=66, blocks=2297, dataSize=5.16 MB, assetsSize=3.83 MB]
main-1 | W 2024/11/06 09:43:09 history.go:43: sql query [SELECT DISTINCT created FROM histories_fts_case_insensitive WHERE 1=1 AND path LIKE '%/%' orser by 100 -- -/%' AND path LIKE '%.sy' AND CAST(created AS INTEGER) > 1728294189 ORDER BY created DESC LIMIT 32 OFFSET 0] failed: near "orser": syntax error
More information
No response
The text was updated successfully, but these errors were encountered:
TaiPhung217
changed the title
SQL Injection in searchHistory (siyuan version 3.1.11)
SQL Injection Vulnerability in searchHistory (siyuan version 3.1.11)
Nov 6, 2024
Is there an existing issue for this?
Can the issue be reproduced with the default theme (daylight/midnight)?
Could the issue be due to extensions?
Describe the problem
An SQL injection vulnerability has been identified in version 3.1.11 of the Siyuan Note application in the notebook parameter of the
POST /api/history/searchHistory
endpoint. By sending a payload we can inject an sql queryPOC
Steps to Reproduce:
version 3.1.11
in a local environment./api/history/searchHistory
endpoint:The code that caused the vulnerability:
This issue occurs due to chaining when passing notebook parameter directly into sql query, without filter.
file: kernel/model/history.go
Impact:
Expected result
'
Screenshot or screen recording presentation
No response
Version environment
Log file
Attaching to main-1
main-1 | Using existing group: siyuan (1000)
main-1 | Using existing user siyuan (PUID: 1000, PGID: 1000)
main-1 | Adjusting ownership of /opt/siyuan, /home/siyuan/, and /siyuan/workspace/
main-1 | Starting Siyuan with UID:1000 and GID:1000 in workspace /siyuan/workspace/
main-1 | I 2024/11/06 09:42:46 working.go:147:
main-1 | ___ ___ ___ ___
main-1 | / /\ ___ ___ //\ / /\ //
main-1 | / /:/_ / /\ //| \ :\ / /::\ \ :
main-1 | / /:/ /\ / /:/ | |:| \ :\ / /:/:\ \ :
main-1 | / /:/ /::\ //::\ | |:| ___ \ :\ / /:/
/::\ __:/:/ \ :/\ //::::\ \ :\ / /:/ \ :/:// \ :~main-1 | //:/ /:/:\ _/:_ ||:| //\ __:\ //:/ /:/:\ /_/::::::::
main-1 | \ :/:/
~/main-1 | \ ::/ /:/ _::/
~:\ \ :\ /:/ \ ::/ \ :\ ~~~main-1 | _/ /:/ //:/ \ :\ \ :/:/ \ :\ \ :
main-1 | //:/ _/ _/ \ ::/ \ :\ \ :
main-1 | _/ _/ _/ _/
main-1 | I 2024/11/06 09:42:46 runtime.go:79: kernel is booting:
main-1 | * ver [3.1.11]
main-1 | * arch [amd64]
main-1 | * os [alpine]
main-1 | * pid [1]
main-1 | * runtime mode [prod]
main-1 | * working directory [/opt/siyuan]
main-1 | * read only [false]
main-1 | * container [docker]
main-1 | * database [ver=20220501]
main-1 | * workspace directory [/siyuan/workspace/]
main-1 | I 2024/11/06 09:42:46 conf.go:130: loaded conf [/siyuan/workspace/conf/conf.json]
main-1 | I 2024/11/06 09:42:46 runtime.go:128: use network proxy [system]
main-1 | I 2024/11/06 09:42:46 serve.go:139: kernel [pid=1] http server [0.0.0.0:6806] is booting
main-1 | I 2024/11/06 09:42:46 conf.go:841: database size [7.65 MB], tree/block count [66/2297]
main-1 | I 2024/11/06 09:42:46 working.go:193: kernel booted
main-1 | I 2024/11/06 09:42:47 box.go:77: auto stat [trees=66, blocks=2297, dataSize=5.16 MB, assetsSize=3.83 MB]
main-1 | W 2024/11/06 09:43:09 history.go:43: sql query [SELECT DISTINCT created FROM histories_fts_case_insensitive WHERE 1=1 AND path LIKE '%/%' orser by 100 -- -/%' AND path LIKE '%.sy' AND CAST(created AS INTEGER) > 1728294189 ORDER BY created DESC LIMIT 32 OFFSET 0] failed: near "orser": syntax error
More information
No response
The text was updated successfully, but these errors were encountered: