<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y" -->

---
title: Our image proxy was hardened against SSRF. It could...
description: A defensively-built image proxy that properly blocked SSRF still had a critical flaw: its content-type check used a prefix match on 'image/', which also...
canonical: https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Our image proxy was hardened against SSRF. It could still change your password. | daily.dev
og:description: A defensively-built image proxy that properly blocked SSRF still had a critical flaw: its content-type check used a prefix match on 'image/', which also...
og:url: https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y
og:image: https://api.daily.dev/og/posts/vqAVl3Y8y.png
og:image:alt: Our image proxy was hardened against SSRF. It could still change your password.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Our image proxy was hardened against SSRF. It could still change your password.

**[AlphAI](https://daily.dev/sources/alphai)** · [@mikhailmakeev](https://daily.dev/mikhailmakeev) · 2 min read · 0 upvotes · 0 comments

## Summary

A defensively-built image proxy that properly blocked SSRF still had a critical flaw: its content-type check used a prefix match on 'image/', which also matched 'image/svg+xml'. Since SVG can contain inline scripts, navigating directly to the proxy URL rendered the SVG as a same-origin document, letting an attacker's script run with the victim's cookies attached and silently change the victim's password plus generate an API key. The fix allowlisted raster types with an exact media-type comparison, returned the validated type instead of the upstream one, and added a strict Content-Security-Policy plus X-Content-Type-Options: nosniff to every response.

## Content

We built our news image proxy defensively. It resolves the hostname up front and rejects private, loopback and CGNAT addresses. It refuses redirects and caps the body at 8 MiB. An external review read it and flagged one line: the content-type gate was a prefix check for `image/`.

`image/svg+xml` starts with `image/`.

So a file served from any https host as `image/svg+xml` passes the gate, and we hand it back with the upstream content type on it. A top-level navigation to our own proxy URL renders that SVG as a document in our origin, and the inline script inside it runs as us. httpOnly and SameSite=Lax don't help, because the request that script makes is same-origin and the browser attaches the cookies on its own. Our password reset route took a new password without asking for the current one. One click by a logged-in user was a password change plus an API key.

Nobody exploited it, and there was nothing in the logs to find, because the victim would be a real browser on a residential IP. What got me is that this isn't SSRF, which is the entire threat model the file was written against. That part was done properly. The gap sat one line away, in what a browser does with the bytes we return.

The fix was three changes in the same route. Allowlist the raster types explicitly and compare the bare media type, since `image/jpeg; charset=utf-8` shows up in the wild. Return the type you validated rather than the upstream string. Add `Content-Security-Policy: default-src 'none'; sandbox` and `X-Content-Type-Options: nosniff` to every 200, since an `<img>` load ignores both and a document made from that URL gets nothing.

If you run an image proxy, don't stop at whether the bytes are an image. Ask what your own origin does when somebody navigates to that URL instead of embedding it.

## Similar posts on daily.dev

- [Can Malware Still Hide Inside Images? What Happened in REF9403](https://daily.dev/posts/can-malware-still-hide-inside-images-what-happened-in-ref9403-ecsqhxika) · Medium · 1 upvotes · 0 comments
- [Roundcube Webmail <1.5.13 / <1.6.13 allows attackers to force remote image loads via SVG feImage](https://daily.dev/posts/roundcube-webmail-1-5-13-1-6-13-allows-attackers-to-force-remote-image-loads-via-svg-feimage-rlmyratwl) · Hacker News · 0 upvotes · 0 comments
- [Novel clickjacking attack relies on CSS and SVG](https://daily.dev/posts/novel-clickjacking-attack-relies-on-css-and-svg-609qdgjok) · The Register · 1 upvotes · 0 comments
- [SVG Filters - Clickjacking 2.0](https://daily.dev/posts/svg-filters---clickjacking-2-0-5wxezdnbz) · Lobsters · 0 upvotes · 0 comments
- [How the Bing Images RCE Flaws Actually Worked, and How to Check Your Own Pipeline](https://daily.dev/posts/how-the-bing-images-rce-flaws-actually-worked-and-how-to-check-your-own-pipeline-jwvjhrg1v) · Latest Hacking News · 1 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#web-security](https://daily.dev/tags/web-security)

[View this post on daily.dev](https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y","headline":"Our image proxy was hardened against SSRF. It could still change your password.","text":"A defensively-built image proxy that properly blocked SSRF still had a critical flaw: its content-type check used a prefix match on 'image/', which also matched 'image/svg+xml'. Since SVG can contain inline scripts, navigating directly to the proxy URL rendered the SVG as a same-origin document, letting an attacker's script run with the victim's cookies attached and silently change the victim's password plus generate an API key. The fix allowlisted raster types with an exact media-type comparison, returned the validated type instead of the upstream one, and added a strict Content-Security-Policy plus X-Content-Type-Options: nosniff to every response.","url":"https://daily.dev/posts/our-image-proxy-was-hardened-against-ssrf-it-could-still-change-your-password--vqavl3y8y","datePublished":"2026-09-05T05:12:10.923Z","dateModified":"2026-09-13T05:19:03.059Z","author":{"@type":"Person","name":"Mikhail Makeev","url":"https://daily.dev/mikhailmakeev","image":"https://lh3.googleusercontent.com/a/ACg8ocIjcvDU1gmJ9-KJDeTYqY2rMdl5QxcWYtLTGSXrj8ubF4nwar_w=s96-c","description":"Owner of alphai.io","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":5100}},"image":"https://media.daily.dev/image/upload/s--fGTo9lHc--/f_auto/v1789276742/posts/vqAVl3Y8y?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/alphai","name":"AlphAI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AlphAI","item":"https://daily.dev/squads/alphai"},{"@type":"ListItem","position":3,"name":"Our image proxy was hardened against SSRF. It could still change your password."}]}
```

