关键信息 漏洞描述 问题: 中间件路径匹配未正确处理URL编码的路径,导致编码路径如 在中间件检查前未被正确解码为 ,可能绕过安全检查。 修复: 规范化URL编码的路径,确保 等编码路径在中间件检查前正确解码为 ,从而防止通过URL编码绕过中间件检查。 修复细节 规范化路径匹配 - Dev服务器请求处理中规范化路径名 - SSR渲染上下文( )中规范化路径名 - 中间件中添加路径编码测试 代码变更示例 typescript protected url = new URL(request.url), typescript protected url = RenderContext.#createNormalizedUrl(request.url), typescript static #createNormalizedUrl(requestUrl: string): URL { const url = new URL(requestUrl); try { url.pathname = decodeURI(url.pathname); } finally { return url; } } markdown it('should protect /admin route with auth check', async () => { const res = await fixture.fetch('/admin', { redirect: 'manual' }); assert.equal(res.status, 302); assert.equal(res.headers.get('location'), '/'); }); markdown it('should NOT allow accessing /admin with url encoding', async () => { const res = await fixture.fetch('/%61dmin', { redirect: 'manual' }); assert.equal(res.status, 302); assert.equal(res.headers.get('location'), '/'); }); ``` 总结 此次修复主要解决了中间件路径检查中可能存在的URL编码绕过问题,通过规范化处理URL编码确保路径正确解析,有效提升了相关中间件的安全性。