dsh-notify-me 1.14.5 → 1.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +20 -3
- package/lib/index.js +39 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-notify-me** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.14.6] — 2026-10-27
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- **监听器只绑一个具体局域网 IP 时,桌面端点通知不再抬不起窗**:抬窗路由的闸门只认 loopback 对端与 `Host`,而 `webServer` 可以被配置成只绑一块网卡;那种情况下壳按绑定地址拨号,请求的对端和 `Host` 都是那个 IP,被 `403 bad-remote` / `bad-host` 挡掉。现在闸门额外接受「恰好是监听器自己绑定的那个 IP」(`webServer.host`)作对端与 `Host`;局域网里别的机器连过来源地址不是这个 IP,照旧拒绝。
|
|
10
|
+
- **会话基线不再随子代理会话一直涨**:`prevById` 在会话首次出现时新增,消失后永远保留。长开的页面上子代理会话来来去去,`debug().sessionBaselines` 只增不减。现在连续 40 次列表更新都缺席的行会丢掉基线(顺带清掉 `doneFiredAt`);短暂消失仍保留,不影响「消失再出现不补报」的语义。
|
|
11
|
+
|
|
12
|
+
### 测试
|
|
13
|
+
|
|
14
|
+
- `host-route-test.mjs` 用 `webServer.host = 192.168.1.5` 的假宿主补了四条:本机自拨的绑定地址放行、局域网别处的客户端 `bad-remote`、自拨但 `Host` 是别的域名 `bad-host`、跨源 `Origin` 照旧拒绝。
|
|
15
|
+
- 冒烟新增 `vanishedBaselinesPruned()`:短暂缺席保留基线,连续 40+ 次更新后清零。
|
|
16
|
+
|
|
17
|
+
### 文档
|
|
18
|
+
|
|
19
|
+
- README / SECURITY 中英的闸门说明补上「或监听器自己绑定的那个 IP」。
|
|
20
|
+
- `docs/listing.md` 版本口径同步到 1.14.6。
|
|
21
|
+
|
|
5
22
|
## [1.14.5] — 2026-10-27
|
|
6
23
|
|
|
7
24
|
### 修复
|
package/README.en.md
CHANGED
|
@@ -311,7 +311,7 @@ Measured with `powershell.exe` 5.1 in one round: window in front ×3, minimized
|
|
|
311
311
|
|
|
312
312
|
Security-wise the plugin opens exactly one exact route. Requests outside the vocabulary are refused: anything other than GET / HEAD / POST answers `405` (including a preflight `OPTIONS`, and it never returns a CORS header), a non-Windows host (Web, macOS / Linux, plain Node) `501` (macOS / Linux use the deep link and never reach this route), and a missing `x-dsh-notify-me-focus: focus` header `403`.
|
|
313
313
|
|
|
314
|
-
That header is only a "this came from the page" marker, not the defence — a DNS-rebinding page is same-origin with the address it resolved, so it can send any custom header and triggers no preflight. The real gate is three checks: the peer address must be loopback; `Host` must be a loopback name (`127.0.0.1` / `localhost` / `[::1]`, port optional), because the shell deletes `host` when forwarding and fetch refills it from the
|
|
314
|
+
That header is only a "this came from the page" marker, not the defence — a DNS-rebinding page is same-origin with the address it resolved, so it can send any custom header and triggers no preflight. The real gate is three checks: the peer address must be loopback, or exactly the address the listener itself is bound to; `Host` must be a loopback name (`127.0.0.1` / `localhost` / `[::1]`, port optional) or that same bind address, because the shell deletes `host` when forwarding and fetch refills it from the URL it dialled, while a rebound page still has the attacker's domain in `Host`; and an `Origin`, when present, must be same-origin with that `Host`. Any failure answers `403`, with `reason` set to `bad-remote` / `bad-host` / `cross-origin`. A `GET` returns only `{ok, route, enabled, desktop, platform}`, so after installing you can open it in a browser to confirm the route is there. Calls within 400 ms coalesce into one, and a script that has not answered after 8 s is killed and counted as a failure.
|
|
315
315
|
|
|
316
316
|
The cases where it will not raise are the same ones listed under [Known limitations](#known-limitations) (elevated window, another virtual desktop, a foreground repeatedly stolen, a window hidden to the tray with `SW_HIDE`); they all answer `202` truthfully and the conversation switch still happens.
|
|
317
317
|
|
package/README.md
CHANGED
|
@@ -310,7 +310,7 @@ Windows 的激活顺序是实的:已经在前台就什么都不做(最常见
|
|
|
310
310
|
|
|
311
311
|
安全上只开一条 exact 路由。词表之外的请求一律拒:非 GET / HEAD / POST 回 `405`(包括预检的 `OPTIONS`,且从不回任何 CORS 头),非 Windows 宿主(Web 版、macOS / Linux、纯 Node)回 `501`(macOS / Linux 走深链,不经过这条路由),缺 `x-dsh-notify-me-focus: focus` 头回 `403`。
|
|
312
312
|
|
|
313
|
-
那个头只是「这是页面发来的」标记,不是防线——DNS rebinding 的恶意页对目标地址而言是同源的,能带任意自定义头、也不触发预检。真正的闸门是三层:对端地址必须是 loopback;`Host` 必须是 loopback 名(`127.0.0.1` / `localhost` / `[::1]
|
|
313
|
+
那个头只是「这是页面发来的」标记,不是防线——DNS rebinding 的恶意页对目标地址而言是同源的,能带任意自定义头、也不触发预检。真正的闸门是三层:对端地址必须是 loopback,或恰好是监听器自己绑定的那个 IP;`Host` 必须是 loopback 名(`127.0.0.1` / `localhost` / `[::1]`,可带端口)或同一个绑定地址,因为壳转发时 `host` 已被删掉、由 fetch 按它拨号的 URL 重填,而 rebinding 的页面 Host 仍是攻击者域名;带了 `Origin` 就必须和 `Host` 同源。任一条不符回 `403`,`reason` 分别是 `bad-remote` / `bad-host` / `cross-origin`。`GET` 只回 `{ok, route, enabled, desktop, platform}`,装完可以先用浏览器打开确认路由在不在。400 毫秒内的重复调用合并成一次,脚本超过 8 秒没回话就 kill 掉按失败处理。
|
|
314
314
|
|
|
315
315
|
抬不起来的几种场合与[已知限制](#已知限制)里列的一致(提权窗口、另一虚拟桌面、前台被反复抢走、`SW_HIDE` 托盘隐藏),一律如实回 `202`、对话照常切。
|
|
316
316
|
|
package/lib/client.js
CHANGED
|
@@ -1944,6 +1944,10 @@
|
|
|
1944
1944
|
// prevById: per-session-id baseline of what we have already reported.
|
|
1945
1945
|
// { running: bool, pendingKeys: string[] , doneArmed: bool, seeded: bool }
|
|
1946
1946
|
var prevById = Object.create(null);
|
|
1947
|
+
// A row absent from this many list updates is gone, not asleep: dropping
|
|
1948
|
+
// its baseline bounds the map on long-lived pages (subagent sessions come
|
|
1949
|
+
// and go), while a short absence keeps the no-replay guarantee.
|
|
1950
|
+
var BASELINE_MISSING_LIMIT = 40;
|
|
1947
1951
|
var faceSub = null; // current session face unsubscribe
|
|
1948
1952
|
var currentFaceId = null;
|
|
1949
1953
|
var listStore = null;
|
|
@@ -2082,7 +2086,8 @@
|
|
|
2082
2086
|
running: runningNow,
|
|
2083
2087
|
pendingKeys: pendingNow.map(function (p) { return p.key; }),
|
|
2084
2088
|
completed: !!row.completed,
|
|
2085
|
-
seeded: true
|
|
2089
|
+
seeded: true,
|
|
2090
|
+
missing: 0
|
|
2086
2091
|
};
|
|
2087
2092
|
|
|
2088
2093
|
// a wait we alerted about has been resolved -> drop the title marker
|
|
@@ -2191,7 +2196,19 @@
|
|
|
2191
2196
|
if (!sum) continue;
|
|
2192
2197
|
evalListRow(sid, sum, cur);
|
|
2193
2198
|
}
|
|
2194
|
-
//
|
|
2199
|
+
// Sessions that vanished: keep the baseline for a while (they may
|
|
2200
|
+
// reappear), then drop it. Without the sweep one entry outlived every
|
|
2201
|
+
// subagent session that ever ran on the page.
|
|
2202
|
+
var gone;
|
|
2203
|
+
for (gone in prevById) {
|
|
2204
|
+
if (byId[gone]) continue;
|
|
2205
|
+
var goneEntry = prevById[gone];
|
|
2206
|
+
goneEntry.missing = (goneEntry.missing || 0) + 1;
|
|
2207
|
+
if (goneEntry.missing > BASELINE_MISSING_LIMIT) {
|
|
2208
|
+
delete prevById[gone];
|
|
2209
|
+
delete doneFiredAt[gone];
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2195
2212
|
} catch (e) {}
|
|
2196
2213
|
}
|
|
2197
2214
|
|
|
@@ -2406,7 +2423,7 @@
|
|
|
2406
2423
|
});
|
|
2407
2424
|
} catch (e) {}
|
|
2408
2425
|
// keep in sync with package.json "version" on every release
|
|
2409
|
-
api.version = "1.14.
|
|
2426
|
+
api.version = "1.14.6";
|
|
2410
2427
|
api.setConfig = function (patch) { return setConfigLocal(patch); };
|
|
2411
2428
|
api.resetConfig = function () {
|
|
2412
2429
|
try {
|
package/lib/index.js
CHANGED
|
@@ -252,6 +252,25 @@ function splitHost(value) {
|
|
|
252
252
|
return { hostname: plain[1], port: plain[2] ?? "" };
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Whether a peer / `Host` names the listener's own bind address.
|
|
257
|
+
*
|
|
258
|
+
* The webserver can be configured to bind one concrete LAN interface; on such a
|
|
259
|
+
* host the shell reaches it through that address, so the request arrives from
|
|
260
|
+
* this machine with the bind IP as both peer and `Host`. Accepting exactly that
|
|
261
|
+
* literal keeps the gate self-addressed: a remote LAN client connects from its
|
|
262
|
+
* own address, never the server's.
|
|
263
|
+
* @param hostname - bare hostname from the peer address or `Host` header.
|
|
264
|
+
* @param bindHost - configured bind address, if the host exposes one.
|
|
265
|
+
* @returns whether they name the same machine.
|
|
266
|
+
*/
|
|
267
|
+
function isBindAddress(hostname, bindHost) {
|
|
268
|
+
if (typeof bindHost !== "string" || bindHost.length === 0) return false;
|
|
269
|
+
const zone = bindHost.indexOf("%");
|
|
270
|
+
const text = zone === -1 ? bindHost : bindHost.slice(0, zone);
|
|
271
|
+
return bareHostname(hostname) === bareHostname(text);
|
|
272
|
+
}
|
|
273
|
+
|
|
255
274
|
/**
|
|
256
275
|
* Refuse a request that did not come from this machine's own page.
|
|
257
276
|
*
|
|
@@ -259,20 +278,21 @@ function splitHost(value) {
|
|
|
259
278
|
* also answers plain HTTP on the host port, and a DNS-rebinding page reaches
|
|
260
279
|
* that port while looking same-origin to the browser — it can send any header,
|
|
261
280
|
* including {@link RAISE_HEADER}, and no preflight fires. What it cannot forge
|
|
262
|
-
* is the connection's source address (
|
|
263
|
-
* or the `Host` header: the shell deletes the original and the fetch
|
|
264
|
-
* it from the
|
|
281
|
+
* is the connection's source address (this machine, so loopback or the bind
|
|
282
|
+
* address) or the `Host` header: the shell deletes the original and the fetch
|
|
283
|
+
* re-fills it from the URL it dialled, while a rebound page keeps its own name.
|
|
265
284
|
*
|
|
266
|
-
* So the gate is: loopback peer,
|
|
267
|
-
* with that `Host` when one is present.
|
|
285
|
+
* So the gate is: loopback or bind-address peer, the same for `Host`, and an
|
|
286
|
+
* `Origin` that agrees with that `Host` when one is present.
|
|
268
287
|
* @param req - the incoming request.
|
|
288
|
+
* @param bindHost - the listener's configured bind address, when known.
|
|
269
289
|
* @returns a short refusal reason, or `null` when the request may proceed.
|
|
270
290
|
*/
|
|
271
|
-
function gateRequest(req) {
|
|
272
|
-
const remote = req.socket?.remoteAddress ?? "";
|
|
273
|
-
if (!isLoopbackHostname(
|
|
291
|
+
function gateRequest(req, bindHost) {
|
|
292
|
+
const remote = String(req.socket?.remoteAddress ?? "").replace(/^::ffff:/i, "");
|
|
293
|
+
if (!isLoopbackHostname(remote) && !isBindAddress(remote, bindHost)) return "bad-remote";
|
|
274
294
|
const host = splitHost(req.headers.host);
|
|
275
|
-
if (host === null || !isLoopbackHostname(host.hostname)) return "bad-host";
|
|
295
|
+
if (host === null || (!isLoopbackHostname(host.hostname) && !isBindAddress(host.hostname, bindHost))) return "bad-host";
|
|
276
296
|
const origin = req.headers.origin;
|
|
277
297
|
if (typeof origin !== "string" || origin.length === 0) return null;
|
|
278
298
|
if (origin === "dsh-app://app") return null; // the desktop page, if not stripped
|
|
@@ -310,14 +330,14 @@ function respond(res, status, body) {
|
|
|
310
330
|
* whether activation is available at all; only the POST form touches the OS.
|
|
311
331
|
* @returns the web-server route handler.
|
|
312
332
|
*/
|
|
313
|
-
function createHandler() {
|
|
333
|
+
function createHandler(bindHost) {
|
|
314
334
|
return function handleFocus(req, res) {
|
|
315
335
|
const method = req.method ?? "GET";
|
|
316
336
|
if (method !== "GET" && method !== "HEAD" && method !== "POST") {
|
|
317
337
|
respond(res, 405, { ok: false, reason: "method-not-allowed" });
|
|
318
338
|
return;
|
|
319
339
|
}
|
|
320
|
-
const refusal = gateRequest(req);
|
|
340
|
+
const refusal = gateRequest(req, bindHost);
|
|
321
341
|
if (refusal !== null) {
|
|
322
342
|
respond(res, 403, { ok: false, reason: refusal });
|
|
323
343
|
return;
|
|
@@ -364,8 +384,15 @@ function createHandler() {
|
|
|
364
384
|
*/
|
|
365
385
|
export function apply(ctx) {
|
|
366
386
|
ctx.inject(["webServer"], (webCtx) => {
|
|
387
|
+
// The listener may be bound to one concrete LAN interface; read it so the
|
|
388
|
+
// gate can accept the self-addressed request the shell makes in that setup.
|
|
389
|
+
let bindHost;
|
|
390
|
+
try {
|
|
391
|
+
const server = webCtx.webServer;
|
|
392
|
+
if (server && typeof server.host === "string") bindHost = server.host;
|
|
393
|
+
} catch {}
|
|
367
394
|
webCtx.effect(
|
|
368
|
-
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler() }),
|
|
395
|
+
() => webCtx.webServer.register({ kind: "exact", path: FOCUS_ROUTE, handler: createHandler(bindHost) }),
|
|
369
396
|
"dsh-notify-me: window focus route",
|
|
370
397
|
);
|
|
371
398
|
});
|