dbsc-toolkit 2.9.2 → 2.9.3
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/README.md +37 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
> **Stop stolen session cookies from being replayed on another device.**
|
|
9
9
|
>
|
|
10
|
-
> `dbsc-toolkit` implements W3C [Device Bound Session Credentials](https://www.w3.org/TR/dbsc/) on the server, and ships a Web Crypto polyfill so the same protection works on browsers that don't speak native DBSC yet. Native DBSC on Chromium 146+
|
|
10
|
+
> `dbsc-toolkit` implements W3C [Device Bound Session Credentials](https://www.w3.org/TR/dbsc/) on the server, and ships a Web Crypto polyfill so the same protection works on browsers that don't speak native DBSC yet. Native DBSC on Chromium 146+ (TPM / Secure Enclave); the polyfill on every other browser. **One server, every browser, no user prompts.**
|
|
11
11
|
>
|
|
12
12
|
> Works with **Express · Fastify · Hono · Next.js · Redis · PostgreSQL**.
|
|
13
13
|
|
|
14
|
+
```ts
|
|
15
|
+
// In your login route — one line to bind the session:
|
|
16
|
+
app.post("/login", async (req, res) => {
|
|
17
|
+
await dbsc.bind(res, sessionId, { userId });
|
|
18
|
+
res.json({ ok: true });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// On any sensitive route — one guard:
|
|
22
|
+
app.post("/payment", express.raw({ type: "*/*" }), requireProof(), paymentHandler);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's it. The rest — key generation, protocol routes, cookie management, polyfill — is handled by the library.
|
|
26
|
+
|
|
14
27
|
## Contents
|
|
15
28
|
|
|
16
29
|
- [Install](#install)
|
|
@@ -25,6 +38,7 @@
|
|
|
25
38
|
- [Protect your routes](#protect-your-routes)
|
|
26
39
|
- [Production checklist](#production-checklist)
|
|
27
40
|
- [API](#subpath-imports)
|
|
41
|
+
- [Security model](#security-model)
|
|
28
42
|
- [Going deeper](#going-deeper)
|
|
29
43
|
|
|
30
44
|
## Why dbsc-toolkit
|
|
@@ -33,8 +47,8 @@ Native DBSC ships on Chrome 146+ for Windows users with a TPM. That's about a th
|
|
|
33
47
|
|
|
34
48
|
This library is among the first DBSC implementations to provide a Web Crypto fallback for browsers that don't support native DBSC. Same wire-level protection against cookie theft, same `requireProof()` guard server-side, key stored non-extractably in IndexedDB instead of a TPM. No biometric prompt, no user interaction, no checkbox.
|
|
35
49
|
|
|
36
|
-
- ✅ **Native W3C DBSC** on Chromium 146+ (TPM
|
|
37
|
-
- ✅ **Web Crypto polyfill** on Firefox, Safari, older Chromium — same protection, IndexedDB key
|
|
50
|
+
- ✅ **Native W3C DBSC** on Chromium 146+ (TPM on Windows, Secure Enclave on macOS)
|
|
51
|
+
- ✅ **Web Crypto polyfill** on Firefox, Safari, mobile, older Chromium — same protection, IndexedDB key
|
|
38
52
|
- ✅ **Express, Fastify, Hono, Next.js** adapters — all four ship in one package
|
|
39
53
|
- ✅ **Memory, Redis, Postgres** storage — pick one, swap with one line
|
|
40
54
|
- ✅ **`requireProof()`** per-request signature guard — works on every browser, body-hash defended against MITM
|
|
@@ -126,7 +140,7 @@ The native-DBSC column refers to a server that uses the spec without a polyfill
|
|
|
126
140
|
|
|
127
141
|
JWTs are still bearer tokens. Whoever has the bytes can replay them. Steal a JWT from a log line, an XSS, a leaked proxy header, a misconfigured intermediary — paste it into another machine and the server treats it as the legitimate user, exactly like a stolen cookie.
|
|
128
142
|
|
|
129
|
-
DBSC pins the session to a cryptographic key that lives on the user's device (TPM, Secure Enclave
|
|
143
|
+
DBSC pins the session to a cryptographic key that lives on the user's device (TPM on Windows, Secure Enclave on macOS, or — under the polyfill — a non-extractable IndexedDB key on every other browser). The token alone is no longer sufficient: the browser has to prove possession of the key on every refresh, and on every guarded request via `requireProof()`. The attacker's device has no key, so the replay fails and the session demotes within one cycle.
|
|
130
144
|
|
|
131
145
|
DBSC complements your existing auth (passwords, MFA, JWT/session cookies) — it does not replace them. It closes the *replay-after-issue* gap that bearer tokens cannot.
|
|
132
146
|
|
|
@@ -243,7 +257,7 @@ Tree-shaking eliminates anything you don't import. Using Koa, Hapi, raw `http`,
|
|
|
243
257
|
|
|
244
258
|
| Tier | Mechanism | Protects against |
|
|
245
259
|
|------|-----------|------------------|
|
|
246
|
-
| `dbsc` | Native W3C DBSC, key in TPM
|
|
260
|
+
| `dbsc` | Native W3C DBSC, key in TPM (Windows) or Secure Enclave (macOS) | Cookie theft (XSS, network, logs, paste-to-other-browser) **and** infostealer malware reading the browser profile |
|
|
247
261
|
| `bound` | Web Crypto polyfill, non-extractable ECDSA P-256 key in IndexedDB | Cookie theft. Does not defeat infostealer malware on the user's machine. |
|
|
248
262
|
| `none` | No active / fresh binding | Nothing the cookie itself doesn't already do |
|
|
249
263
|
|
|
@@ -254,6 +268,23 @@ Tree-shaking eliminates anything you don't import. Using Koa, Hapi, raw `http`,
|
|
|
254
268
|
|
|
255
269
|
There is no third option, and **never gate a route on `tier === "dbsc"`** — that locks out every Firefox and Safari user (they can only reach `tier: "bound"`), and `requireProof()` already gives those browsers the same per-request guarantee via a signed proof. `requireProof()` is the one guard; it works on every browser. Read `res.locals.dbsc.tier` only if you want to *display* binding state in the UI — not to build a gate. Full guidance in [docs/security/best-practices.md](./docs/security/best-practices.md).
|
|
256
270
|
|
|
271
|
+
## Security model
|
|
272
|
+
|
|
273
|
+
`dbsc-toolkit` protects against:
|
|
274
|
+
|
|
275
|
+
- Stolen session cookies replayed from another device
|
|
276
|
+
- Stolen bearer tokens (same category — bearer == portable)
|
|
277
|
+
- Cookie exfiltration via XSS, network capture, log leakage, or proxy leakage
|
|
278
|
+
|
|
279
|
+
The Web Crypto polyfill (`tier: "bound"`) does **not** protect against:
|
|
280
|
+
|
|
281
|
+
- Malware already running on the user's machine with access to the browser profile
|
|
282
|
+
- Browser or OS compromise
|
|
283
|
+
|
|
284
|
+
Native DBSC (`tier: "dbsc"`) provides stronger protection against local malware because the private key lives inside the TPM or Secure Enclave — software cannot extract it even with admin access. The polyfill key is non-extractable to JavaScript, but the encrypted blob lives on disk and a sufficiently privileged attacker can reach it.
|
|
285
|
+
|
|
286
|
+
Neither tier is a substitute for HTTPS, input validation, strong passwords, or MFA.
|
|
287
|
+
|
|
257
288
|
## Going deeper
|
|
258
289
|
|
|
259
290
|
- **Concepts and protocol:** [HOW-IT-WORKS.md](./HOW-IT-WORKS.md)
|
|
@@ -270,7 +301,7 @@ There is no third option, and **never gate a route on `tier === "dbsc"`** — th
|
|
|
270
301
|
|
|
271
302
|
## Status
|
|
272
303
|
|
|
273
|
-
Verified end-to-end on Chrome 147 / Windows / TPM 2.0. Native DBSC
|
|
304
|
+
Verified end-to-end on Chrome 147 / Windows / TPM 2.0. Native DBSC requires Chromium 145+ on Windows or macOS Apple Silicon. The bound polyfill works on every browser with Web Crypto + IndexedDB (Firefox, Safari, mobile browsers, older Chromium). No third-party security audit yet. Production-readiness table and adoption guidance: [HOW-IT-WORKS.md#production-readiness](./HOW-IT-WORKS.md#production-readiness).
|
|
274
305
|
|
|
275
306
|
## License
|
|
276
307
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbsc-toolkit",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "Server-side Device Bound Session Credentials (DBSC) for Node.js plus a Web Crypto polyfill for Firefox, Safari, and older Chromium. Cookie-theft protection on every modern browser.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|