From 0700bdacdb56f6179b255c756b058df3742f2a65 Mon Sep 17 00:00:00 2001 From: Cafe137 Date: Tue, 18 Jun 2024 11:50:04 +0200 Subject: [PATCH] fix: block invalid path --- src/proxy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/proxy.ts b/src/proxy.ts index f55744a..ef49d5e 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -10,6 +10,7 @@ import { getErrorMessage } from './utils' export const GET_PROXY_ENDPOINTS = ['/chunks/*', '/bytes/*', '/bzz/*', '/feeds/*'] export const POST_PROXY_ENDPOINTS = ['/chunks', '/bytes', '/bzz', '/soc/*', '/feeds/*'] +const BAD_PATH = `bzz/${'00'.repeat(32)}` const SWARM_STAMP_HEADER = 'swarm-postage-batch-id' const SWARM_PIN_HEADER = 'swarm-pin' @@ -57,6 +58,11 @@ export function createProxyEndpoints(app: Application, options: Options) { } }) app.get(GET_PROXY_ENDPOINTS, async (req, res) => { + if (req.path.includes(BAD_PATH)) { + res.status(400) + res.send({ error: 'bad path' }) + return + } await fetchAndRespond('GET', req.path, req.query, req.headers, req.body, res, options) }) app.post(POST_PROXY_ENDPOINTS, async (req, res) => {