本文へ移動
English version →
中 4.7

Echo has Arbitrary Scheme Injection in WWWRedirect/NonWWWRedirect Middlewares via X-Forwarded-Proto

CVE-2026-118658 SecPulse初出

影響パッケージ

種類パッケージ影響を受ける版直った版
labstack echo — —
go github.com/labstack/echo/v5
5.1.1 未満
5.1.1
go github.com/labstack/echo/v4
4.15.2 未満
4.15.2
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。

Summary

The c.Scheme() method in Echo (context.go:162-181) trusts the X-Forwarded-Proto, X-Forwarded-Protocol, and X-Url-Scheme request headers without validating that the value is http or https. The WWWRedirect() and NonWWWRedirect() middlewares use this unsanitized scheme to construct redirect URLs, allowing an attacker to inject arbitrary URI schemes into the Location response header.

Affected Components

  • context.go:162-181 - Scheme() method returns attacker-controlled value verbatim
  • middleware/redirect.go:172-184 - redirectWWW/redirectNonWWW use unsanitized scheme

Proof of Concept

GET /path HTTP/1.1
Host: example.com
X-Forwarded-Proto: javascript

Response:
HTTP/1.1 301 Moved Permanently
Location: javascript://www.example.com/path

Confirmed injectable schemes: javascript, data, vbscript, file, ftp, ssh, telnet, gopher.

Only WWWRedirect() and NonWWWRedirect() (and WithConfig variants) are affected. HTTPSRedirect, HTTPSWWWRedirect, HTTPSNonWWWRedirect are NOT affected (they hardcode https://).

Impact

  • Open redirect to arbitrary scheme URLs when app is not behind a proxy that strips X-Forwarded-Proto
  • Cache poisoning when behind a CDN that caches redirect responses keyed by path
  • file:// scheme injection could trigger file access in some browser configurations

Suggested Fix

Whitelist scheme in c.Scheme() to only return http or https:

func (c *Context) Scheme()…

出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

参照URL

当サイトでは、アクセス解析と広告の効果測定のために Cookie を使います。株式会社Game のサイト共通の設定です。 詳しく