Skip to content

fix(storage,upload): validate content ids + enforce multipart file limits#103

Merged
MorganOnCode merged 1 commit into
masterfrom
fix/resource-server-input-limits
May 28, 2026
Merged

fix(storage,upload): validate content ids + enforce multipart file limits#103
MorganOnCode merged 1 commit into
masterfrom
fix/resource-server-input-limits

Conversation

@MorganOnCode
Copy link
Copy Markdown
Owner

Summary

Re-derived per-concern slice from the closed #88 — resource-server input bounds.

  • download (/files/:cid): validate the content id against supported formats (sha256 hex, IPFS CIDv0, CIDv1 base32) before hitting any storage backend — rejects attacker-controlled identifiers and avoids oversized arbitrary IPFS lookups. Returns 400 "invalid" instead of passing junk downstream.
  • upload (/upload): pass explicit multipart limits to request.file() (fileSize 10 MiB, files 1, fields 0, parts 1) so oversized/multi-part uploads are rejected before any storage write.
  • Tests: updated to valid CIDs (old fixtures used non-CID strings the new validator rejects) + new coverage for non-hex CID and over-limit upload.

Scope discipline

Dropped a metrics config fixture #88 had entangled into these test files (caught by tsc — that field belongs to the gated config-production PR, not here).

Risk

Low: facilitator-only, config-compatible, tighter input validation on resource-server routes. Verified: typecheck clean, 461 root tests pass.

Part of re-delivering #88's hardening as focused, individually-reviewable PRs.

🤖 Generated with Claude Code

…mits

Re-derived per-concern slice from the closed #88 (resource-server input bounds).

- download (/files/:cid): validate the content id against supported formats
  (sha256 hex, IPFS CIDv0, CIDv1 base32) before hitting any storage backend —
  rejects attacker-controlled identifiers + avoids oversized arbitrary IPFS
  lookups. Returns 400 "invalid" instead of passing junk to the backend.
- upload (/upload): pass explicit multipart limits to request.file()
  (fileSize 10MiB, files 1, fields 0, parts 1) so oversized/multi-part uploads
  are rejected before any storage write.
- Tests updated to use valid CIDs (the old fixtures used non-CID strings the new
  validator rejects) + new coverage for non-hex CID + over-limit upload.

Deliberately dropped a `metrics` config fixture that #88 had entangled into
these test files (it belongs to the gated config-production PR). Config-compatible,
facilitator-only. Verified: typecheck clean, 461 root tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MorganOnCode MorganOnCode merged commit 6e82db6 into master May 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant