Harden client-warm cache writes against forged card and poster images
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- nextjs, typescript
调研方向
Start at app/api/cache-image/route.ts, then read components/WarmOnView.tsx to see how warm writes are triggered and lib/og/pngCache.ts for the cache key and expected card/poster dimensions. Check scripts/warm.mjs because it currently treats locally warmed handles as final, which affects how poisoned entries survive. Done means the route rejects unsigned/expired writes, invalid PNG bytes and wrong dimensions, enforces a documented write limit, and has tests covering unsigned, signed, bad bytes, wrong dimensions and the limit.
由索引模型根据 Issue 内容生成。
描述
Summary
POST /api/cache-image stores client-supplied bytes in R2 under a cache key built from the query string. It does not authenticate the caller, verify that the bytes are a PNG, or rate-limit writes. A third party can seed a valid-looking handle or pair with arbitrary image bytes; the card and poster routes will serve those bytes until the entry is replaced or expires.
This is a cache-poisoning and storage-abuse path, not a cosmetic issue.
Evidence
app/api/cache-image/route.ts:10-37acceptskind,login,aandb; it checks only the login shape and a 200 KB to 4 MB size before writing toGITONE_PNGS.components/WarmOnView.tsx:51-55makes the same route reachable from any public profile page.lib/og/pngCache.ts:80-86serves the stored object directly asimage/png.scripts/warm.mjs:139-142treats a handle as warmed once it is in local state, so a poisoned object can survive later warmer runs.
Expected behavior
- A warm write must prove it came from the app. Use a short-lived HMAC over
kind, the exact key, and an expiry, generated by the page or server and checked by the route. - Reject bytes that are not a valid PNG. Reject dimensions that do not match the card or poster contract.
- Add a per-IP or global write budget and a structured log line for rejected writes.
- Keep reads public; only writes need the token.
Scope
app/api/cache-image/route.tscomponents/WarmOnView.tsxlib/og/pngCache.tsfor the expected dimensions / key helpers- tests for the route
Acceptance
- Unsigned or expired warm requests return 401/403.
- A correctly signed request still stores and serves the image.
- A file with a bad PNG header or wrong dimensions returns 400 and writes nothing.
- Repeated writes are bounded by a documented limit.
- Tests cover unsigned, signed, bad bytes, wrong dimensions and the limit.
- 主要语言
- TypeScript
- 星标
- 7
- 派生
- 0
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
LangerSword/gitone 的其他 Issue
-
bug help wanted
难度 2/5 1-3 小时 新手友好度 80/100
LangerSword/gitone#7 ·
-
accessibility bug help wanted
难度 2/5 1-3 小时 新手友好度 78/100
LangerSword/gitone#6 ·
-
bug help wanted
难度 3/5 1-2 天 新手友好度 72/100
LangerSword/gitone#5 ·
-
bug help wanted
难度 3/5 半天 新手友好度 72/100
LangerSword/gitone#4 ·
-
Add a /health endpoint可能已有人在做 @LangerSword 今天认领。 未关闭good first issue
难度 1/5 1-3 小时 新手友好度 45/100
LangerSword/gitone#2 · 1 条评论 ·
查看 LangerSword/gitone 的全部 Issue
相似的 Issue
-
MCP tool results drop structuredContent when text is only a summary可能已有人在做 @Pankaj-bit361 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
inblockio/siwx-oidc-matrix-server#101 ·
维护者通常 1 天内回复
-
status:needs-triage
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pingdotgg/t3code#42253 · 1 条评论 ·
维护者通常 1 天内回复