最新资讯
dev.to 我们在 DolphinBench 上测试记忆检索:纯关键词搜索暴露了自身回归 dev.to 别再把 Agent 写成 while 循环,把它建模为状态机 bloomberg.com Rightmove 与 Scout24 借 AI 产品应对低迷房市并上调展望 stackoverflow.blog 欢迎来到芯片时代:半导体制造、AI 数据中心与芯片设计的未来 www.youtube.com AI Agent 总犯同样的错:CentralAgent AI 将记忆重构为经验系统 pub.towardsai.net Netflix 科学家建议重采样 LLM 评判:5 次仅将误差棒缩小 13% pub.towardsai.net Jev 作为 LLM 前的静默层:构建提示感知的模型路由器 reddit.com OpenAI 称 Astra 仅满足 10% 安全任务标准 dev.to FreeToken:在自有 GPU 上运行前沿 MoE 模型及其内存需求 dev.to 当 AI Agent 说“完成”时,究竟完成了什么? dev.to 部署 Underdog Bark 3.0 Pro:逐字转写、自定义后端与分块设置 dev.to 为艰难对话构建 AI:五个 Agent、一条安全正则与一位盲评监督者
多元动态
登录 注册
行业动态 dev.to · @Hamze Zare

一个无法完全复现的存储型 XSS 报告,我们仍然做了加固

原文 我的收藏

开发者收到关于帮助台产品存储型 XSS 的报告:有人把内嵌 JavaScript 的 PDF 附到工单,客服打开时脚本在应用上下文中执行。核查发现下载路由自 2025 年 12 月起已强制 Content-Disposition: attachment 和 application/octet-stream,前端附件查看器没有 iframe、embed 或 object,非图片附件一律走 Blob 下载;上传已用 python-magic 读取真实文件字节而非浏览器声明的类型,并明确把 image/svg+xml 排除在白名单外。因此所述路径按原文很可能无法复现。作者仍做了加固:下载时从磁盘字节重新检测真实 MIME,只有白名单图片类型才内联返回,PDF 及未识别类型一律强制下载,并加上 X-Content-Type-Options: nosniff 和 sandbox CSP;新增四个测试并当天上线。作者总结的教训是,无法精确复现的漏洞报告仍值得细读,它指出了上传校验与下载信任之间的真实缺口。

AI推荐理由 这是一篇开发者安全复盘:作者收到存储型 XSS 报告后核查发现下载路由自 2025 年 12 月起强制 Content-Disposition: attachment 与 application/octet-stream,前端附件查看器无 iframe/embed/object,上传已用 python-magic 校验真实字节并排除 image/svg+xml,因此所述路径按原文很可能无法复现;作者仍在下载时重新检测真实 MIME、仅允许白名单图片内联,其余强制下载并加 X-Content-Type-Options: nosniff 与 sandbox CSP,新增四个测试并当天上线。具体新信息是上传校验与下载信任之间的缺口及修复代码,局限是单一产品、无漏洞编号或外部验证,且文中自述 AI 协助起草。

62

正文

A researcher named Dhruv emailed us to report a stored XSS path: someone attaches a PDF with embedded JavaScript to a support ticket in our helpdesk product, and when a support agent opens it, the script runs "in the context of the application." What we found when we checked The download route has forced Content-Disposition: attachment and application/octet-stream since December 2025 — confirmed with git blame. The frontend attachment viewer has zero iframe, embed, or object anywhere in the code; every non-image attachment goes through a Blob download, never an inline render. Uploads are already validated with python-magic, reading the real file bytes instead of trusting the browser's claimed content type, and image/svg+xml is explicitly excluded from the allow-list for exactly this reason — an SVG can carry a tag. So the exact path Dhruv described likely doesn't reproduce as written. That's still not a reason to leave the code as it was. What we changed anyway Upload-time validation only tells you what a file was when someone uploaded it. Nothing stops the stored bytes from being served differently later if some other code path changes. We closed that gap by re-detecting the real MIME type at download time too, from the same bytes on disk, not the type stored in the database: detected_type = magic.from_file(str(file_path), mime=True) is_image = FileStorageService.renders_inline_safely(detected_type) return FileResponse( path=str(file_path), filename=file_path.name, media_type=detected_type if is_image else "application/octet-stream", content_disposition_type="inline" if is_image else "attachment", headers={ "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; sandbox", }, ) Enter fullscreen mode Exit fullscreen mode Only an allow-listed image type is ever served as inline. Every PDF, and everything we don't explicitly recognize, is forced to download — now with nosniff and a sandboxed CSP on the response, so a browser can't decide otherwise even if some future code path opens the file directly. Four tests were added around this logic and it shipped to production the same day. The actual lesson A bug report that doesn't reproduce exactly as written is still worth reading carefully. Dhruv's email pointed at a real gap — not an exploitable one today, but a gap between what we validate at upload and what we trust at download. Closing that gap cost an afternoon. Finding out we needed to cost someone else's careful attention, and earned a reply thanking them for it. AI helped draft this write-up; the investigation, the code, and the fix are our own.

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容