@blockrun/franklin 3.49.2 → 3.49.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/dist/panel/server.js +20 -1
- package/dist/session/storage.js +4 -0
- package/package.json +1 -1
package/dist/panel/server.js
CHANGED
|
@@ -72,6 +72,17 @@ function isTrustedPanelOrigin(req) {
|
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
function isLocalHostHeader(req) {
|
|
76
|
+
const host = req.headers.host;
|
|
77
|
+
if (!host)
|
|
78
|
+
return false;
|
|
79
|
+
try {
|
|
80
|
+
return isLocalHostname(new URL(`http://${host}`).hostname);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
75
86
|
function isLocalPanelRequest(req) {
|
|
76
87
|
return isLoopback(req) && isTrustedPanelOrigin(req);
|
|
77
88
|
}
|
|
@@ -128,6 +139,15 @@ export function createPanelServer(port) {
|
|
|
128
139
|
try {
|
|
129
140
|
const url = new URL(req.url || '/', `http://localhost:${port}`);
|
|
130
141
|
const p = url.pathname;
|
|
142
|
+
// Every route, read-only ones included: session transcripts and the audit
|
|
143
|
+
// log are as sensitive as the wallet routes. Loopback alone does not stop
|
|
144
|
+
// DNS rebinding (a page on attacker.example re-resolved to 127.0.0.1), so
|
|
145
|
+
// the Host header must name a local host too.
|
|
146
|
+
if (!isLoopback(req) || !isLocalHostHeader(req)) {
|
|
147
|
+
res.writeHead(403, { 'Content-Type': 'text/plain' });
|
|
148
|
+
res.end('Forbidden');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
131
151
|
// ─── HTML ──
|
|
132
152
|
if (p === '/') {
|
|
133
153
|
res.writeHead(200, {
|
|
@@ -163,7 +183,6 @@ export function createPanelServer(port) {
|
|
|
163
183
|
'Content-Type': 'text/event-stream',
|
|
164
184
|
'Cache-Control': 'no-cache',
|
|
165
185
|
'Connection': 'keep-alive',
|
|
166
|
-
'Access-Control-Allow-Origin': '*',
|
|
167
186
|
});
|
|
168
187
|
res.write('data: {"type":"connected"}\n\n');
|
|
169
188
|
sseClients.add(res);
|
package/dist/session/storage.js
CHANGED
|
@@ -54,6 +54,10 @@ function getSessionsDir() {
|
|
|
54
54
|
return resolvedSessionsDir;
|
|
55
55
|
}
|
|
56
56
|
function sessionPath(id) {
|
|
57
|
+
// Ids reach here from URLs (panel /api/sessions/:id); never let one escape the sessions dir.
|
|
58
|
+
if (!id || id !== path.basename(id) || id.includes('..') || id.includes('\0')) {
|
|
59
|
+
throw new Error(`Invalid session id: ${JSON.stringify(id)}`);
|
|
60
|
+
}
|
|
57
61
|
return path.join(getSessionsDir(), `${id}.jsonl`);
|
|
58
62
|
}
|
|
59
63
|
/** Get the absolute path to a session's JSONL file (for external readers like search). */
|
package/package.json
CHANGED