@mrrlin-dev/mcp 0.4.126 → 0.4.127

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.
Files changed (2) hide show
  1. package/dist/bin.cjs +43 -4
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -63221,7 +63221,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
63221
63221
  }
63222
63222
 
63223
63223
  // src/_generated/version.ts
63224
- var PKG_VERSION = "0.4.126";
63224
+ var PKG_VERSION = "0.4.127";
63225
63225
 
63226
63226
  // src/receipt-signing.ts
63227
63227
  var import_node_crypto17 = __toESM(require("node:crypto"), 1);
@@ -69861,6 +69861,28 @@ function startArtifactsGc(baseStateDir, intervalMs = 10 * 60 * 1e3, options) {
69861
69861
  };
69862
69862
  }
69863
69863
 
69864
+ // src/bridge-host-guard.ts
69865
+ var LOOPBACK_HOST_NAMES = ["127.0.0.1", "localhost", "[::1]"];
69866
+ function hostHeaderName(host) {
69867
+ const lower = host.trim().toLowerCase();
69868
+ return lower.includes(":") && !lower.startsWith("[") ? `[${lower}]` : lower;
69869
+ }
69870
+ function isAllowedBridgeHost(hostHeader, opts) {
69871
+ const { port, configuredHost } = opts;
69872
+ if (!hostHeader || port === void 0) return false;
69873
+ const names = new Set(LOOPBACK_HOST_NAMES);
69874
+ if (configuredHost?.trim()) names.add(hostHeaderName(configuredHost));
69875
+ const actual = hostHeader.trim().toLowerCase();
69876
+ for (const name of names) {
69877
+ if (actual === `${name}:${port}`) return true;
69878
+ if (port === 80 && actual === name) return true;
69879
+ }
69880
+ return false;
69881
+ }
69882
+ function isAllowedBridgeRequestHost(req, configuredHost) {
69883
+ return isAllowedBridgeHost(req.headers.host, { port: req.socket.localPort, configuredHost });
69884
+ }
69885
+
69864
69886
  // src/chat-compaction.ts
69865
69887
  var DEFAULT_COMPACTION_SEED_BUDGET_BYTES = 8e3;
69866
69888
  var DEFAULT_COMPACTION_TIMEOUT_MS = 3e4;
@@ -76752,6 +76774,10 @@ function applyPnaHeaders(res, requestOrigin, allowed) {
76752
76774
  function createBridgeRequestListener(opts) {
76753
76775
  const { host, port, token, allowedOrigins, stateDir, getHealth } = opts;
76754
76776
  return (req, res) => {
76777
+ if (!isAllowedBridgeRequestHost(req, host)) {
76778
+ res.writeHead(421).end();
76779
+ return;
76780
+ }
76755
76781
  const requestOrigin = typeof req.headers.origin === "string" ? req.headers.origin : void 0;
76756
76782
  if (req.method === "OPTIONS") {
76757
76783
  applyPnaHeaders(res, requestOrigin, allowedOrigins);
@@ -76841,7 +76867,16 @@ function sessionIdOf(msg) {
76841
76867
  }
76842
76868
  function attachBridgeWss(server, opts) {
76843
76869
  const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex } = opts;
76844
- const wss = new import_websocket_server.default({ server, path: "/ws" });
76870
+ const wss = new import_websocket_server.default({
76871
+ server,
76872
+ path: "/ws",
76873
+ // The DNS-rebinding Host check from createBridgeRequestListener, applied to the upgrade: a bad
76874
+ // Host is answered 421 and the socket is never opened, so no `ready` frame goes out.
76875
+ verifyClient: (info, done) => {
76876
+ if (isAllowedBridgeRequestHost(info.req, opts.host)) done(true);
76877
+ else done(false, 421);
76878
+ }
76879
+ });
76845
76880
  wss.on("connection", (socket, request) => {
76846
76881
  const origin = request.headers.origin;
76847
76882
  if (!isOriginAllowed(origin, allowedOrigins)) {
@@ -78793,8 +78828,7 @@ async function startDirectorBridge() {
78793
78828
  inFlightRunIds: Array.from(consumerState.inFlightRunIds),
78794
78829
  inFlightCount: consumerState.inFlightRunIds.size,
78795
78830
  lastClaimAt: consumerState.lastClaimAt,
78796
- service: health.snapshot(),
78797
- localArtifactToken: config2.token
78831
+ service: health.snapshot()
78798
78832
  })
78799
78833
  })
78800
78834
  );
@@ -79058,6 +79092,7 @@ async function startDirectorBridge() {
79058
79092
  attachBridgeWss(server, {
79059
79093
  token: config2.token,
79060
79094
  allowedOrigins: config2.allowedOrigins,
79095
+ host: config2.host,
79061
79096
  onReady: createBridgeMessageHandler({
79062
79097
  ...sharedHandlerDeps,
79063
79098
  threads,
@@ -79111,6 +79146,10 @@ async function startDirectorBridge() {
79111
79146
  }
79112
79147
  const workerToken = readOrCreateWorkerToken();
79113
79148
  const dispatchServer = import_node_http3.default.createServer((req, res) => {
79149
+ if (!isAllowedBridgeRequestHost(req, "127.0.0.1")) {
79150
+ res.writeHead(421).end();
79151
+ return;
79152
+ }
79114
79153
  if (req.method !== "POST" || req.url !== "/worker/dispatch") {
79115
79154
  res.writeHead(404).end();
79116
79155
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.126",
3
+ "version": "0.4.127",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"