GHSA-7J37-4GQ6-WM7M
Plaintext Publish Session Cookie Enables Authentication Bypass
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7J37-4GQ6-WM7M divulgada · CVSS 9.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Plaintext Publish Session Cookie Enables Authentication Bypass
Summary
Source review at SiYuan revision 8641553a1f07374001902d3ce773285db1292b2d shows that the publish listener can serve HTTP and HTTPS, while its authentication transport accepts a reusable session cookie before it asks for Basic Auth. The cookie is issued without Secure or SameSite attributes, so an on-path observer of a successful plaintext Basic Auth exchange could replay the session identifier and reach the authenticated publish-account path without learning the password. The source check confirms these predicates and the unauthenticated rejection branch, but it did not launch the publish service or capture live HTTP responses, cookies, or forwarded tokens.
Technical Details
The relevant source-to-sink route is InitPublishService -> initPublishService -> initPublishListener -> startPublishReverseProxyService -> ServeMultiplexed -> PublishServiceTransport.RoundTrip.
initPublishListener creates a TCP listener with net.Listen("tcp", ...). When TLS material is available, ServeMultiplexed classifies connections as TLS or other traffic, wraps only the TLS branch, and serves the same reverse-proxy handler through both HTTP and HTTPS. Without TLS material, the listener is served by an ordinary HTTP server.
PublishServiceTransport.RoundTrip first looks for publish-visitor-session-id. A valid session lets the transport look up the account, place its token in X-Auth-Token, and forward the request. If no valid session exists, valid Basic Auth creates or reuses a session and adds the cookie to the response:
~~~go
cookie := &http.Cookie{
Name: model.SessionIdCookieName,
Value: sessionID,
Path: "/",
HttpOnly: true,
}
response.Header.Add("Set-Cookie", cookie.String())
~~~
The cookie has no Secure or SameSite setting, and the listener does not require TLS before this authentication flow. The security invariant is therefore: a session identifier obtained from plaintext transport must not be sufficient to cross the publish authentication boundary. The reviewed code does not enforce that invariant.
PoV
The following exchanges are illustrative of the traffic that a live integration test must capture. They are not captured traffic from this revision.
~~~http
GET /published-page HTTP/1.1
Host: publish.example
Authorization: Basic <valid-credentials>
HTTP/1.1 200 OK
Set-Cookie: publish-visitor-session-id=<session>; Path=/; HttpOnly
~~~
An observer could then send the cookie on a later plaintext request:
~~~http
GET /published-page HTTP/1.1
Host: publish.example
Cookie: publish-visitor-session-id=<session>
~~~
The expected live proof is an authenticated forwarding response and a separate no-credential request receiving 401 Unauthorized. Those response details are not presented as observed results here.
PoC
Create a temporary checkout at the affected revision and run from its repository root:
~~~sh
set -eu
checkout_dir="$(mktemp -d)"
git clone https://github.com/siyuan-note/siyuan.git "$checkout_dir/siyuan"
git -C "$checkout_dir/siyuan" checkout 8641553a1f07374001902d3ce773285db1292b2d
cd "$checkout_dir/siyuan"
node <<'NODE'
const fs = require('fs');
const publish = fs.readFileSync('kernel/server/proxy/publish.go', 'utf8');
const cmux = fs.readFileSync('kernel/util/cmux.go', 'utf8');
const cookieMatch = publish.match(/cookie\s*:=\s*&http\.Cookie\s*\{([\s\S]*?)\n\s*\}/);
const cookie = cookieMatch ? cookieMatch[1] : '';
const transport = [
/net\.Listen\(\s*"tcp"\s*,\s*fmt\.Sprintf\(/,
/httpL\s*:=\s*m\.Match\(cmux\.Any\(\)\)/,
/tlsL\s*:=\s*m\.Match\(cmux\.TLS\(\)\)/,
/httpServer\.Serve\(httpL\)/,
/httpsServer\.Serve\(tlsListener\)/,
].every((pattern) => pattern.test(pattern.source.includes('httpL') || pattern.source.includes('tlsL') || pattern.source.includes('Server') ? cmux : publish));
const session = [
cookieMatch !== null,
/HttpOnly\s*:\s*true/.test(cookie),
!/Secure\s*:/.test(cookie),
!/SameSite\s*:/.test(cookie),
/response\.Header\.Add\(\s*"Set-Cookie"\s*,\s*cookie\.String\(\)\s*\)/.test(publish),
/request\.Cookie\(model\.SessionIdCookieName\)/.test(publish),
/model\.GetBasicAuthAccountBySessionID\(sessionID\)/.test(publish),
/request\.Header\.Set\(model\.XAuthTokenKey\s*,\s*account\.Token\)/.test(publish),
].every(Boolean);
const noCredentials401 = /!ok\s*\|\|\s*""\s*==\s*username[\s\S]*?StatusUnauthorized/.test(publish);
const attack = transport && session;
const control = attack && noCredentials401;
console.log('attack result: ' + JSON.stringify({
result: attack ? 'violation' : 'invalid',
signal: attack ? 'plaintext publish session cookie is observable and replayed across the publish authentication boundary' : '',
}));
console.log('control result: ' + JSON.stringify({
result: control ? 'pass' : 'invalid',
signal: '',
}));
NODE
~~~
The command prints:
~~~text
attack result: {"result":"violation","signal":"plaintext publish session cookie is observable and replayed across the publish authentication boundary"}
control result: {"result":"pass","signal":""}
~~~
This is a transparent source-derived check, not a live HTTP proof. It does not establish a captured 200 response, Set-Cookie value, cookie replay, token forwarding, or 401 response; those require the runtime integration test described in Suggested Fix.
Impact
If the listener is reachable over plaintext HTTP, an on-path attacker can observe a valid publish session cookie and reuse it until the session expires or is invalidated. The attacker does not need the account password, and requests are forwarded with the authenticated publish account's token. The impact is limited to the privileges exposed by that publish account; this finding does not claim host code execution.
Suggested Fix
Require TLS before accepting publish authentication and reject plaintext connections rather than allowing the same authenticated handler to serve both schemes. Mark any remaining session cookie Secure and use an appropriate SameSite policy. Invalidate sessions that may have crossed plaintext transport, and add an integration test that sends Basic Auth over HTTP, captures the real Set-Cookie value, replays it, verifies authenticated forwarding, and checks a no-credential 401 control.
Affected Package/Versions
- Package: siyuan-note/siyuan
- Ecosystem: npm
- Affected revision: 8641553a1f07374001902d3ce773285db1292b2d
- Source review at the current head showed the same predicates; no patched version was identified in this review.
Advisory History
Issue #19097, Improve publish session invalidation after account password changes, and commit 79d47867b106467c951475a9193455b48d1f3682 address removal of stale sessions after a password change. That protects credential-change invalidation; it does not stop an observer from learning or replaying a still-valid cookie over plaintext.
PR #15692, Add cookie-based auth in publish proxy, and commit ff4d215f78a8d6e6db6052be18b5f9f4db9c7d68 introduced the cookie-backed session branch. This history explains the mechanism but does not make a cookie transported over plaintext confidential.
GHSA-2x7j-p79w-7744 concerns Basic Auth throttling and retention of unique invalid-user keys, a resource-retention and availability defense. It does not address observation or replay of a valid session cookie. GHSA-f4vj-ppp2-5hg4, Publish-service Basic Auth creates unbounded persistent sessions, likewise concerns session retention and availability rather than this transport confidentiality and authentication-boundary issue.
Related reports about Kramdown IAL paste-to-desktop execution, remote-kernel Electron IPC access to the clipboard, unescaped flashcard card-manager execution, and gutter-drag DataTransfer disclosure concern different code paths. No exact CVE for this plaintext session observation and replay primitive was identified.
References
- Publish authentication transport: https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/server/proxy/publish.go
- Multiplexed publish listener: https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/util/cmux.go
- Issue #19097, Improve publish session invalidation after account password changes: https://github.com/siyuan-note/siyuan/issues/19097
- Commit 79d47867, Improve publish session invalidation after account password changes: https://github.com/siyuan-note/siyuan/commit/79d47867b106467c951475a9193455b48d1f3682
- PR #15692, Add cookie-based auth in publish proxy: https://github.com/siyuan-note/siyuan/pull/15692
- Commit ff4d215f, Add cookie-based auth in publish proxy: https://github.com/siyuan-note/siyuan/commit/ff4d215f78a8d6e6db6052be18b5f9f4db9c7d68
- GHSA-2x7j-p79w-7744: https://github.com/advisories/GHSA-2x7j-p79w-7744
- GHSA-f4vj-ppp2-5hg4: https://github.com/advisories/GHSA-f4vj-ppp2-5hg4
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Versiones afectadas
pinned-revision-8641553a1f07374001902d3ce773285db1292b2dEstado 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-7j37-4gq6-wm7mLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
