GitHub advisory · Go
Daptin: Broken Access Control (IDOR) in the generic YJS collaboration endpoint
Description
Daptin registers a generic WebSocket endpoint, GET /yjs/:documentName, for real-time collaborative
document editing (YJS/CRDT). Unlike its purpose-built sibling route, this generic endpoint performs
no per-resource authorization check - it only verifies that some user session exists. Because the
document store parses :documentName as typename.referenceId.columnName and fetches that row's
real column content unconditionally, any authenticated user (including a brand-new, zero-privilege,
self-registered account) can read - and, since YJS sync is bidirectional, also write - the content
of any file.*-typed column on any row of any table, including tables that are admin-only by
default.
InitializeYjsResources (server/endpoint_yjs.go) registers two routes.
The purpose-built, correctly-secured route, registered once per file.*-typed column on every
table:
// server/endpoint_yjs.go:47-113 (abridged)
path := fmt.Sprintf("/live/%v/:referenceId/%v/yjs", typename, columnInfo.ColumnName)
...
return func(ginContext *gin.Context) {
sessionUser := ...
if sessionUser == nil { ginContext.AbortWithStatus(403); return }
...
object, _, getErr := cruds[typename].GetSingleRowByReferenceIdWithTransaction(typename, parsedId, nil, tx)
if getErr != nil { ginContext.AbortWithStatus(404); return }
...
objectPermission := cruds[typename].GetRowPermission(object, tx2)
if !objectPermission.CanUpdate(user.UserReferenceId, user.Groups, cruds[typename].AdministratorGroupId) {
ginContext.AbortWithStatus(401)
return
}
roomName := fmt.Sprintf("%v%v%v%v%v", typename, ".", referenceId, ".", columnInfo.ColumnName)
...
yjsConnectionHandler(ginContext.Writer, ginContext.Request)
}
This route correctly requires a session, loads the actual row, and checks
objectPermission.CanUpdate(...) for the specific requesting user before allowing the WebSocket
upgrade.
A second, generic route is…
Manual fix · Go
go get github.com/daptin/daptin@v0.12.30Sources