Skip to content

fix(journal): validate image uploads against the public origin - #71

Merged
davidvornholt merged 1 commit into
mainfrom
fix/image-upload-proxy-origin
Sep 10, 2026
Merged

fix(journal): validate image uploads against the public origin#71
davidvornholt merged 1 commit into
mainfrom
fix/image-upload-proxy-origin

Conversation

@davidvornholt

@davidvornholt davidvornholt commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Before. Pasting or uploading an image in production failed with “Upload images from the journal page.” The September 10 production log at 20:05:32 UTC records this rejection: Caddy terminates HTTPS, but Bun receives an HTTP request URL, so comparing its origin with the browser’s HTTPS origin rejects legitimate uploads before storage.

Now. Image uploads validate the browser origin against the existing configured public URL (BETTER_AUTH_URL). Pasting and file uploads can pass through the production proxy while cross-origin requests and requests without the upload marker remain rejected.

Implementation

The upload boundary supplies the configured public origin to the bounded body reader. Neither the request URL nor forwarded headers can authorize an origin. Regression coverage exercises HTTPS origins over HTTP transport, spoofed host and forwarding headers, missing/null/wrong-scheme origins, and missing/false upload markers. Existing size-limit coverage remains in place.

Verification

Completed checks

  • Deployed through personal-infra PR #339 and successful exact-commit run https://github.com/davidvornholt/personal-infra/actions/runs/34526622367; both hosts passed activation and service verification.

  • Production readback confirmed digest sha256:f6b7051ef8e212927e9ba9ae540ad1cce8be80d01466e76ed7d8dae30da056fd. Authenticated synthetic PNG upload over public HTTPS returned 200, authenticated image readback matched the original bytes, anonymous read redirected to sign-in (303), and the synthetic object was removed.

  • Reproduced the HTTP request URL / HTTPS browser origin mismatch with Bun inside the production container.

  • Focused image tests: 10 passed, 0 failed.

  • Web test suite: 631 passed, 0 failed.

  • Local DATABASE_URL=… nix develop --command bun run check against disposable PostgreSQL 18: 16 of 17 tasks passed (including lint, types, build, and unit tests). The 218-test browser task timed out on unrelated archive/navigation cases and stalled; terminated it after five minutes. The clean CI gate passed all 17 tasks, including the full browser suite: https://github.com/davidvornholt/postlude/actions/runs/34524804480.

  • Initial local attempts found stale installed dependencies and an incompatible stopped PostgreSQL 17 development container. Installed the frozen lockfile with the declared Bun 1.4.0 and used an isolated PostgreSQL 18 container; preserved existing local data.

@davidvornholt
davidvornholt merged commit bd236ad into main Sep 10, 2026
17 checks passed
@davidvornholt
davidvornholt deleted the fix/image-upload-proxy-origin branch September 10, 2026 20:17
@github-actions

Copy link
Copy Markdown
Contributor

State: removed

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