@chatpanel/bridge 0.10.12 → 0.10.14
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/LICENSE +132 -74
- package/README.md +16 -0
- package/package.json +1 -1
- package/src/server.js +8 -26
- package/src/ssrf.js +102 -0
package/LICENSE
CHANGED
|
@@ -1,110 +1,168 @@
|
|
|
1
|
-
#
|
|
1
|
+
# PolyForm Shield License 1.0.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Required Notice: Copyright © 2026 ChatPanel (https://chatpanel.net)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Licensor Line of Business: ChatPanel — an AI browser side-panel, its local
|
|
8
|
+
bridge, and related developer tools and services (https://chatpanel.net)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
## Acceptance
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
In order to get any license under these terms, you must agree
|
|
13
|
+
to them as both strict obligations and conditions to all
|
|
14
|
+
your licenses.
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## Copyright License
|
|
14
17
|
|
|
15
|
-
The
|
|
18
|
+
The licensor grants you a copyright license for the
|
|
19
|
+
software to do everything you might do with the software
|
|
20
|
+
that would otherwise infringe the licensor's copyright
|
|
21
|
+
in it for any permitted purpose. However, you may
|
|
22
|
+
only distribute the software according to [Distribution
|
|
23
|
+
License](#distribution-license) and make changes or new works
|
|
24
|
+
based on the software according to [Changes and New Works
|
|
25
|
+
License](#changes-and-new-works-license).
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
## Distribution License
|
|
18
28
|
|
|
19
|
-
The
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
The licensor grants you an additional copyright license to
|
|
30
|
+
distribute copies of the software. Your license to distribute
|
|
31
|
+
covers distributing the software with changes and new works
|
|
32
|
+
permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
22
33
|
|
|
23
|
-
|
|
34
|
+
## Notices
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
You must ensure that anyone who gets a copy of any part of
|
|
37
|
+
the software from you also gets a copy of these terms or the
|
|
38
|
+
URL for them above, as well as copies of any plain-text lines
|
|
39
|
+
beginning with `Required Notice:` that the licensor provided
|
|
40
|
+
with the software. For example:
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
> Required Notice: Copyright © 2026 ChatPanel (https://chatpanel.net)
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
means making the Software available to others in a commercial product or
|
|
34
|
-
service that:
|
|
44
|
+
## Changes and New Works License
|
|
35
45
|
|
|
36
|
-
|
|
46
|
+
The licensor grants you an additional copyright license to
|
|
47
|
+
make changes and new works based on the software for any
|
|
48
|
+
permitted purpose.
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
that exists as of the date we make the Software available; or
|
|
50
|
+
## Patent License
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
The licensor grants you a patent license for the software that
|
|
53
|
+
covers patent claims the licensor can license, or becomes able
|
|
54
|
+
to license, that you would infringe by using the software.
|
|
42
55
|
|
|
43
|
-
|
|
56
|
+
## Noncompete
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
Any purpose is a permitted purpose, except for providing any
|
|
59
|
+
product that competes with the software or any product the
|
|
60
|
+
licensor or any of its affiliates provides using the software.
|
|
46
61
|
|
|
47
|
-
|
|
62
|
+
## Competition
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
Goods and services compete even when they provide functionality
|
|
65
|
+
through different kinds of interfaces or for different technical
|
|
66
|
+
platforms. Applications can compete with services, libraries
|
|
67
|
+
with plugins, frameworks with development tools, and so on,
|
|
68
|
+
even if they're written in different programming languages
|
|
69
|
+
or for different computer architectures. Goods and services
|
|
70
|
+
compete even when provided free of charge. If you market a
|
|
71
|
+
product as a practical substitute for the software or another
|
|
72
|
+
product, it definitely competes.
|
|
50
73
|
|
|
51
|
-
|
|
52
|
-
using the Software in accordance with these Terms and Conditions.
|
|
74
|
+
## New Products
|
|
53
75
|
|
|
54
|
-
|
|
76
|
+
If you are using the software to provide a product that does
|
|
77
|
+
not compete, but the licensor or any of its affiliates brings
|
|
78
|
+
your product into competition by providing a new version of
|
|
79
|
+
the software or another product using the software, you may
|
|
80
|
+
continue using versions of the software available under these
|
|
81
|
+
terms beforehand to provide your competing product, but not
|
|
82
|
+
any later versions.
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
patents, the license grant above includes a license under our patents. If you
|
|
58
|
-
make a claim against any party that the Software infringes or contributes to
|
|
59
|
-
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
-
immediately.
|
|
84
|
+
## Discontinued Products
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
You may begin using the software to compete with a product
|
|
87
|
+
or service that the licensor or any of its affiliates has
|
|
88
|
+
stopped providing, unless the licensor includes a plain-text
|
|
89
|
+
line beginning with `Licensor Line of Business:` with the
|
|
90
|
+
software that mentions that line of business. For example:
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
> Licensor Line of Business: ChatPanel — an AI browser side-panel, its local
|
|
93
|
+
> bridge, and related developer tools and services (https://chatpanel.net)
|
|
66
94
|
|
|
67
|
-
|
|
68
|
-
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
-
remove any copyright notices provided in or with the Software.
|
|
95
|
+
## Sales of Business
|
|
70
96
|
|
|
71
|
-
|
|
97
|
+
If the licensor or any of its affiliates sells a line of
|
|
98
|
+
business developing the software or using the software
|
|
99
|
+
to provide a product, the buyer can also enforce
|
|
100
|
+
Noncompete for that product.
|
|
72
101
|
|
|
73
|
-
|
|
74
|
-
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
-
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
102
|
+
## Fair Use
|
|
76
103
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
104
|
+
You may have "fair use" rights for the software under the
|
|
105
|
+
law. These terms do not limit them.
|
|
80
106
|
|
|
81
|
-
|
|
107
|
+
## No Other Rights
|
|
82
108
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
109
|
+
These terms do not allow you to sublicense or transfer any of
|
|
110
|
+
your licenses to anyone else, or prevent the licensor from
|
|
111
|
+
granting licenses to anyone else. These terms do not imply
|
|
112
|
+
any other licenses.
|
|
86
113
|
|
|
87
|
-
##
|
|
114
|
+
## Patent Defense
|
|
88
115
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
the
|
|
92
|
-
|
|
116
|
+
If you make any written claim that the software infringes or
|
|
117
|
+
contributes to infringement of any patent, your patent license
|
|
118
|
+
for the software granted under these terms ends immediately. If
|
|
119
|
+
your company makes such a claim, your patent license ends
|
|
120
|
+
immediately for work on behalf of your company.
|
|
93
121
|
|
|
94
|
-
|
|
95
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
-
the Software without restriction, including without limitation the rights to
|
|
97
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
-
so, subject to the following conditions:
|
|
122
|
+
## Violations
|
|
100
123
|
|
|
101
|
-
The
|
|
102
|
-
|
|
124
|
+
The first time you are notified in writing that you have
|
|
125
|
+
violated any of these terms, or done anything with the software
|
|
126
|
+
not covered by your licenses, your licenses can nonetheless
|
|
127
|
+
continue if you come into full compliance with these terms,
|
|
128
|
+
and take practical steps to correct past violations, within
|
|
129
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
130
|
+
end immediately.
|
|
103
131
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
## No Liability
|
|
133
|
+
|
|
134
|
+
***As far as the law allows, the software comes as is, without
|
|
135
|
+
any warranty or condition, and the licensor will not be liable
|
|
136
|
+
to you for any damages arising out of these terms or the use
|
|
137
|
+
or nature of the software, under any kind of legal claim.***
|
|
138
|
+
|
|
139
|
+
## Definitions
|
|
140
|
+
|
|
141
|
+
The **licensor** is the individual or entity offering these
|
|
142
|
+
terms, and the **software** is the software the licensor makes
|
|
143
|
+
available under these terms.
|
|
144
|
+
|
|
145
|
+
A **product** can be a good or service, or a combination
|
|
146
|
+
of them.
|
|
147
|
+
|
|
148
|
+
**You** refers to the individual or entity agreeing to these
|
|
149
|
+
terms.
|
|
150
|
+
|
|
151
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
152
|
+
or other kind of organization that you work for, plus all
|
|
153
|
+
its affiliates.
|
|
154
|
+
|
|
155
|
+
**Affiliates** means the other organizations that an
|
|
156
|
+
organization has control over, is under the control of, or is
|
|
157
|
+
under common control with.
|
|
158
|
+
|
|
159
|
+
**Control** means ownership of substantially all the assets of
|
|
160
|
+
an entity, or the power to direct its management and policies
|
|
161
|
+
by vote, contract, or otherwise. Control can be direct or
|
|
162
|
+
indirect.
|
|
163
|
+
|
|
164
|
+
**Your licenses** are all the licenses granted to you for the
|
|
165
|
+
software under these terms.
|
|
166
|
+
|
|
167
|
+
**Use** means anything you do with the software requiring one
|
|
168
|
+
of your licenses.
|
package/README.md
CHANGED
|
@@ -124,3 +124,19 @@ macOS (launchd) example — save to `~/Library/LaunchAgents/app.chatpanel.bridge
|
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
Then `launchctl load ~/Library/LaunchAgents/app.chatpanel.bridge.plist`.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
**Source-available**, under the [**PolyForm Shield License 1.0.0**](LICENSE).
|
|
131
|
+
Read, audit, run, and modify it for your own use — you just may not use it to
|
|
132
|
+
provide a product or service that **competes** with ChatPanel. The
|
|
133
|
+
[extension](https://github.com/chatpanel/chatpanel-extension) is under the same
|
|
134
|
+
license. This is *not* an OSI "open source" license; the source is published for
|
|
135
|
+
transparency and trust (this bridge runs on your machine with file access, so it
|
|
136
|
+
should be auditable), not for re-packaging or resale.
|
|
137
|
+
|
|
138
|
+
## Trademarks & brand
|
|
139
|
+
|
|
140
|
+
The name **“ChatPanel”**, the logo, and brand assets are **trademarks of ChatPanel,
|
|
141
|
+
not licensed** under the terms above — the Shield license covers the code only.
|
|
142
|
+
Don't redistribute a fork (e.g. to npm) under the ChatPanel name or marks.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatpanel/bridge",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local bridge that exposes the AI coding agents installed on your machine — Claude Code (CLI), Codex (CLI), and Gemini CLI — to the ChatPanel Chrome extension over a localhost SSE endpoint. Bring your own agent.",
|
|
6
6
|
"keywords": [
|
package/src/server.js
CHANGED
|
@@ -32,11 +32,12 @@ import { installService, uninstallService, serviceStatus, restartService } from
|
|
|
32
32
|
import { AGENT_CLIS, enrichPath, findAgentBin, resolveCommand } from './env.js';
|
|
33
33
|
import { checkForUpdate, selfUpdate } from './update.js';
|
|
34
34
|
import { callLocalMcp } from './mcp-local.js';
|
|
35
|
+
import { assertPublicHttpUrl } from './ssrf.js';
|
|
35
36
|
|
|
36
37
|
// Hardcoded (not read from package.json) so it survives Bun's single-file
|
|
37
38
|
// --compile, where package.json isn't on a readable FS. CI fails the publish if
|
|
38
39
|
// this drifts from package.json, so the two can't silently diverge.
|
|
39
|
-
const VERSION = '0.10.
|
|
40
|
+
const VERSION = '0.10.14';
|
|
40
41
|
const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
|
|
41
42
|
const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
|
|
42
43
|
|
|
@@ -233,31 +234,12 @@ const PRIVILEGED_POST = new Set([
|
|
|
233
234
|
]);
|
|
234
235
|
const PRIVILEGED_GET = new Set(['/debug']);
|
|
235
236
|
|
|
236
|
-
// SSRF guard for /mcp-remote
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (h === '::1' || h === '::' || h.startsWith('fc') || h.startsWith('fd') || h.startsWith('fe8') || h.startsWith('fe9') || h.startsWith('fea') || h.startsWith('feb')) return true;
|
|
243
|
-
const m = h.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
244
|
-
if (m) {
|
|
245
|
-
const a = Number(m[1]), b = Number(m[2]);
|
|
246
|
-
if (a === 0 || a === 127 || a === 10) return true; // this-host / loopback / RFC1918
|
|
247
|
-
if (a === 169 && b === 254) return true; // link-local + cloud metadata
|
|
248
|
-
if (a === 172 && b >= 16 && b <= 31) return true; // RFC1918
|
|
249
|
-
if (a === 192 && b === 168) return true; // RFC1918
|
|
250
|
-
if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT
|
|
251
|
-
}
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
function assertPublicHttpUrl(u) {
|
|
255
|
-
let parsed;
|
|
256
|
-
try { parsed = new URL(u); } catch { throw new Error(`invalid URL: ${u}`); }
|
|
257
|
-
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') throw new Error(`only http(s) URLs allowed (got "${parsed.protocol}")`);
|
|
258
|
-
if (isBlockedHttpHost(parsed.hostname)) throw new Error(`refusing to proxy a private/loopback/metadata address (${parsed.hostname})`);
|
|
259
|
-
return parsed;
|
|
260
|
-
}
|
|
237
|
+
// SSRF guard for /mcp-remote lives in ./ssrf.js (assertPublicHttpUrl). Loopback
|
|
238
|
+
// is allowed (the user's own localhost MCP server — the common "via bridge"
|
|
239
|
+
// case; the extension can reach it directly anyway), cloud metadata is always
|
|
240
|
+
// blocked, and other private/LAN ranges are blocked unless the operator sets
|
|
241
|
+
// CHATPANEL_BRIDGE_ALLOW_PRIVATE_HOSTS=1. Checked on the initial URL AND after
|
|
242
|
+
// any redirect.
|
|
261
243
|
|
|
262
244
|
// Returns an error code if the request must be blocked, else null.
|
|
263
245
|
function guard(req, pathname) {
|
package/src/ssrf.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// SSRF guard for the /mcp-remote proxy.
|
|
2
|
+
//
|
|
3
|
+
// The bridge proxies ONE JSON-RPC message to a remote MCP server *from this
|
|
4
|
+
// machine* (no browser Origin header), so the extension can reach servers that
|
|
5
|
+
// reject browser origins. That route is already privileged — it requires the
|
|
6
|
+
// extension origin or the per-install bridge token, so a random web page cannot
|
|
7
|
+
// drive it. This guard is the second layer: even when driven by the extension,
|
|
8
|
+
// the bridge must not become a relay that a prompt-injected agent could point at
|
|
9
|
+
// cloud metadata or use to sweep the LAN.
|
|
10
|
+
//
|
|
11
|
+
// Policy:
|
|
12
|
+
// • Loopback (127.0.0.0/8, ::1, localhost, *.localhost) → ALLOWED.
|
|
13
|
+
// It's the user's own host — the same place the bridge runs, and a place the
|
|
14
|
+
// extension can already fetch DIRECTLY. Proxying it grants no new reach; it
|
|
15
|
+
// only drops the browser Origin header (the whole point of "via bridge").
|
|
16
|
+
// Localhost MCP servers are the common case.
|
|
17
|
+
// • Cloud instance metadata (169.254.169.254) → ALWAYS BLOCKED.
|
|
18
|
+
// This is the sharpest SSRF target (credential theft) and is blocked even
|
|
19
|
+
// when private hosts are opted in.
|
|
20
|
+
// • Everything else private/internal (RFC1918, CGNAT, link-local, IPv6 ULA,
|
|
21
|
+
// 0.0.0.0, ::, *.local) → BLOCKED, unless the operator opts in with
|
|
22
|
+
// CHATPANEL_BRIDGE_ALLOW_PRIVATE_HOSTS=1 (for reaching an MCP server on
|
|
23
|
+
// another machine on a trusted LAN).
|
|
24
|
+
// • Non-http(s) schemes → BLOCKED.
|
|
25
|
+
//
|
|
26
|
+
// The same checks run on the initial URL AND after any redirect.
|
|
27
|
+
|
|
28
|
+
const ALLOW_PRIVATE_HOSTS = /^(1|true|yes|on)$/i.test(
|
|
29
|
+
process.env.CHATPANEL_BRIDGE_ALLOW_PRIVATE_HOSTS || '',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
function ipv4(h) {
|
|
33
|
+
const m = h.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
34
|
+
if (!m) return null;
|
|
35
|
+
const o = m.slice(1).map(Number);
|
|
36
|
+
if (o.some((n) => n > 255)) return null;
|
|
37
|
+
return o;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Loopback = this host's own services. Reachable by the extension directly, so
|
|
41
|
+
// allowing the bridge to reach it adds no capability.
|
|
42
|
+
export function isLoopbackHost(hostname) {
|
|
43
|
+
const h = String(hostname || '').toLowerCase().replace(/^\[|\]$/g, '');
|
|
44
|
+
if (!h) return false;
|
|
45
|
+
if (h === 'localhost' || h.endsWith('.localhost')) return true;
|
|
46
|
+
if (h === '::1') return true;
|
|
47
|
+
const o = ipv4(h);
|
|
48
|
+
return !!(o && o[0] === 127);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Cloud instance metadata — credential-theft vector. Always blocked.
|
|
52
|
+
function isMetadataHost(hostname) {
|
|
53
|
+
const o = ipv4(hostname);
|
|
54
|
+
return !!(o && o[0] === 169 && o[1] === 254);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function isBlockedHttpHost(hostname) {
|
|
58
|
+
const h = String(hostname || '').toLowerCase().replace(/^\[|\]$/g, '');
|
|
59
|
+
if (!h) return true;
|
|
60
|
+
if (isLoopbackHost(h)) return false; // user's own host — allowed
|
|
61
|
+
if (isMetadataHost(h)) return true; // never proxy cloud metadata, even when private is opted in
|
|
62
|
+
if (ALLOW_PRIVATE_HOSTS) return false; // operator opted in to LAN/private targets
|
|
63
|
+
|
|
64
|
+
// Default deny for the rest of the private/internal space.
|
|
65
|
+
if (h.endsWith('.local')) return true; // mDNS / LAN
|
|
66
|
+
if (
|
|
67
|
+
h === '::' ||
|
|
68
|
+
h.startsWith('fc') ||
|
|
69
|
+
h.startsWith('fd') || // IPv6 ULA
|
|
70
|
+
h.startsWith('fe8') ||
|
|
71
|
+
h.startsWith('fe9') ||
|
|
72
|
+
h.startsWith('fea') ||
|
|
73
|
+
h.startsWith('feb') // IPv6 link-local
|
|
74
|
+
) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const o = ipv4(h);
|
|
78
|
+
if (o) {
|
|
79
|
+
const [a, b] = o;
|
|
80
|
+
if (a === 0 || a === 10) return true; // this-host / RFC1918
|
|
81
|
+
if (a === 172 && b >= 16 && b <= 31) return true; // RFC1918
|
|
82
|
+
if (a === 192 && b === 168) return true; // RFC1918
|
|
83
|
+
if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function assertPublicHttpUrl(u) {
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = new URL(u);
|
|
92
|
+
} catch {
|
|
93
|
+
throw new Error(`invalid URL: ${u}`);
|
|
94
|
+
}
|
|
95
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
96
|
+
throw new Error(`only http(s) URLs allowed (got "${parsed.protocol}")`);
|
|
97
|
+
}
|
|
98
|
+
if (isBlockedHttpHost(parsed.hostname)) {
|
|
99
|
+
throw new Error(`refusing to proxy a private/metadata address (${parsed.hostname})`);
|
|
100
|
+
}
|
|
101
|
+
return parsed;
|
|
102
|
+
}
|