Skip to content

fix(locksmith): block private URLs in OG/certification image fetch - #16595

Open
SashaMIT wants to merge 2 commits into
unlock-protocol:masterfrom
SashaMIT:fix/og-image-ssrf
Open

fix(locksmith): block private URLs in OG/certification image fetch#16595
SashaMIT wants to merge 2 commits into
unlock-protocol:masterfrom
SashaMIT:fix/og-image-ssrf

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 9, 2026

Copy link
Copy Markdown

Why

Unauthenticated GET /v2/og/event/... (and certification) fetch lock metadata.image / event_cover_image through imageURLToDataURI with bare fetch and no scheme/private/redirect guard.

Distinct from #16593 (WebSub hub.callback) and #16594 (Apple Wallet thumbnail). Same SSRF class; this PR introduces the shared assertSafeCallbackUrl helper for the image path (sibling PRs add the same helper for their sinks — land one first and rebase the others if needed).

Fix

  • Add assertSafeCallbackUrl (http(s) + DNS private/link-local/CGNAT block)
  • Call it in imageURLToDataURI before fetch with redirect: 'error'

Test plan

  • yarn vitest run __tests__/utils/image.test.ts __tests__/utils/safeCallbackUrl.test.ts (6/6)
  • Public https lock images still render in OG
  • http://127.0.0.1/... / metadata IP fail closed (fallback / throw)

Made with Cursor

imageURLToDataURI bare-fetched metadata.image / event_cover_image on
unauth OG routes. Reuse assertSafeCallbackUrl and disable redirects.
@cla-bot

cla-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to Unlock! We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @SashaMIT on file.
In order for us to review and merge your code, please open another pull request with a single modification: your github username added to the file .clabot.
Thank you!

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@SashaMIT is attempting to deploy a commit to the Unlock Protocol Team on Vercel.

A member of the Team first needs to authorize it.

Unauthenticated GET /image/:network/:lock/:keyId fetched key.tokenURI and
redirected to json.image with no SSRF guard. Reuse assertSafeCallbackUrl
(and redirect:error) for both URLs, matching the OG/Apple siblings.
@SashaMIT

Copy link
Copy Markdown
Author

Follow-up commit on this branch: the same unauthenticated SSRF class also sits on GET /image/:network/:lockAddress/:keyId (getTokenURIImage).

It bare-fetched key.tokenURI and redirected the client to json.image with no scheme/private/DNS/redirect guard. Now both URLs go through assertSafeCallbackUrl with redirect: 'error', consistent with the OG/Apple paths in this PR family.

@cla-bot

cla-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to Unlock! We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @SashaMIT on file.
In order for us to review and merge your code, please open another pull request with a single modification: your github username added to the file .clabot.
Thank you!

@SashaMIT

Copy link
Copy Markdown
Author

CLA sign PR opened per cla-bot: #16596 (single-file .clabot add for SashaMIT). Once that merges, verification/cla-signed should clear on this PR. Vercel authorize remains maintainer-side.

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