Skip to content

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

:lock: Treat publish hidden as unlisted instead of a confidentiality boundary https://github.com/siyuan-note/siyuan/security/advisories/GHSA-wqv8-gjg9-hcg8

Daniel81ad2ea2b425
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
index 9e562cb84a..4ea22a0c78 100644
--- a/.github/SECURITY.md
+++ b/.github/SECURITY.md
@@ -13,6 +13,7 @@ Some areas we don't consider security vulnerabilities:
* SSRF: SiYuan supports user-configured network proxies and outbound requests to user-specified URLs. Outbound requests initiated by authenticated users through features such as `netImg2LocalAssets`, `netAssets2LocalAssets`, and MCP tools are expected behavior. This exclusion does not apply to unauthenticated access or authentication/authorization bypasses
* Sync storage tampering: SiYuan treats user-configured sync storage and principals with write access to the sync repository as trusted. Data loss, rollback, or sync corruption caused by a malicious or compromised storage operator or a principal with write access is outside the security boundary. This exclusion does not apply when an attacker can tamper with sync data without storage write access, such as through an authentication/authorization bypass or a transport security failure
* `/public/` unauthenticated access: The `/public/` route serves files without authentication because it is designed for public sharing (https://github.com/siyuan-note/siyuan/issues/8593), and users are responsible for the security of files they place in the `data/public/` directory
+* Publish `visible:false` ("hidden") unlisted semantics: Hiding a notebook or document in publish access (`visible:false`) removes it from the published file tree, but the content remains directly accessible via its ID or link — this is unlisted-style sharing by design, not a confidentiality boundary, and the UI documents it as "Not publicly visible, can be accessed directly". Access control in publish mode is provided by the password and disable levels, which are enforced across content and raw-file APIs; bypasses of those are still in scope. Reports that treat `visible:false` as a confidentiality boundary are not considered vulnerabilities
* Config file encryption: Credentials stored in the workspace config (e.g., cloud login token, sync credentials, AI API keys, and Secrets) are obfuscated with a hardcoded AES key and IV instead of being truly encrypted, because the config must remain readable across devices and reinstallations. An attacker who can read the config file can recover these credentials. The security boundary is access control over the workspace directory and the OS user account
* Opening external links with unvalidated URLs: Handing off arbitrary URLs to the OS with no URL-scheme allowlist is expected behavior because opening external links in the system browser or launching the default handler for custom URI schemes is a common user need; whether the OS-level URI-handler chain is exploitable depends on the user's OS and installed software, outside SiYuan's security boundary. This applies to the Electron main process `shell.openExternal()` at `windowNavigate` and `setWindowOpenHandler` (`app/electron/main.js`), and to the mobile WebView bridges (Android `JSAndroid.openExternal()` / `exportByDefault()` reaching `Intent.ACTION_VIEW` via `openByDefaultBrowser()` in `Utils.java`, HarmonyOS `JSHarmony.openExternal()`, and iOS `webkit.messageHandlers.openLink`)
diff --git a/kernel/api/asset.go b/kernel/api/asset.go
index f4c65a281a..3c942b0783 100644
--- a/kernel/api/asset.go
+++ b/kernel/api/asset.go
@@ -388,7 +388,7 @@ func getFileAnnotation(c *gin.Context) {
}
if model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
- if !model.CheckAbsPathAccessableByPublishAccessForReadOnly(c, assetAbsPath, publishAccess) {
+ if !model.CheckAbsPathAccessableByPublishAccess(c, assetAbsPath, publishAccess) {
ret.Code = http.StatusForbidden
ret.Msg = http.StatusText(http.StatusForbidden)
return
diff --git a/kernel/api/file.go b/kernel/api/file.go
index 7690225fa8..7b42c8e9ad 100644
--- a/kernel/api/file.go
+++ b/kernel/api/file.go
@@ -529,7 +529,7 @@ func getFile(c *gin.Context) {
if model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
- if !model.CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbsPath, publishAccess) {
+ if !model.CheckAbsPathAccessableByPublishAccess(c, fileAbsPath, publishAccess) {
ret.Code = http.StatusForbidden
ret.Msg = http.StatusText(http.StatusForbidden)
c.JSON(http.StatusAccepted, ret)
diff --git a/kernel/api/file_test.go b/kernel/api/file_test.go
index e024027dac..7dd8de8346 100644
--- a/kernel/api/file_test.go
+++ b/kernel/api/file_test.go
@@ -135,9 +135,10 @@ func TestGetFileAdminCanFollowAssetsSymlinkOutsideWorkspace(t *testing.T) {
}
}
-// TestGetFileReaderDeniesHiddenNotebookFile 验证 reader 无法通过原始文件 API 读取
-// 显式隐藏(Visible:false)笔记本下的普通文件与 .sy 文档(security advisory GHSA-8ggq-wq3f-vxrw)。
-func TestGetFileReaderDeniesHiddenNotebookFile(t *testing.T) {
+// TestGetFileReaderCanReadHiddenNotebookFile 验证「仅隐藏」语义:reader 可通过原始文件 API
+// 直接读取显式隐藏(Visible:false)笔记本下的普通文件与 .sy 文档,
+// 隐藏仅控制发布文件树中的列出,不构成访问控制边界。
+func TestGetFileReaderCanReadHiddenNotebookFile(t *testing.T) {
workspaceDir := t.TempDir()
origWorkspaceDir, origDataDir := util.WorkspaceDir, util.DataDir
util.WorkspaceDir = workspaceDir
@@ -175,12 +176,12 @@ func TestGetFileReaderDeniesHiddenNotebookFile(t *testing.T) {
context.Request = request
getFile(context)
- if recorder.Code == http.StatusOK {
- t.Fatalf("reader must not read file [%s] under hidden notebook, got status %d: %s",
+ if recorder.Code != http.StatusOK {
+ t.Fatalf("reader should read file [%s] under hidden notebook, got status %d: %s",
name, recorder.Code, recorder.Body.String())
}
- if strings.Contains(recorder.Body.String(), string(canary)) {
- t.Fatalf("hidden notebook file [%s] leaked to reader: %s", name, recorder.Body.String())
+ if !strings.Contains(recorder.Body.String(), string(canary)) {
+ t.Fatalf("hidden notebook file [%s] content missing: %s", name, recorder.Body.String())
}
}
}
diff --git a/kernel/model/publish_access.go b/kernel/model/publish_access.go
index 81f8e9314a..3f028b4849 100644
--- a/kernel/model/publish_access.go
+++ b/kernel/model/publish_access.go
@@ -491,29 +491,6 @@ func assetPathFromDataRelativePath(relPath string) (assetPath, boxID string, ok
}
func CheckAbsPathAccessableByPublishAccess(c *gin.Context, absPath string, publishAccess PublishAccess) bool {
- return checkAbsPathAccessableByPublishAccess(c, absPath, publishAccess, false)
-}
-
-// CheckAbsPathAccessableByPublishAccessForReadOnly 在只读角色(读者、访客)场景下检查绝对路径的
-// 发布访问权限:在禁用与密码之外,还要求所属笔记本未被显式隐藏(Visible:false)。
-// 用于原始文件通道(getFile 等),只读角色不通过其他内容 API 获取这些路径,
-// 显式隐藏的笔记本应被视为机密边界(security advisory GHSA-8ggq-wq3f-vxrw)。
-func CheckAbsPathAccessableByPublishAccessForReadOnly(c *gin.Context, absPath string, publishAccess PublishAccess) bool {
- return checkAbsPathAccessableByPublishAccess(c, absPath, publishAccess, true)
-}
-
-// CheckNotebookVisibleByPublishAccess 判断笔记本在发布访问配置中是否被显式隐藏:
-// 未配置的笔记本默认可见,与 isNotebookVisibleByPublishAccess(kernel/api/notebook.go)保持一致。
-func CheckNotebookVisibleByPublishAccess(boxID string, publishAccess PublishAccess) bool {
- for _, item := range publishAccess {
- if item.ID == boxID {
- return item.Visible
- }
- }
- return true
-}
-
-func checkAbsPathAccessableByPublishAccess(c *gin.Context, absPath string, publishAccess PublishAccess, enforceNotebookVisible bool) bool {
absPath = filepath.Clean(absPath)
if gulu.File.IsSubPath(util.HistoryDir, absPath) {
@@ -539,9 +516,6 @@ func checkAbsPathAccessableByPublishAccess(c *gin.Context, absPath string, publi
if ast.IsNodeIDPattern(pathParts[0]) {
box := pathParts[0]
- if enforceNotebookVisible && !CheckNotebookVisibleByPublishAccess(box, publishAccess) {
- return false
- }
blockPath := "/" + strings.Join(pathParts[1:], "/")
passwordID, password := GetPathPasswordByPublishAccess(box, blockPath, publishAccess)
publishIgnore := GetDisablePublishAccess(publishAccess)
diff --git a/kernel/model/publish_access_test.go b/kernel/model/publish_access_test.go
index bc0d701877..1f3573f396 100644
--- a/kernel/model/publish_access_test.go
+++ b/kernel/model/publish_access_test.go
@@ -1474,10 +1474,10 @@ func TestFilterAssetContentByPublishAccess(t *testing.T) {
}
}
-// TestCheckAbsPathAccessableByPublishAccessForReadOnly 验证只读角色的原始文件通道
-// 会将显式隐藏(Visible:false)的笔记本视为机密边界(security advisory GHSA-8ggq-wq3f-vxrw),
-// 而基础校验保持原有的未列出但可直接访问语义不变。
-func TestCheckAbsPathAccessableByPublishAccessForReadOnly(t *testing.T) {
+// TestCheckAbsPathAccessableByPublishAccessKeepsHiddenNotebookAccessible 验证原始文件通道
+// 保持「仅隐藏」语义:显式隐藏(Visible:false)的笔记本不构成机密边界,
+// 普通文件与 .sy 文档仍可直接访问,禁用与密码保护照常生效。
+func TestCheckAbsPathAccessableByPublishAccessKeepsHiddenNotebookAccessible(t *testing.T) {
const (
boxID = "20260821000005-visboxa"
docID = "20260821000006-visdoca"
@@ -1496,42 +1496,34 @@ func TestCheckAbsPathAccessableByPublishAccessForReadOnly(t *testing.T) {
fileAbs := filepath.Join(util.DataDir, boxID, "private.txt")
docAbs := filepath.Join(util.DataDir, boxID, docID+".sy")
- // 基础校验:显式隐藏的笔记本仍保持可直接访问语义(与文档内容 API 一致)
+ // 显式隐藏的笔记本保持可直接访问语义(与文档内容 API 一致)
if !CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{{ID: boxID, Visible: false}}) {
- t.Fatal("base check should keep hidden notebook directly accessible")
+ t.Fatal("hidden notebook file should remain directly accessible")
}
-
- // 只读校验:显式隐藏的笔记本应被拒绝,普通文件与 .sy 文档均如此
- if CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: false}}) {
- t.Fatal("read-only check should deny file under hidden notebook")
- }
- if CheckAbsPathAccessableByPublishAccessForReadOnly(c, docAbs, PublishAccess{{ID: boxID, Visible: false}}) {
- t.Fatal("read-only check should deny doc under hidden notebook")
+ if !CheckAbsPathAccessableByPublishAccess(c, docAbs, PublishAccess{{ID: boxID, Visible: false}}) {
+ t.Fatal("hidden notebook doc should remain directly accessible")
}
- // 可见、未配置、禁用与密码保护场景应保持原有判定
- if !CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: true}}) {
- t.Fatal("read-only check should allow file under visible notebook")
+ // 可见与未配置场景不受影响
+ if !CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{{ID: boxID, Visible: true}}) {
+ t.Fatal("visible notebook file should be accessible")
}
- if !CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{}) {
- t.Fatal("read-only check should allow file under unconfigured notebook")
+ if !CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{}) {
+ t.Fatal("unconfigured notebook file should be accessible")
}
- if CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Disable: true}}) {
- t.Fatal("read-only check should deny disabled notebook")
+
+ // 禁用与密码保护仍构成访问控制
+ if CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Disable: true}}) {
+ t.Fatal("disabled notebook should be denied")
}
- if CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Password: password}}) {
- t.Fatal("read-only check should deny password protected notebook without auth cookie")
+ if CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Password: password}}) {
+ t.Fatal("password protected notebook should be denied without auth cookie")
}
c.Request.AddCookie(&http.Cookie{
Name: "publish-auth-" + boxID,
Value: util.SHA256Hash([]byte(boxID + password)),
})
- if !CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Password: password}}) {
- t.Fatal("read-only check should allow password protected notebook after authorization")
- }
-
- // 隐藏且带密码的笔记本应被隐藏判定直接拒绝,即使已通过密码授权
- if CheckAbsPathAccessableByPublishAccessForReadOnly(c, fileAbs, PublishAccess{{ID: boxID, Visible: false, Password: password}}) {
- t.Fatal("read-only check should deny hidden notebook even after password authorization")
+ if !CheckAbsPathAccessableByPublishAccess(c, fileAbs, PublishAccess{{ID: boxID, Visible: true, Password: password}}) {
+ t.Fatal("password protected notebook should be accessible after authorization")
}
}
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index 123e90761a..f4da39b900 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -975,13 +975,7 @@ func serveAssets(ginServer *gin.Engine) {
if !model.IsAdminRoleContext(context) {
publishAccess := model.GetPublishAccess()
- var accessible bool
- if model.IsReadOnlyRoleContext(context) {
- accessible = model.CheckAbsPathAccessableByPublishAccessForReadOnly(context, p, publishAccess)
- } else {
- accessible = model.CheckAbsPathAccessableByPublishAccess(context, p, publishAccess)
- }
- if !accessible {
+ if !model.CheckAbsPathAccessableByPublishAccess(context, p, publishAccess) {
context.Status(http.StatusForbidden)
return
}