An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:lock: Prevent hidden database backlink disclosure https://github.com/siyuan-note/siyuan/security/advisories/GHSA-p4qw-vx5p-g984
Daniel5b42614311b0
diff --git a/kernel/model/publish_access.go b/kernel/model/publish_access.goindex 50bb4258ed..4292348ec1 100644--- a/kernel/model/publish_access.go+++ b/kernel/model/publish_access.go@@ -1097,7 +1097,7 @@ func FilterAttributeViewBacklinksByPublishAccess(c *gin.Context, publishAccess P}passwordID, password := GetPathPasswordByPublishAccess(bt.BoxID, bt.Path, publishAccess)if ("" == password || CheckPublishAuthCookie(c, passwordID, password)) &&- CheckPathAccessableByPublishIgnore(bt.BoxID, bt.Path, publishIgnore) {+ CheckBlockTreeDiscoverableByPublishAccess(publishAccess, bt) {databaseAccessible = truebacklink.DatabaseBlockID = bt.IDbacklink.BoxID = bt.BoxIDdiff --git a/kernel/model/publish_access_test.go b/kernel/model/publish_access_test.goindex d60434fc8e..8ce9edacd9 100644--- a/kernel/model/publish_access_test.go+++ b/kernel/model/publish_access_test.go@@ -173,6 +173,94 @@ func TestFilterBlockTreesByPublishAccess(t *testing.T) {}}+func TestFilterAttributeViewBacklinksByPublishAccess(t *testing.T) {+ const (+ boxID = "20260730140000-box0001"+ targetDocID = "20260730140001-target1"+ sourceDocID = "20260730140002-source1"+ targetAvID = "20260730140003-targeta"+ sourceAvID = "20260730140004-sourcea"+ sourceItemID = "20260730140005-sourcei"+ targetItemID = "20260730140006-targeti"+ relationKeyID = "20260730140007-relkey1"+ )++ oldDataDir := util.DataDir+ oldBlockTreeDBPath := util.BlockTreeDBPath+ util.DataDir = t.TempDir()+ util.BlockTreeDBPath = filepath.Join(util.DataDir, "blocktree.db")+ treenode.InitBlockTree(true)+ invalidateEncryptedPublishAccessCache()+ t.Cleanup(func() {+ treenode.CloseDatabase()+ util.DataDir = oldDataDir+ util.BlockTreeDBPath = oldBlockTreeDBPath+ invalidateEncryptedPublishAccessCache()+ if "" != oldBlockTreeDBPath {+ treenode.InitBlockTree(false)+ }+ })++ targetTree := treenode.NewTree(boxID, "/"+targetDocID+".sy", "/Target", "Target")+ sourceTree := treenode.NewTree(boxID, "/"+sourceDocID+".sy", "/Source", "Source")+ treenode.UpsertBlockTree(targetTree)+ treenode.UpsertBlockTree(sourceTree)+ av.UpsertBlockRel(targetAvID, targetDocID)++ newBacklinks := func() *AttributeViewBacklinks {+ return &AttributeViewBacklinks{+ Total: 1,+ Items: []*AttributeViewBacklink{{+ AvID: sourceAvID,+ BlockIDs: []string{sourceDocID},+ ItemID: sourceItemID,+ IsDetached: true,+ Relations: []*AttributeViewBacklinkRelation{{+ KeyID: relationKeyID,+ TargetAvID: targetAvID,+ TargetItemID: targetItemID,+ }},+ }},+ }+ }+ c, _ := gin.CreateTestContext(httptest.NewRecorder())+ c.Request = httptest.NewRequest(http.MethodGet, "/", nil)++ tests := []struct {+ name string+ publishAccess PublishAccess+ expectedTotal int+ }{+ {+ name: "public source",+ expectedTotal: 1,+ },+ {+ name: "hidden source",+ publishAccess: PublishAccess{{ID: sourceDocID, Visible: false}},+ expectedTotal: 0,+ },+ {+ name: "disabled source with inconsistent visibility",+ publishAccess: PublishAccess{{ID: sourceDocID, Visible: true, Disable: true}},+ expectedTotal: 0,+ },+ {+ name: "hidden target remains directly accessible",+ publishAccess: PublishAccess{{ID: targetDocID, Visible: false}},+ expectedTotal: 1,+ },+ }+ for _, test := range tests {+ t.Run(test.name, func(t *testing.T) {+ filtered := FilterAttributeViewBacklinksByPublishAccess(c, test.publishAccess, newBacklinks())+ if filtered.Total != test.expectedTotal || len(filtered.Items) != test.expectedTotal {+ t.Fatalf("unexpected attribute view backlinks: %+v", filtered)+ }+ })+ }+}+func TestEncryptedNotebookDeniedByPublishAccess(t *testing.T) {const (boxID = "20260726000000-encrypt"