Miggo Logo

CVE-2025-47909: github.com/gorilla/csrf improperly validates TrustedOrigins allowing CSRF attacks

N/A

CVSS Score

Basic Information

EPSS Score
-
Published
8/29/2025
Updated
8/29/2025
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
-
Package NameEcosystemVulnerable VersionsFirst Patched Version
github.com/gorilla/csrfgo<= 1.7.3

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability, identified as CVE-2025-47909, exists in the github.com/gorilla/csrf library and stems from an improper validation of trusted origins. The analysis of the provided information, including the vulnerability description and the code changes in commit 9dd6af1f6d30fc79fb0d972394deebdabad6b5eb, reveals that the core of the issue lies within the ServeHTTP method of the csrf struct.

The patch introduced a new origin check logic. When a request includes an Origin header, the ServeHTTP function parses it. If the origin is not the same as the request's origin, the code proceeds to check if the origin's host is present in the TrustedOrigins list. The critical flaw is in this check: slices.Contains(cs.opts.TrustedOrigins, parsedOrigin.Host). This comparison only considers the host part of the origin, completely ignoring the scheme (HTTP or HTTPS).

This flaw allows a network attacker to set up a malicious form on an HTTP domain that is listed in the TrustedOrigins of a target application running on HTTPS. For example, if https://example.com trusts example.net, an attacker can host a malicious form on http://example.net. When a user on the same network visits this page, the form can submit requests to https://example.com. The CSRF protection will fail because while http://example.net is not the same origin as https://example.com, the host example.net is in the TrustedOrigins list, and the scheme is not checked, thus bypassing the protection.

The vulnerable function is csrf.ServeHTTP, as it contains the flawed logic for origin validation. This function would appear in a runtime profile during the exploitation of this vulnerability.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

*osts list** in Trust**Ori*ins impli*itly *llow r*qu*sts *rom t** *orr*spon*in* *TTP ori*ins, *llowin* n*twork MitMs to p*r*orm *SR* *tt**ks. **t*r t** *V*-****-***** *ix, * n*twork *tt**k*r t**t pl***s * *orm *t *ttp://*x*mpl*.*om **n't **t it to s

Reasoning

T** vuln*r**ility, i**nti*i** *s *V*-****-*****, *xists in t** `*it*u*.*om/*orill*/*sr*` li*r*ry *n* st*ms *rom *n improp*r v*li**tion o* trust** ori*ins. T** *n*lysis o* t** provi*** in*orm*tion, in*lu*in* t** vuln*r**ility **s*ription *n* t** *o**