{"id":"CVE-2026-48788","aliases":["CVE-2026-48788","GHSA-4c8j-mgm4-qqvp","GO-2026-5804"],"related":[],"kind":"vulnerability","state":"published","title":"Remark42: Cross-Site Scripting (XSS) on /api/v1/img via content-type spoofing","summary":"Remark42 is a self-hosted comment engine for blogs, articles, or any other place where readers can add comments. Versions 1.6.0 through 1.15.0 contain a Cross-Site Scripting (XSS) vulnerability exploitable through content-type spoofing. The Remark42 image proxy fetches an arbitrary remote URL and re-serves the response from Remark42's own origin. During the download phase, the proxy determines whether the resource is an image by inspecting only the Content-Type header advertised by the remote server, never examining the actual bytes; during the serving phase, it instead derives the response Content-Type by sniffing those bytes with http.DetectContentType. An attacker can exploit this inconsistency by hosting a URL that advertises Content-Type: image/png while returning an HTML/JavaScript body: the download check accepts it as an image, the serving path sniffs the body and emits Content-Type: text/html, and the browser renders the attacker-controlled HTML/JavaScript as a document within Remark42's origin. Exploitation requires no Remark42 account on the target instance; the attacker only needs to host the malicious upstream URL and deliver the proxy link to a victim by any means, such as email, direct message, or a link on another website. This issue has been fixed in version 1.16.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Remark42 is a self-hosted comment engine for blogs, articles, or any other place where readers can add comments. Versions 1.6.0 through 1.15.0 contain a Cross-Site Scripting (XSS) vulnerability exploitable through content-type spoofing. The Remark42 image proxy fetches an arbitrary remote URL and re-serves the response from Remark42's own origin. During the download phase, the proxy determines whether the resource is an image by inspecting only the Content-Type header advertised by the remote server, never examining the actual bytes; during the serving phase, it instead derives the response Content-Type by sniffing those bytes with http.DetectContentType. An attacker can exploit this inconsistency by hosting a URL that advertises Content-Type: image/png while returning an HTML/JavaScript body: the download check accepts it as an image, the serving path sniffs the body and emits Content-Type: text/html, and the browser renders the attacker-controlled HTML/JavaScript as a document within Remark42's origin. Exploitation requires no Remark42 account on the target instance; the attacker only needs to host the malicious upstream URL and deliver the proxy link to a victim by any means, such as email, direct message, or a link on another website. This issue has been fixed in version 1.16.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe remark42 image proxy fetches an arbitrary remote URL and re-serves the response from remark42's own origin. The download path decides whether the fetched resource is an image by looking only at the `Content-Type` header the remote server claims — it never inspects the actual bytes. The serving path then derives the response `Content-Type` by sniffing those bytes with `http.DetectContentType`.\n\nAn attacker hosts a URL that sets `Content-Type` to `image/png` but returns an HTML/JavaScript body:\n\n* the download check sees `image/png` → accepts it;\n* the serve path sniffs the body → emits `Content-Type: text/html`;\n* the browser renders attacker HTML/JS as a document in remark42's origin.\n\n### Details\n#### Downloader\n\n`backend/app/rest/proxy/image.go` — `downloadImage()`, lines 189-206:\n\n```go\ncontentType := resp.Header.Get(\"Content-Type\")\nif !strings.HasPrefix(contentType, \"image/\") {\n    return nil, fmt.Errorf(\"invalid content type %s\", contentType)\n}\n\nmaxSize := 5 * 1024 * 1024 // 5MB default\nif p.ImageService != nil && p.ImageService.MaxSize > 0 {\n    maxSize = p.ImageService.MaxSize\n}\nlr := io.LimitReader(resp.Body, int64(maxSize)+1)\nimgData, err := io.ReadAll(lr)\nif err != nil {\n    return nil, fmt.Errorf(\"unable to read image body: %w\", err)\n}\nif len(imgData) > maxSize {\n    return nil, fmt.Errorf(\"image is too large\")\n}\nreturn imgData, nil          // <-- bytes never validated, returned as-is\n```\n\nSend `Content-Type: image/png` and the check passes regardless of what the body actually contains.\n\n#### Server\n\n`backend/app/rest/proxy/image.go` — `Handler()`, line 131:\n\n```go\nw.Header().Add(\"Content-Type\", p.ImageService.ImgContentType(img))\n_, err = io.Copy(w, bytes.NewReader(img))\n```\n\n`backend/app/store/image/image.go` — `ImgContentType()`, lines 242-249:\n\n```go\nfunc (s *Service) ImgContentType(img []byte) string {\n    contentType := http.DetectContentType(img)\n    if contentType == \"application/octet-stream\" {\n        return \"image/*\"\n    }\n    return contentType                 // <-- returns text/html for an HTML body\n}\n```\n\n### PoC\n\n```python\nself.send_response(200)\nself.send_header(\"Content-Type\", \"image/png\")\nself.send_header(\"Content-Length\", str(len(body)))\nself.end_headers()\nself.wfile.write(body)            # body = <!DOCTYPE html><script>...</script>\n```\n\nThen have the victim open `https://<remark42-host>/api/v1/img?src=<base64(attacker-host)>` top-level.\n\n### Impact\n* The script can issue authenticated, same-origin API calls with `credentials: 'include'` — the JWT cookie is sent automatically.\n* The script can read the `XSRF-TOKEN` cookie and re-send it as the `X-XSRF-TOKEN` header, defeating CSRF protection. The attacker acts as the victim: delete/edit their comments, change their settings, and — if the victim is admin — perform admin actions.\n\nTriggering requires no remark42 account on the target instance; the attacker only needs to host the malicious upstream URL and deliver the proxy link to a victim by any means (email, DM, link on another site, etc.).\n\n### Fix\n\n`v1.16.0` adds layered defense to `/api/v1/img` and `/api/v1/picture/{user}/{id}`:\n\n* `rest.SafeImgContentType` validates sniffed body bytes against a strict allowlist (`image/png`, `image/jpeg`, `image/gif`, `image/webp`, `image/bmp`, `image/x-icon`). Non-image content returns `415` with no body echo. SVG is implicitly excluded.\n* Every response carries `Content-Security-Policy: default-src 'none'; sandbox; frame-ancestors 'none'`, `X-Content-Type Options: nosniff`, and `Content-Disposition: inline; filename=\"image\"`.\n* The ETag is bumped to `\"v2:<base64(src)>\"`. Browsers that revalidate cached pre-fix responses get a fresh validated `200` instead of a `304` against the poisoned cached entry.\n* The strict `default-src 'none'; sandbox` CSP also applies to all `/api/v1/*` routes as defense-in-depth.\n\n#### Residual exposure\n\nBrowser-local caches that already hold a pre-fix `text/html` response with `Cache-Control: max-age=2592000` keep serving it from local store until the TTL expires or the cache is evicted under memory pressure. The ETag bump only reaches clients that revalidate during the cached lifetime. Operators running a CDN/edge cache in front of remark42 should purge `/api/v1/img` after deploying `v1.16.0`.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Remark42: Cross-Site Scripting (XSS) on /api/v1/img via content-type spoofing in github.com/umputun/remark42","format":"markdown","source":"go"},{"lang":"es","text":"Remark42 es un motor de comentarios autoalojado para blogs, artículos o cualquier otro lugar donde los lectores puedan añadir comentarios. Las versiones 1.6.0 a la 1.15.0 contienen una vulnerabilidad de Cross-Site Scripting (XSS) explotable a través de la suplantación de tipo de contenido. El proxy de imágenes de Remark42 obtiene una URL remota arbitraria y vuelve a servir la respuesta desde el propio origen de Remark42. Durante la fase de descarga, el proxy determina si el recurso es una imagen inspeccionando solo el encabezado Content-Type anunciado por el servidor remoto, sin examinar nunca los bytes reales; durante la fase de servicio, en su lugar, deriva el Content-Type de la respuesta detectando esos bytes con http.DetectContentType. Un atacante puede explotar esta inconsistencia alojando una URL que anuncia Content-Type: image/png mientras devuelve un cuerpo HTML/javascript_disabled: la verificación de descarga lo acepta como una imagen, la ruta de servicio detecta el cuerpo y emite Content-Type: text/html, y el navegador renderiza el HTML/JavaScript controlado por el atacante como un documento dentro del origen de Remark42. La explotación no requiere una cuenta de Remark42 en la instancia objetivo; el atacante solo necesita alojar la URL maliciosa de origen y entregar el enlace del proxy a una víctima por cualquier medio, como correo electrónico, mensaje directo o un enlace en otro sitio web. Este problema ha sido solucionado en la versión 1.16.0.","source":"nvd"}],"published":"2026-06-16T22:29:38.877Z","modified":"2026-10-25T23:10:00.167Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N","score":8.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N","score":8.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.0","vector":"CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N","score":8.2,"rating":"HIGH"}],"cwes":["CWE-79","CWE-436"],"affected":[{"ranges":[{"version":">= 1.6.0, < 1.16.0","status":"affected"}],"vendor":"umputun","product":"remark42","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.6.0","status":"affected","fixed":"1.16.0"}],"ecosystem":"Go","package":"github.com/umputun/remark42","purl":"pkg:golang/github.com/umputun/remark42","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.6.0","status":"affected","fixed":"1.16.0"}],"ecosystem":"Go","package":"github.com/umputun/remark42","purl":"pkg:golang/github.com/umputun/remark42","source":"go"}],"references":[{"url":"https://github.com/umputun/remark42/security/advisories/GHSA-4c8j-mgm4-qqvp","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/umputun/remark42/commit/78d6de6bce1e961f023969da3ec8a00dd80c9ae8","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/umputun/remark42/releases/tag/v1.16.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48788","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/umputun/remark42","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-06-17T13:19:50.596Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-48788","url":"https://www.cve.org/CVERecord?id=CVE-2026-48788","licence":"CVE Terms of Use","modified":"2026-06-17T13:20:11.543Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4c8j-mgm4-qqvp","url":"https://github.com/advisories/GHSA-4c8j-mgm4-qqvp","licence":"CC-BY-4.0","modified":"2026-07-07T16:11:13.898Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5804","url":"https://pkg.go.dev/vuln/GO-2026-5804","licence":"CC-BY-4.0","modified":"2026-07-07T16:01:34.714Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-48788","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48788","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"}],"updatedAt":"2026-11-25T22:59:24.917Z","epss":{"score":0.00406,"percentile":0.26479,"date":"2026-11-30T12:00:22.000Z"}}