The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 13:15 UTC
fix(server): signed asset and upload URLs stay out of HTTP traces (#24556)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 29, 2026 at 12:56 UTC
4afdabab4479a68c7ea02d09174fe7936f084882
2 files changed
+70
-2
apps/server/src/http.test.ts
+63
@@ -13,7 +13,10 @@ import * as Layer from "effect/Layer";
13
import * as Path from "effect/Path";
14
import * as PlatformError from "effect/PlatformError";
15
import * as Queue from "effect/Queue";
16
+import * as Tracer from "effect/Tracer";
17
import { HttpClient, HttpClientRequest, HttpRouter, HttpServerResponse } from "effect/http";
18
+import { ASSET_ROUTE_PREFIX } from "./assets/AssetAccess.ts";
19
+import { ATTACHMENT_UPLOAD_ROUTE_PREFIX } from "./assets/AttachmentUpload.ts";
20
import { openMediaFile } from "./assets/MediaFile.ts";
21
22
import {
@@ -139,6 +142,66 @@ describe("browser API CORS", () => {
142
});
143
});
144
145
+describe("untraced requests", () => {
146
+ it.effect("keeps signed asset and upload URLs out of HTTP server spans", () =>
147
+ Effect.gen(function* () {
148
+ const serverSpans: Array<string> = [];
149
+ const layerTracer = Layer.succeed(
150
+ Tracer.Tracer,
151
+ Tracer.make({
152
+ span: (options) => {
153
+ if (options.kind === "server") serverSpans.push(options.name);
154
+ return new Tracer.NativeSpan(options);
155
+ },
156
+ }),
157
+ );
158
+ const layerRoutes = Layer.effectDiscard(
159
+ Effect.gen(function* () {
160
+ const router = yield* HttpRouter.HttpRouter;
161
+ yield* router.add("GET", `${ASSET_ROUTE_PREFIX}/*`, HttpServerResponse.empty());
162
+ yield* router.add(
163
+ "POST",
164
+ `${ATTACHMENT_UPLOAD_ROUTE_PREFIX}/*`,
165
+ HttpServerResponse.empty(),
166
+ );
167
+ yield* router.add("GET", "/api/environment", HttpServerResponse.empty());
168
+ }),
169
+ );
170
+ const services = yield* Layer.build(
171
+ HttpRouter.serve(layerRoutes, { disableListenLog: true, disableLogger: true }).pipe(
172
+ ServerHttp.withUntracedRequests,
173
+ Layer.provideMerge(NodeHttpServer.layerTest),
174
+ Layer.provide(layerTracer),
175
+ ),
176
+ );
177
+ const client = Context.get(services, HttpClient.HttpClient);
178
+
179
+ // Each URL is a bearer credential: url.full and url.path would carry it.
180
+ for (const request of [
181
+ HttpClientRequest.get(`${ASSET_ROUTE_PREFIX}/payload.signature/image.png`),
182
+ HttpClientRequest.get(`${ASSET_ROUTE_PREFIX}/payload.signature/image.png?v=1`),
183
+ HttpClientRequest.post(`${ATTACHMENT_UPLOAD_ROUTE_PREFIX}/payload.signature`),
184
+ HttpClientRequest.post(`${ATTACHMENT_UPLOAD_ROUTE_PREFIX}/payload.signature?v=1`),
185
+ HttpClientRequest.head(`${ASSET_ROUTE_PREFIX}/payload.signature/image.png`),
186
+ ]) {
187
+ expect((yield* client.execute(request)).status).toBe(204);
188
+ }
189
+ expect(serverSpans).toEqual([]);
190
+
191
+ expect((yield* client.execute(HttpClientRequest.get("/api/environment"))).status).toBe(204);
192
+ expect(serverSpans).toEqual(["GET"]);
193
+
194
+ for (const path of [
195
+ `${ASSET_ROUTE_PREFIX}-other/file`,
196
+ `${ATTACHMENT_UPLOAD_ROUTE_PREFIX}-other/token`,
197
+ ]) {
198
+ expect((yield* client.execute(HttpClientRequest.get(path))).status).toBe(404);
199
+ }
200
+ expect(serverSpans).toEqual(["GET", "GET", "GET"]);
201
+ }).pipe(Effect.provide(NodeServices.layer)),
202
+ );
203
+});
204
+
205
const layerFileResponse = Layer.mergeAll(NodeHttpPlatform.layer, NodeServices.layer);
206
207
const makeStaticRequest = Effect.fn("HttpTest.makeStaticRequest")(function* (staticDir: string) {
apps/server/src/http.ts
+7
-2
@@ -391,8 +391,13 @@ const UNTRACED_REQUEST_PATHS: ReadonlySet<string> = new Set([OTLP_TRACES_PROXY_P
391
const layerUntracedRequests = Layer.succeed(HttpMiddleware.TracerDisabledWhen)((request) => {
392
const queryIndex = request.url.indexOf("?");
393
const path = queryIndex === -1 ? request.url : request.url.slice(0, queryIndex);
394
- // Webhook URLs carry their secret token in the path, so they never reach a trace.
395
- return UNTRACED_REQUEST_PATHS.has(path) || path.startsWith(`${WEBHOOK_ROUTE_PREFIX}/`);
394
+ // Signed URLs carry bearer tokens in the path, so they never reach a trace.
395
+ return (
396
+ UNTRACED_REQUEST_PATHS.has(path) ||
397
+ path.startsWith(`${WEBHOOK_ROUTE_PREFIX}/`) ||
398
+ path.startsWith(`${ASSET_ROUTE_PREFIX}/`) ||
399
+ path.startsWith(`${ATTACHMENT_UPLOAD_ROUTE_PREFIX}/`)
400
+ );
401
});
402
403
export const withUntracedRequests = Layer.provide(layerUntracedRequests);