Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: https://github.com/siyuan-note/siyuan/security/advisories/GHSA-3g9h-9hp4-654v

Daniel1048a2bc38d0
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index f35be5704d..aedc7c0380 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -781,6 +781,11 @@ func serveWebSocket(ginServer *gin.Engine) {
util.WebSocketServer.HandleMessage(func(s *melody.Session, msg []byte) {
start := time.Now()
logging.LogTracef("request [%s]", shortReqMsg(msg))
+
+ if util.IsAuthSession(s) {
+ return
+ }
+
request := map[string]interface{}{}
if err := gulu.JSON.UnmarshalJSON(msg, &request); err != nil {
result := util.NewResult()
diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go
index a08ea68f7b..0663c6101c 100644
--- a/kernel/util/websocket.go
+++ b/kernel/util/websocket.go
@@ -114,7 +114,7 @@ func AddPushChan(session *melody.Session) {
typ := session.Request.URL.Query().Get("type")
session.Set("type", typ)
- if "auth" == id {
+ if IsAuthSession(session) {
if appSessions, ok := authSessions.Load(appID); !ok {
appSess := &sync.Map{}
appSess.Store(id, session)
@@ -133,6 +133,16 @@ func AddPushChan(session *melody.Session) {
}
}
+func IsAuthSession(session *melody.Session) bool {
+ id, _ := session.Get("id")
+ if "auth" == id {
+ return true
+ }
+
+ id = session.Request.URL.Query().Get("id")
+ return "auth" == id
+}
+
func RemovePushChan(session *melody.Session) {
app, _ := session.Get("app")
id, _ := session.Get("id")
@@ -141,7 +151,7 @@ func RemovePushChan(session *melody.Session) {
return
}
- if "auth" == id {
+ if IsAuthSession(session) {
appSess, _ := authSessions.Load(app)
if nil != appSess {
appSessions := appSess.(*sync.Map)