CWE-346
Weakness Allowed-with-ReviewOrigin Validation Error
Abstraction: Class · Status: Draft
The product does not properly verify that the source of data or communication is valid.
Mapping guidance
This CWE entry is a Class and might have Base-level children that would be more appropriate
Examine children of this entry to see if there is a better fit
Relationships and members
Modes of introduction
REALIZATION: This weakness is caused during implementation of an architectural security tactic.
Detection methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Notes
Maintenance
This entry has some significant overlap with other CWE entries and may need some clarification. See terminology notes.
Terminology
The "Origin Validation Error" term was originally used in a 1995 thesis [REF-324]. Although not formally defined, an issue is considered to be an origin validation error if either (1) "an object [accepts] input from an unauthorized subject," or (2) "the system [fails] to properly or completely authenticate a subject." A later section says that an origin validation error can occur when the system (1) "does not properly authenticate a user or process" or (2) "does not properly authenticate the shared data or libraries." The only example provided in the thesis (covered by OSVDB:57615) involves a setuid program running command-line arguments without dropping privileges. So, this definition (and its examples in the thesis) effectively cover other weaknesses such as CWE-287 (Improper Authentication), CWE-285 (Improper Authorization), and CWE-250 (Execution with Unnecessary Privileges). There appears to be little usage of this term today, except in the SecurityFocus vulnerability database, where the term is used for a variety of issues, including web-browser problems that allow violation of the Same Origin Policy and improper validation of the source of an incoming message.
Content history
Suggested mappings to ISA/IEC 62443.
updated Time_of_Introduction
updated Relationships, Relationship_Notes, Taxonomy_Mappings, Weakness_Ordinalities
updated Related_Attack_Patterns
updated Related_Attack_Patterns
updated Common_Consequences
updated Common_Consequences
updated Related_Attack_Patterns, Relationships
updated Applicable_Platforms, Common_Consequences, Demonstrative_Examples, Maintenance_Notes, References, Relationship_Notes, Relationships, Terminology_Notes
updated Related_Attack_Patterns
updated Relationships
updated Modes_of_Introduction, References, Relationships
updated Related_Attack_Patterns, Relationships
updated Relationships
updated Demonstrative_Examples, Terminology_Notes
updated Relationships
updated Relationships
updated Description, Type
updated Relationships, Taxonomy_Mappings
updated Mapping_Notes, Relationships
updated Taxonomy_Mappings
updated References
updated Observed_Examples
updated Applicable_Platforms, Detection_Factors, Relationships
1273 vulnerabilities reference this CWE, most recent first.
GHSA-96GQ-6RHF-G9X2
Vulnerability from github – Published: 2022-05-24 16:56 – Updated: 2024-04-04 01:55hostapd before 2.10 and wpa_supplicant before 2.10 allow an incorrect indication of disconnection in certain situations because source address validation is mishandled. This is a denial of service that should have been prevented by PMF (aka management frame protection). The attacker must send a crafted 802.11 frame from a location that is within the 802.11 communications range.
{
"affected": [],
"aliases": [
"CVE-2019-16275"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-09-12T20:15:00Z",
"severity": "MODERATE"
},
"details": "hostapd before 2.10 and wpa_supplicant before 2.10 allow an incorrect indication of disconnection in certain situations because source address validation is mishandled. This is a denial of service that should have been prevented by PMF (aka management frame protection). The attacker must send a crafted 802.11 frame from a location that is within the 802.11 communications range.",
"id": "GHSA-96gq-6rhf-g9x2",
"modified": "2024-04-04T01:55:46Z",
"published": "2022-05-24T16:56:03Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-16275"
},
{
"type": "WEB",
"url": "https://www.openwall.com/lists/oss-security/2019/09/11/7"
},
{
"type": "WEB",
"url": "https://www.debian.org/security/2019/dsa-4538"
},
{
"type": "WEB",
"url": "https://w1.fi/security/2019-7/ap-mode-pmf-disconnection-protection-bypass.txt"
},
{
"type": "WEB",
"url": "https://w1.fi/security/2019-7"
},
{
"type": "WEB",
"url": "https://usn.ubuntu.com/4136-2"
},
{
"type": "WEB",
"url": "https://usn.ubuntu.com/4136-1"
},
{
"type": "WEB",
"url": "https://seclists.org/bugtraq/2019/Sep/56"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PBJXUKV6XMSELWNXPS37CSUIH5EUHFXQ"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HY6STGJIIROVNIU6VMB2WTN2Q5M65WF4"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FEGITWRTIWABW54ANEPCEF4ARZLXGSK5"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/B7NCLOPTZNRRNYODH22BFIDH6YIQWLJD"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/36G4XAZ644DMHBLKOL4FDSPZVIGNQY6U"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/PBJXUKV6XMSELWNXPS37CSUIH5EUHFXQ"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/HY6STGJIIROVNIU6VMB2WTN2Q5M65WF4"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FEGITWRTIWABW54ANEPCEF4ARZLXGSK5"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/B7NCLOPTZNRRNYODH22BFIDH6YIQWLJD"
},
{
"type": "WEB",
"url": "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/36G4XAZ644DMHBLKOL4FDSPZVIGNQY6U"
},
{
"type": "WEB",
"url": "https://lists.debian.org/debian-lts-announce/2019/09/msg00017.html"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2019/09/12/6"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-96PH-P3MM-PHXP
Vulnerability from github – Published: 2026-09-01 15:31 – Updated: 2026-09-03 18:31Spoofing issue in the DOM: Core & HTML component. This vulnerability was fixed in Firefox 155 and Firefox ESR 153.2.
{
"affected": [],
"aliases": [
"CVE-2026-84137"
],
"database_specific": {
"cwe_ids": [
"CWE-346",
"CWE-451"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-09-01T13:20:07Z",
"severity": "MODERATE"
},
"details": "Spoofing issue in the DOM: Core \u0026 HTML component. This vulnerability was fixed in Firefox 155 and Firefox ESR 153.2.",
"id": "GHSA-96ph-p3mm-phxp",
"modified": "2026-09-03T18:31:33Z",
"published": "2026-09-01T15:31:09Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-84137"
},
{
"type": "WEB",
"url": "https://bugzilla.mozilla.org/show_bug.cgi?id=2051146"
},
{
"type": "WEB",
"url": "https://www.mozilla.org/security/advisories/mfsa2026-82"
},
{
"type": "WEB",
"url": "https://www.mozilla.org/security/advisories/mfsa2026-85"
},
{
"type": "WEB",
"url": "https://www.mozilla.org/security/advisories/mfsa2026-86"
},
{
"type": "WEB",
"url": "https://www.mozilla.org/security/advisories/mfsa2026-88"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-97M6-C5RG-V543
Vulnerability from github – Published: 2026-07-01 00:34 – Updated: 2026-07-01 15:35Insufficient policy enforcement in GetUserMedia in Google Chrome prior to 150.0.7871.47 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Low)
{
"affected": [],
"aliases": [
"CVE-2026-14039"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-06-30T23:17:16Z",
"severity": "MODERATE"
},
"details": "Insufficient policy enforcement in GetUserMedia in Google Chrome prior to 150.0.7871.47 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Low)",
"id": "GHSA-97m6-c5rg-v543",
"modified": "2026-07-01T15:35:07Z",
"published": "2026-07-01T00:34:09Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-14039"
},
{
"type": "WEB",
"url": "https://chromereleases.googleblog.com/2026/06/stable-channel-update-for-desktop_0175352312.html"
},
{
"type": "WEB",
"url": "https://issues.chromium.org/issues/497358012"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-989F-9M7C-HF34
Vulnerability from github – Published: 2026-06-05 00:31 – Updated: 2026-06-06 06:30Insufficient policy enforcement in Paint in Google Chrome prior to 149.0.7827.53 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Medium)
{
"affected": [],
"aliases": [
"CVE-2026-11132"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-06-04T23:17:19Z",
"severity": "MODERATE"
},
"details": "Insufficient policy enforcement in Paint in Google Chrome prior to 149.0.7827.53 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Medium)",
"id": "GHSA-989f-9m7c-hf34",
"modified": "2026-06-06T06:30:28Z",
"published": "2026-06-05T00:31:48Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-11132"
},
{
"type": "WEB",
"url": "https://chromereleases.googleblog.com/2026/06/stable-channel-update-for-desktop.html"
},
{
"type": "WEB",
"url": "https://issues.chromium.org/issues/501597365"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-98CG-QGHR-QMQX
Vulnerability from github – Published: 2026-11-21 18:30 – Updated: 2026-11-21 18:30@better-auth/passkey 1.4.0-beta.16 before 1.7.16 and 1.8.0-beta.0 before 1.8.0-beta.5, and the passkey plugin in better-auth 1.2.0-beta.18 before 1.4.0, do not confirm WebAuthn user verification when userVerification is "required" and take the expected origin from the request instead of configuration. Users can register or use passkeys without the required PIN or biometric check, and passkey responses created on another origin under the same relying party ID may be accepted.
{
"affected": [],
"aliases": [
"CVE-2026-134320"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-11-21T17:16:53Z",
"severity": "LOW"
},
"details": "@better-auth/passkey 1.4.0-beta.16 before 1.7.16 and 1.8.0-beta.0 before 1.8.0-beta.5, and the passkey plugin in better-auth 1.2.0-beta.18 before 1.4.0, do not confirm WebAuthn user verification when userVerification is \"required\" and take the expected origin from the request instead of configuration. Users can register or use passkeys without the required PIN or biometric check, and passkey responses created on another origin under the same relying party ID may be accepted.",
"id": "GHSA-98cg-qghr-qmqx",
"modified": "2026-11-21T18:30:25Z",
"published": "2026-11-21T18:30:25Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/better-auth/better-auth/security/advisories/GHSA-gv75-j3v8-3crm"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-134320"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/better-auth-passkey-before-1.7.16-improper-origin-and-user-verification-enforcement"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-98H2-VJPC-F4M2
Vulnerability from github – Published: 2026-07-30 03:31 – Updated: 2026-07-31 21:31Inappropriate implementation in Permissions in Google Chrome prior to 151.0.7922.72 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Medium)
{
"affected": [],
"aliases": [
"CVE-2026-17850"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-07-30T01:16:48Z",
"severity": "MODERATE"
},
"details": "Inappropriate implementation in Permissions in Google Chrome prior to 151.0.7922.72 allowed a remote attacker to bypass same origin policy via a crafted HTML page. (Chromium security severity: Medium)",
"id": "GHSA-98h2-vjpc-f4m2",
"modified": "2026-07-31T21:31:51Z",
"published": "2026-07-30T03:31:14Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-17850"
},
{
"type": "WEB",
"url": "https://chromereleases.googleblog.com/2026/07/stable-channel-update-for-desktop_0887107924.html"
},
{
"type": "WEB",
"url": "https://issues.chromium.org/issues/519078527"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-993X-2CG3-PV23
Vulnerability from github – Published: 2026-02-10 18:30 – Updated: 2026-02-12 15:32Certain HP OfficeJet Pro printers may expose information if Cross‑Origin Resource Sharing (CORS) is misconfigured, potentially allowing unauthorized web origins to access device resource.
CORS is disabled by default on Pro‑class devices and can only be enabled by an administrator through the Embedded Web Server (EWS). Keeping CORS disabled unless explicitly required helps ensure that only trusted solutions can interact with the device.
{
"affected": [],
"aliases": [
"CVE-2026-1997"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-02-10T18:16:22Z",
"severity": "MODERATE"
},
"details": "Certain HP OfficeJet Pro printers may expose information if Cross\u2011Origin Resource Sharing (CORS) is misconfigured, potentially allowing unauthorized web origins to access device resource.\n\nCORS is disabled by default on Pro\u2011class devices and can only be enabled by an administrator through the Embedded Web Server (EWS). Keeping CORS disabled unless explicitly required helps ensure that only trusted solutions can interact with the device.",
"id": "GHSA-993x-2cg3-pv23",
"modified": "2026-02-12T15:32:42Z",
"published": "2026-02-10T18:30:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-1997"
},
{
"type": "WEB",
"url": "https://support.hp.com/us-en/document/ish_14051823-14051849-16/hpsbpi04086"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-997Q-GVVC-JWMX
Vulnerability from github – Published: 2026-10-22 16:43 – Updated: 2026-10-22 16:43Impact
Requests to open external protocol URLs could be attributed to a document other than the one that asked for them, so the requestingUrl passed to session.setPermissionRequestHandler was a trusted origin for a launch untrusted content had requested. An origin-based handler could therefore let untrusted content launch an OS-registered external application.
Apps are only affected if they grant openExternal based on the requesting origin and let untrusted content open or navigate windows. Apps whose permission handler denies openExternal for untrusted content are not affected.
Workarounds
Deny the openExternal permission for untrusted content, or deny the windows it opens with setWindowOpenHandler.
Fixed Versions
45.0.0-alpha.544.3.043.7.042.11.3
For more information
If you have any questions or comments about this advisory, email us at security@electronjs.org
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "electron"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "42.11.3"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "electron"
},
"ranges": [
{
"events": [
{
"introduced": "43.0.0-alpha.1"
},
{
"fixed": "43.7.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "electron"
},
"ranges": [
{
"events": [
{
"introduced": "44.0.0-alpha.1"
},
{
"fixed": "44.3.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "electron"
},
"ranges": [
{
"events": [
{
"introduced": "45.0.0-alpha.1"
},
{
"fixed": "45.0.0-alpha.5"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-114121"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-22T16:43:59Z",
"nvd_published_at": "2026-10-21T17:18:25Z",
"severity": "MODERATE"
},
"details": "### Impact\nRequests to open external protocol URLs could be attributed to a document other than the one that asked for them, so the `requestingUrl` passed to `session.setPermissionRequestHandler` was a trusted origin for a launch untrusted content had requested. An origin-based handler could therefore let untrusted content launch an OS-registered external application.\n\nApps are only affected if they grant `openExternal` based on the requesting origin and let untrusted content open or navigate windows. Apps whose permission handler denies `openExternal` for untrusted content are not affected.\n\n### Workarounds\nDeny the `openExternal` permission for untrusted content, or deny the windows it opens with `setWindowOpenHandler`.\n\n### Fixed Versions\n* `45.0.0-alpha.5`\n* `44.3.0`\n* `43.7.0`\n* `42.11.3`\n\n### For more information\nIf you have any questions or comments about this advisory, email us at [security@electronjs.org](mailto:security@electronjs.org)",
"id": "GHSA-997q-gvvc-jwmx",
"modified": "2026-10-22T16:43:59Z",
"published": "2026-10-22T16:43:59Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/electron/electron/security/advisories/GHSA-997q-gvvc-jwmx"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-114121"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/pull/53699"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/pull/53698"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/pull/53697"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/pull/53696"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/pull/53682"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/commit/e3a400911084537bce7380ffea8af939572ce8dd"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/commit/e0a20d5277b567aea8603f8e9852a4341407a586"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/commit/92a783952891805f2f82f344c40a6917b98a7d98"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/commit/8aa5414f73792ed3b2e3f9ab6391b1832e6dc2c3"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/commit/25057643bf6d9a20bad69e45707551ccf546f5ce"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/releases/tag/v42.11.3"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/releases/tag/v43.7.0"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/releases/tag/v44.3.0"
},
{
"type": "WEB",
"url": "https://github.com/electron/electron/releases/tag/v45.0.0-alpha.5"
},
{
"type": "PACKAGE",
"url": "https://github.com/electron/electron"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "Electron: openExternal permission requests can be attributed to the wrong origin"
}
GHSA-99JH-6H7P-PP36
Vulnerability from github – Published: 2026-10-28 19:53 – Updated: 2026-10-28 19:53Summary
The Echo proxy middleware (middleware/proxy.go) preserves an incoming X-Real-IP header verbatim and forwards it to the upstream service when Echo#IPExtractor is not configured — which is the default. Because any HTTP client can supply an arbitrary X-Real-IP value, an attacker can cause Echo to relay a spoofed client IP address to every upstream service behind the proxy, undermining upstream IP-based access controls, rate limiting, audit logging, and geo-restriction.
Affected Component
middleware/proxy.go—ProxyConfig.ToMiddleware(), header-rewriting block (lines 351–355)
Description
The header-preservation condition passes spoofed values to upstream
ProxyConfig.ToMiddleware() (proxy.go:338-405) prepares forwarding headers before dispatching each request. The X-Real-IP rewrite logic at lines 351-355 reads:
// proxy.go:351-355
// Basically it's not good practice to unconditionally pass incoming x-real-ip header to upstream.
// However, for backward compatibility, legacy behavior is preserved unless you configure Echo#IPExtractor.
if req.Header.Get(echo.HeaderXRealIP) == "" || c.Echo().IPExtractor != nil {
req.Header.Set(echo.HeaderXRealIP, c.RealIP())
}
The condition is TRUE (and therefore overwrites the header with a derived value) only when:
- The header is absent — req.Header.Get(echo.HeaderXRealIP) == ""; or
- IPExtractor is explicitly configured — c.Echo().IPExtractor != nil
The condition is FALSE — and the header is left unchanged — when the request arrives with an X-Real-IP header already set and IPExtractor is nil. Because Echo.New() leaves IPExtractor as nil, this is the out-of-the-box behaviour for every application that uses Proxy() or ProxyWithConfig() without extra configuration.
An attacker who sets X-Real-IP to any value causes Echo to forward exactly that value to the upstream, with no modification or validation.
The comment in the source code confirms intent and the security gap
The inline comment at line 351-352 explicitly states:
"Basically it's not good practice to unconditionally pass incoming x-real-ip header to upstream. However, for backward compatibility, legacy behavior is preserved unless you configure Echo#IPExtractor."
The framework is aware that the default is insecure and retains it for backward compatibility. No warning appears in the Proxy() or ProxyWithConfig() documentation, so operators who follow the standard setup example receive a silently insecure proxy configuration.
This is structurally identical to the documented insecurity in ip.go:27:
"Note: if you don't set
Echo#IPExtractorexplicitly, Echo fallback to legacy behavior, which is not a good choice."
Full execution chain
- Attacker sends
GET /api/adminto the Echo proxy with headerX-Real-IP: 203.0.113.1(a trusted corporate IP) ToMiddleware()evaluates the guard at line 353: header is present (!= ""),IPExtractorisnil→ condition isFALSEreq.Header.Setis not called; the upstream request carries the original, attacker-suppliedX-Real-IP: 203.0.113.1- Upstream service checks
X-Real-IPagainst its IP allowlist → finds203.0.113.1→ grants access - Attacker reaches an endpoint that should be restricted to the corporate IP range
Secondary impact path (audit poisoning):
- All upstream log entries, rate-limit counters, and geo-restriction checks are evaluated against 203.0.113.1 rather than the real client IP, rendering audit trails and security analytics unreliable.
Proof of Concept
package main
import (
"fmt"
"log"
"net/http"
echo "github.com/labstack/echo/v5"
"github.com/labstack/echo/v5/middleware"
)
func main() {
// Upstream server: echoes back the X-Real-IP it received
upstream := http.NewServeMux()
upstream.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "upstream sees X-Real-IP: %s\n", r.Header.Get("X-Real-IP"))
})
go http.ListenAndServe(":9000", upstream)
// Echo proxy — IPExtractor deliberately NOT set (the default)
e := echo.New()
targets := []*middleware.ProxyTarget{{URL: mustParse("http://127.0.0.1:9000")}}
e.Use(middleware.Proxy(middleware.NewRoundRobinBalancer(targets)))
log.Fatal(e.Start(":1323"))
}
# Without spoofed header — upstream sees actual peer address
curl http://127.0.0.1:1323/
# upstream sees X-Real-IP: 127.0.0.1
# With spoofed header — upstream sees attacker-supplied value
curl -H 'X-Real-IP: 198.51.100.77' http://127.0.0.1:1323/
# upstream sees X-Real-IP: 198.51.100.77
The attacker-supplied IP 198.51.100.77 arrives at the upstream unchanged.
Impact
- Upstream IP-based access controls (allowlists, blocklists, geo-restrictions) can be bypassed by supplying the expected IP in
X-Real-IP - Upstream rate limiters that key on
X-Real-IPare bypassable (same class as the Echo rate-limiter finding, now on every upstream service) - Audit logs, intrusion detection systems, and SIEM tools that rely on
X-Real-IPrecord the attacker-chosen IP, not the real source — forensic trails are poisoned - Any upstream admin endpoint restricted by IP allowlist is reachable by any attacker who knows or guesses a trusted IP address
Recommended Remediation
Option 1: Always overwrite X-Real-IP from an authoritative source (preferred)
Remove the conditional that preserves the incoming header. Echo, as the edge proxy, is the only authoritative source for the real client IP:
// proxy.go — always set X-Real-IP from an authoritative source
req.Header.Set(echo.HeaderXRealIP, c.RealIP())
For this to be safe, operators using Proxy() should also configure IPExtractor:
e.IPExtractor = echo.ExtractIPDirect() // no upstream proxy
// or
e.IPExtractor = echo.ExtractIPFromXFFHeader() // behind a trusted upstream LB
Option 2: Document and warn in Proxy() godoc
If backward compatibility must be preserved, add a prominent security warning to Proxy() and ProxyWithConfig():
// Proxy returns a Proxy middleware.
//
// SECURITY: By default, an incoming X-Real-IP header supplied by the client
// is forwarded to the upstream unchanged. This allows any client to spoof its
// IP identity to upstream services. Configure Echo#IPExtractor before using
// this middleware to ensure X-Real-IP is derived from a trusted source:
//
// e.IPExtractor = echo.ExtractIPDirect()
//
// See https://echo.labstack.com/guide/ip-address for details.
func Proxy(balancer ProxyBalancer) echo.MiddlewareFunc {
Credit
This vulnerability was discovered and reported by bugbunny.ai.
Patches
Fixed in github.com/labstack/echo/v5 v5.4.0: the Proxy middleware always sets X-Real-IP from Context.RealIP(), which is the address of the direct peer unless Echo#IPExtractor is configured.
github.com/labstack/echo/v4 is not changed, because v4's Context.RealIP() without Echo#IPExtractor trusts X-Forwarded-For and X-Real-IP by design, and changing that default would merge all clients behind a proxy into one rate-limit bucket.
Workarounds
Configure Echo#IPExtractor for your deployment, for example e.IPExtractor = echo.ExtractIPDirect() when there is no proxy in front of the application, or echo.ExtractIPFromXFFHeader() / echo.ExtractIPFromRealIPHeader() (with TrustIPRange for proxies on public addresses). With an extractor set, the Proxy middleware overwrites X-Real-IP in v4 too.
{
"affected": [
{
"package": {
"ecosystem": "Go",
"name": "github.com/labstack/echo/v5"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.4.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "Go",
"name": "github.com/labstack/echo/v4"
},
"ranges": [
{
"events": [
{
"introduced": "4.0.0"
},
{
"last_affected": "4.16.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-118651"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-28T19:53:24Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "## Summary\n\nThe Echo proxy middleware (`middleware/proxy.go`) preserves an incoming `X-Real-IP` header verbatim and forwards it to the upstream service when `Echo#IPExtractor` is not configured \u2014 which is the default. Because any HTTP client can supply an arbitrary `X-Real-IP` value, an attacker can cause Echo to relay a spoofed client IP address to every upstream service behind the proxy, undermining upstream IP-based access controls, rate limiting, audit logging, and geo-restriction.\n\n## Affected Component\n\n- `middleware/proxy.go` \u2014 `ProxyConfig.ToMiddleware()`, header-rewriting block (lines 351\u2013355)\n\n## Description\n\n### The header-preservation condition passes spoofed values to upstream\n\n`ProxyConfig.ToMiddleware()` (`proxy.go:338-405`) prepares forwarding headers before dispatching each request. The `X-Real-IP` rewrite logic at lines 351-355 reads:\n\n```go\n// proxy.go:351-355\n// Basically it\u0027s not good practice to unconditionally pass incoming x-real-ip header to upstream.\n// However, for backward compatibility, legacy behavior is preserved unless you configure Echo#IPExtractor.\nif req.Header.Get(echo.HeaderXRealIP) == \"\" || c.Echo().IPExtractor != nil {\n req.Header.Set(echo.HeaderXRealIP, c.RealIP())\n}\n```\n\nThe condition is `TRUE` (and therefore overwrites the header with a derived value) only when:\n- The header is absent \u2014 `req.Header.Get(echo.HeaderXRealIP) == \"\"`; **or**\n- `IPExtractor` is explicitly configured \u2014 `c.Echo().IPExtractor != nil`\n\nThe condition is `FALSE` \u2014 and the header is left **unchanged** \u2014 when the request arrives with an `X-Real-IP` header already set **and** `IPExtractor` is `nil`. Because `Echo.New()` leaves `IPExtractor` as `nil`, this is the out-of-the-box behaviour for every application that uses `Proxy()` or `ProxyWithConfig()` without extra configuration.\n\nAn attacker who sets `X-Real-IP` to any value causes Echo to forward exactly that value to the upstream, with no modification or validation.\n\n### The comment in the source code confirms intent and the security gap\n\nThe inline comment at line 351-352 explicitly states:\n\n\u003e \"Basically it\u0027s not good practice to unconditionally pass incoming x-real-ip header to upstream. However, for backward compatibility, legacy behavior is preserved unless you configure Echo#IPExtractor.\"\n\nThe framework is aware that the default is insecure and retains it for backward compatibility. No warning appears in the `Proxy()` or `ProxyWithConfig()` documentation, so operators who follow the standard setup example receive a silently insecure proxy configuration.\n\nThis is structurally identical to the documented insecurity in `ip.go:27`:\n\n\u003e \"Note: if you don\u0027t set `Echo#IPExtractor` explicitly, Echo fallback to legacy behavior, which is not a good choice.\"\n\n### Full execution chain\n\n1. Attacker sends `GET /api/admin` to the Echo proxy with header `X-Real-IP: 203.0.113.1` (a trusted corporate IP)\n2. `ToMiddleware()` evaluates the guard at line 353: header is present (`!= \"\"`), `IPExtractor` is `nil` \u2192 condition is `FALSE`\n3. `req.Header.Set` is **not** called; the upstream request carries the original, attacker-supplied `X-Real-IP: 203.0.113.1`\n4. Upstream service checks `X-Real-IP` against its IP allowlist \u2192 finds `203.0.113.1` \u2192 grants access\n5. Attacker reaches an endpoint that should be restricted to the corporate IP range\n\nSecondary impact path (audit poisoning):\n- All upstream log entries, rate-limit counters, and geo-restriction checks are evaluated against `203.0.113.1` rather than the real client IP, rendering audit trails and security analytics unreliable.\n\n## Proof of Concept\n\n```go\npackage main\n\nimport (\n \"fmt\"\n \"log\"\n \"net/http\"\n echo \"github.com/labstack/echo/v5\"\n \"github.com/labstack/echo/v5/middleware\"\n)\n\nfunc main() {\n // Upstream server: echoes back the X-Real-IP it received\n upstream := http.NewServeMux()\n upstream.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, \"upstream sees X-Real-IP: %s\\n\", r.Header.Get(\"X-Real-IP\"))\n })\n go http.ListenAndServe(\":9000\", upstream)\n\n // Echo proxy \u2014 IPExtractor deliberately NOT set (the default)\n e := echo.New()\n targets := []*middleware.ProxyTarget{{URL: mustParse(\"http://127.0.0.1:9000\")}}\n e.Use(middleware.Proxy(middleware.NewRoundRobinBalancer(targets)))\n log.Fatal(e.Start(\":1323\"))\n}\n```\n\n```bash\n# Without spoofed header \u2014 upstream sees actual peer address\ncurl http://127.0.0.1:1323/\n# upstream sees X-Real-IP: 127.0.0.1\n\n# With spoofed header \u2014 upstream sees attacker-supplied value\ncurl -H \u0027X-Real-IP: 198.51.100.77\u0027 http://127.0.0.1:1323/\n# upstream sees X-Real-IP: 198.51.100.77\n```\n\nThe attacker-supplied IP `198.51.100.77` arrives at the upstream unchanged.\n\n## Impact\n\n- Upstream IP-based access controls (allowlists, blocklists, geo-restrictions) can be bypassed by supplying the expected IP in `X-Real-IP`\n- Upstream rate limiters that key on `X-Real-IP` are bypassable (same class as the Echo rate-limiter finding, now on every upstream service)\n- Audit logs, intrusion detection systems, and SIEM tools that rely on `X-Real-IP` record the attacker-chosen IP, not the real source \u2014 forensic trails are poisoned\n- Any upstream admin endpoint restricted by IP allowlist is reachable by any attacker who knows or guesses a trusted IP address\n\n## Recommended Remediation\n\n### Option 1: Always overwrite `X-Real-IP` from an authoritative source (preferred)\n\nRemove the conditional that preserves the incoming header. Echo, as the edge proxy, is the only authoritative source for the real client IP:\n\n```go\n// proxy.go \u2014 always set X-Real-IP from an authoritative source\nreq.Header.Set(echo.HeaderXRealIP, c.RealIP())\n```\n\nFor this to be safe, operators using `Proxy()` should also configure `IPExtractor`:\n\n```go\ne.IPExtractor = echo.ExtractIPDirect() // no upstream proxy\n// or\ne.IPExtractor = echo.ExtractIPFromXFFHeader() // behind a trusted upstream LB\n```\n\n### Option 2: Document and warn in `Proxy()` godoc\n\nIf backward compatibility must be preserved, add a prominent security warning to `Proxy()` and `ProxyWithConfig()`:\n\n```go\n// Proxy returns a Proxy middleware.\n//\n// SECURITY: By default, an incoming X-Real-IP header supplied by the client\n// is forwarded to the upstream unchanged. This allows any client to spoof its\n// IP identity to upstream services. Configure Echo#IPExtractor before using\n// this middleware to ensure X-Real-IP is derived from a trusted source:\n//\n// e.IPExtractor = echo.ExtractIPDirect()\n//\n// See https://echo.labstack.com/guide/ip-address for details.\nfunc Proxy(balancer ProxyBalancer) echo.MiddlewareFunc {\n```\n\n## Credit\n\nThis vulnerability was discovered and reported by [bugbunny.ai](https://bugbunny.ai).\n\n## Patches\n\nFixed in `github.com/labstack/echo/v5` v5.4.0: the Proxy middleware always sets `X-Real-IP` from `Context.RealIP()`, which is the address of the direct peer unless `Echo#IPExtractor` is configured.\n\n`github.com/labstack/echo/v4` is not changed, because v4\u0027s `Context.RealIP()` without `Echo#IPExtractor` trusts `X-Forwarded-For` and `X-Real-IP` by design, and changing that default would merge all clients behind a proxy into one rate-limit bucket.\n\n## Workarounds\n\nConfigure `Echo#IPExtractor` for your deployment, for example `e.IPExtractor = echo.ExtractIPDirect()` when there is no proxy in front of the application, or `echo.ExtractIPFromXFFHeader()` / `echo.ExtractIPFromRealIPHeader()` (with `TrustIPRange` for proxies on public addresses). With an extractor set, the Proxy middleware overwrites `X-Real-IP` in v4 too.",
"id": "GHSA-99jh-6h7p-pp36",
"modified": "2026-10-28T19:53:24Z",
"published": "2026-10-28T19:53:24Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/labstack/echo/security/advisories/GHSA-99jh-6h7p-pp36"
},
{
"type": "WEB",
"url": "https://github.com/labstack/echo/commit/fc410094b2f3415cf2bf5204082137b205bfd5af"
},
{
"type": "PACKAGE",
"url": "https://github.com/labstack/echo"
},
{
"type": "WEB",
"url": "https://github.com/labstack/echo/releases/tag/v5.4.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to Upstream by Default"
}
GHSA-9CCQ-2JFG-QW33
Vulnerability from github – Published: 2026-09-17 20:24 – Updated: 2026-09-17 20:24Summary
Grav\Common\Uri::referrer() and Grav\Common\Page\Pages::referrerRoute() both check whether an incoming request's Referer header "came from our site" using str_starts_with($referrer, $base), where $base is the site's own absolute root URL (for example https://example.com, no trailing slash). Because the comparison has no boundary character after the prefix, any Referer value that merely starts with that string is accepted, including a Referer from a completely different host such as https://example.com.attacker.tld.
This is the same class of bug already fixed once in 2.0.15 for the fast static asset server (GHSA-4v9q-p283-qc2m, "also allowing any neighbouring directory whose name starts with the same letters"). The identical pattern is still present in both places that trust the Referer header, and neither is covered by that fix.
Affected product and version
Product: Grav CMS, getgrav/grav Confirmed present in: 2.0.15, commit c2b46866857a93a0aa7048e7ed707ed3ed45dbc3 The pattern is not touched by any of the 2.0.15 security fixes, so earlier 2.x releases are likely affected too. I have not checked how far back it goes.
Affected code
system/src/Grav/Common/Uri.php, method referrer():
$referrer = $_SERVER['HTTP_REFERER'] ?? null;
...
$base = $this->rootUrl(true); // e.g. "https://example.com", no trailing slash
// Referrer should always have host set and it should come from the same base address.
if (!is_string($referrer) || !str_starts_with($referrer, $base)) {
$referrer = $default ?: $this->route(true, true);
}
$referrer = substr($referrer, strlen($base));
system/src/Grav/Common/Page/Pages.php, method referrerRoute():
$referrer = $_SERVER['HTTP_REFERER'] ?? null;
$root = $this->grav['base_url_absolute']; // e.g. "https://example.com"
if (!is_string($referrer) || !str_starts_with($referrer, (string) $root)) {
return null;
}
Note that the inner per-language loop later in the same referrerRoute() method does anchor the check correctly (str_starts_with($referrer, "{$base}/")), and system/src/Grav/Common/Themes.php line 300 does the same thing correctly ($current === $base || str_starts_with($current, $base . '/')). So the codebase already has the correct pattern elsewhere. Only the two outer checks quoted above compare against the bare root URL with no trailing delimiter.
Root cause
str_starts_with($referrer, $base) treats $base as a plain string prefix. Since $base has no trailing /, a string is accepted as long as it begins with those exact characters, regardless of what character follows. An attacker fully controls their own domain name, so producing a string that begins with the victim's origin is trivial, for example by registering example.com.attacker.tld or example.com-attacker.tld.
Under the default browser Referrer Policy (strict-origin-when-cross-origin), a cross-origin click or form submission from the attacker's page sends only the origin (scheme://host) as Referer, which is exactly the granularity $base is compared at, so no unusual browser configuration is required.
Proof of concept, verified, real output
This was run directly against the actual, unmodified source file from the repository, not a reimplementation. Steps and exact output below.
Step 1, clone the repo and confirm the commit under test:
$ git clone --depth 1 https://github.com/getgrav/grav.git
$ cd grav && git log -1 --format="%H %ai"
c2b46866857a93a0aa7048e7ed707ed3ed45dbc3 2026-08-03 15:14:50 +0100
Step 2, install PHP to execute the real class:
$ apt-get install -y php-cli
$ php -v
PHP 8.3.6 (cli) (built: Jul 16 2026 18:30:41) (NTS)
Step 3, PoC harness. Full site bootstrap, composer install, database, config, is not required to demonstrate this specific bug, since referrer() only needs the $root property, which init() would normally compute from the site config. The harness sets that one property with PHP Reflection, then calls the real, unmodified referrer() method with a real $_SERVER['HTTP_REFERER'] value, exactly the input path a live server would use:
<?php
// poc.php
spl_autoload_register(function ($class) {
if (strpos($class, 'Grav\\') === 0) {
$rel = str_replace('Grav\\', '', $class);
$path = '/home/claude/grav/system/src/Grav/' . str_replace('\\', '/', $rel) . '.php';
if (file_exists($path)) {
require_once $path;
}
}
});
$env = [
'HTTP_HOST' => 'example.com',
'REQUEST_URI' => '/target-route',
'HTTPS' => 'on',
];
$uri = new \Grav\Common\Uri($env);
$ref = new ReflectionObject($uri);
$prop = $ref->getProperty('root');
$prop->setAccessible(true);
$prop->setValue($uri, 'https://example.com');
function test($label, $refererHeader) {
global $uri;
$_SERVER['HTTP_REFERER'] = $refererHeader;
$result = $uri->referrer('https://example.com/DEFAULT_FALLBACK_USED');
echo "$label\n";
echo " Referer sent : $refererHeader\n";
echo " referrer() returned : $result\n";
echo " Same-origin check : " . ($result === '/DEFAULT_FALLBACK_USED' ? 'REJECTED (fallback used, correct)' : 'ACCEPTED (Referer treated as same-origin)') . "\n\n";
}
echo "=== Grav\\Common\\Uri::referrer() executed against real, unmodified source ===\n";
echo "Site base (\$root, as init() would set it) = https://example.com\n\n";
test('[1] Legitimate same-site referrer', 'https://example.com/some/page');
test('[2] Unrelated attacker site, sanity check, must be rejected', 'https://attacker.tld/phish');
test('[3] Attacker domain string-prefixing victim domain, vulnerable case', 'https://example.com.attacker.tld/phish');
test('[4] Attacker domain, dash variant, vulnerable case', 'https://example.com-attacker.tld/phish');
Step 4, run it:
$ php poc.php
Actual output:
=== Grav\Common\Uri::referrer() executed against real, unmodified source ===
Site base ($root, as init() would set it) = https://example.com
[1] Legitimate same-site referrer
Referer sent : https://example.com/some/page
referrer() returned : /some/page
Same-origin check : ACCEPTED (Referer treated as same-origin)
[2] Unrelated attacker site, sanity check, must be rejected
Referer sent : https://attacker.tld/phish
referrer() returned : /DEFAULT_FALLBACK_USED
Same-origin check : REJECTED (fallback used, correct)
[3] Attacker domain string-prefixing victim domain, vulnerable case
Referer sent : https://example.com.attacker.tld/phish
referrer() returned : .attacker.tld/phish
Same-origin check : ACCEPTED (Referer treated as same-origin)
[4] Attacker domain, dash variant, vulnerable case
Referer sent : https://example.com-attacker.tld/phish
referrer() returned : -attacker.tld/phish
Same-origin check : ACCEPTED (Referer treated as same-origin)
Interpretation: test 2 proves the harness correctly rejects a genuinely unrelated origin, so the acceptance in tests 3 and 4 is not a harness artifact. https://example.com.attacker.tld and https://example.com-attacker.tld, both fully attacker owned and registerable domains, are treated by referrer() as if they were https://example.com itself.
For a live end to end check against a running installation, this is the manual equivalent with curl once a Grav site is deployed at a known host, and it exercises the exact same str_starts_with comparison inside the real request path, not a standalone harness:
curl -s -H "Referer: https://TARGETHOST.attacker.tld/x" https://TARGETHOST/some/route
I did not have a fully bootstrapped live Grav instance available in this environment, composer install requires packagist.org, which was not reachable from the sandbox I was working in, so I was not able to additionally capture that live HTTP round trip. The harness above exercises the identical, unmodified vulnerable method and comparison from the real source file, so the defect itself is verified. What I could not verify from this repository alone is the specific downstream consumer of the return value, since Pages::referrerRoute()'s only real caller I could find references, per its own docblock example, which mentions /admin, is expected to live in the Admin plugin, getgrav/grav-plugin-admin, a separate repository not included in this checkout. If that is where a post login redirect target gets built from this value, please confirm on your end, since it would raise the severity of this report from an origin check bypass to a concrete open redirect after login.
Impact
An attacker who gets a victim to click a link, or to load a page that issues a cross-site request, from an attacker-controlled domain that string-prefixes the victim's Grav site domain can make the application treat that request as though it originated on site when it did not. The function also returns a relative route value derived directly from attacker-controlled input, via substr($referrer, strlen($base)), seen in test 3 and 4 above as .attacker.tld/phish and -attacker.tld/phish. If that value is later reused to build a redirect target, this becomes an open redirect. I was not able to fully confirm that chain from this repository alone, since the concrete consumer appears to live in the separate Admin plugin repository, but the origin check itself is unambiguously broken, and it is a reusable, security documented API, the docblock for referrer() explicitly states it checks that the referrer came from the site.
Suggested fix
Anchor the comparison the same way the codebase already does correctly elsewhere:
// Uri::referrer()
if (!is_string($referrer) || !($referrer === $base || str_starts_with($referrer, $base . '/'))) { ... }
// Pages::referrerRoute()
if (!is_string($referrer) || !($referrer === $root || str_starts_with($referrer, $root . '/'))) { return null; }
A more robust alternative is to parse both values with parse_url() and compare scheme, host, and port as discrete fields instead of doing any string prefix comparison.
Additional notes
While reviewing this release I also checked Utils::checkFilename() and the uploads_dangerous_extensions list, the Security::detectXss() regex handling of on_events and xmlns, and the twig_sandbox allow list in system/config/security.yaml. All three looked solid and appear to already reflect the fixes from prior advisories, GHSA-w8cg-7jcj-4vv2, GHSA-c2q3-p4jr-c55f, GHSA-j274-39qw-32c9. I did not find further issues to report there. Given this pattern has now recurred at least three times in this codebase, the static asset server, Uri::referrer(), and Pages::referrerRoute(), it may be worth grepping for every remaining str_starts_with($x, $base) call site touching URLs or paths.
=========================================================== CWE FIELD =========================================================== CWE-346, Origin Validation Error
=========================================================== CVSS CALCULATOR SELECTIONS (v3.1) =========================================================== Attack Vector: Network Attack Complexity: Low Privileges Required: None User Interaction: Required Scope: Unchanged Confidentiality: None Integrity: Low Availability: None
Resulting vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N Resulting score: 4.3, severity Medium
Note for the maintainer: this is a conservative rating for the origin check bypass on its own. If you confirm that Pages::referrerRoute()'s output feeds an unvalidated redirect target in the Admin plugin's post login flow, please rescore, Integrity would likely move to High and this becomes a credential phishing primitive right after a real login, which is meaningfully worse than the score above reflects.
=========================================================== SEVERITY FIELD =========================================================== Moderate, pending your confirmation of the Admin plugin call site, see note above
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.0.15"
},
"package": {
"ecosystem": "Packagist",
"name": "getgrav/grav"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.0.16"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-72702"
],
"database_specific": {
"cwe_ids": [
"CWE-346"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-17T20:24:38Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "## Summary\n\n`Grav\\Common\\Uri::referrer()` and `Grav\\Common\\Page\\Pages::referrerRoute()` both check whether an incoming request\u0027s `Referer` header \"came from our site\" using `str_starts_with($referrer, $base)`, where `$base` is the site\u0027s own absolute root URL (for example `https://example.com`, no trailing slash). Because the comparison has no boundary character after the prefix, any `Referer` value that merely starts with that string is accepted, including a `Referer` from a completely different host such as `https://example.com.attacker.tld`.\n\nThis is the same class of bug already fixed once in 2.0.15 for the fast static asset server (GHSA-4v9q-p283-qc2m, \"also allowing any neighbouring directory whose name starts with the same letters\"). The identical pattern is still present in both places that trust the `Referer` header, and neither is covered by that fix.\n\n## Affected product and version\n\nProduct: Grav CMS, getgrav/grav\nConfirmed present in: 2.0.15, commit c2b46866857a93a0aa7048e7ed707ed3ed45dbc3\nThe pattern is not touched by any of the 2.0.15 security fixes, so earlier 2.x releases are likely affected too. I have not checked how far back it goes.\n\n## Affected code\n\n`system/src/Grav/Common/Uri.php`, method `referrer()`:\n```php\n$referrer = $_SERVER[\u0027HTTP_REFERER\u0027] ?? null;\n...\n$base = $this-\u003erootUrl(true); // e.g. \"https://example.com\", no trailing slash\n// Referrer should always have host set and it should come from the same base address.\nif (!is_string($referrer) || !str_starts_with($referrer, $base)) {\n $referrer = $default ?: $this-\u003eroute(true, true);\n}\n$referrer = substr($referrer, strlen($base));\n```\n\n`system/src/Grav/Common/Page/Pages.php`, method `referrerRoute()`:\n```php\n$referrer = $_SERVER[\u0027HTTP_REFERER\u0027] ?? null;\n$root = $this-\u003egrav[\u0027base_url_absolute\u0027]; // e.g. \"https://example.com\"\nif (!is_string($referrer) || !str_starts_with($referrer, (string) $root)) {\n return null;\n}\n```\n\nNote that the inner per-language loop later in the same `referrerRoute()` method does anchor the check correctly (`str_starts_with($referrer, \"{$base}/\")`), and `system/src/Grav/Common/Themes.php` line 300 does the same thing correctly (`$current === $base || str_starts_with($current, $base . \u0027/\u0027)`). So the codebase already has the correct pattern elsewhere. Only the two outer checks quoted above compare against the bare root URL with no trailing delimiter.\n\n## Root cause\n\n`str_starts_with($referrer, $base)` treats `$base` as a plain string prefix. Since `$base` has no trailing `/`, a string is accepted as long as it begins with those exact characters, regardless of what character follows. An attacker fully controls their own domain name, so producing a string that begins with the victim\u0027s origin is trivial, for example by registering `example.com.attacker.tld` or `example.com-attacker.tld`.\n\nUnder the default browser Referrer Policy (`strict-origin-when-cross-origin`), a cross-origin click or form submission from the attacker\u0027s page sends only the origin (`scheme://host`) as `Referer`, which is exactly the granularity `$base` is compared at, so no unusual browser configuration is required.\n\n## Proof of concept, verified, real output\n\nThis was run directly against the actual, unmodified source file from the repository, not a reimplementation. Steps and exact output below.\n\nStep 1, clone the repo and confirm the commit under test:\n```\n$ git clone --depth 1 https://github.com/getgrav/grav.git\n$ cd grav \u0026\u0026 git log -1 --format=\"%H %ai\"\nc2b46866857a93a0aa7048e7ed707ed3ed45dbc3 2026-08-03 15:14:50 +0100\n```\n\nStep 2, install PHP to execute the real class:\n```\n$ apt-get install -y php-cli\n$ php -v\nPHP 8.3.6 (cli) (built: Jul 16 2026 18:30:41) (NTS)\n```\n\nStep 3, PoC harness. Full site bootstrap, composer install, database, config, is not required to demonstrate this specific bug, since `referrer()` only needs the `$root` property, which `init()` would normally compute from the site config. The harness sets that one property with PHP Reflection, then calls the real, unmodified `referrer()` method with a real `$_SERVER[\u0027HTTP_REFERER\u0027]` value, exactly the input path a live server would use:\n\n```php\n\u003c?php\n// poc.php\nspl_autoload_register(function ($class) {\n if (strpos($class, \u0027Grav\\\\\u0027) === 0) {\n $rel = str_replace(\u0027Grav\\\\\u0027, \u0027\u0027, $class);\n $path = \u0027/home/claude/grav/system/src/Grav/\u0027 . str_replace(\u0027\\\\\u0027, \u0027/\u0027, $rel) . \u0027.php\u0027;\n if (file_exists($path)) {\n require_once $path;\n }\n }\n});\n\n$env = [\n \u0027HTTP_HOST\u0027 =\u003e \u0027example.com\u0027,\n \u0027REQUEST_URI\u0027 =\u003e \u0027/target-route\u0027,\n \u0027HTTPS\u0027 =\u003e \u0027on\u0027,\n];\n\n$uri = new \\Grav\\Common\\Uri($env);\n\n$ref = new ReflectionObject($uri);\n$prop = $ref-\u003egetProperty(\u0027root\u0027);\n$prop-\u003esetAccessible(true);\n$prop-\u003esetValue($uri, \u0027https://example.com\u0027);\n\nfunction test($label, $refererHeader) {\n global $uri;\n $_SERVER[\u0027HTTP_REFERER\u0027] = $refererHeader;\n $result = $uri-\u003ereferrer(\u0027https://example.com/DEFAULT_FALLBACK_USED\u0027);\n echo \"$label\\n\";\n echo \" Referer sent : $refererHeader\\n\";\n echo \" referrer() returned : $result\\n\";\n echo \" Same-origin check : \" . ($result === \u0027/DEFAULT_FALLBACK_USED\u0027 ? \u0027REJECTED (fallback used, correct)\u0027 : \u0027ACCEPTED (Referer treated as same-origin)\u0027) . \"\\n\\n\";\n}\n\necho \"=== Grav\\\\Common\\\\Uri::referrer() executed against real, unmodified source ===\\n\";\necho \"Site base (\\$root, as init() would set it) = https://example.com\\n\\n\";\n\ntest(\u0027[1] Legitimate same-site referrer\u0027, \u0027https://example.com/some/page\u0027);\ntest(\u0027[2] Unrelated attacker site, sanity check, must be rejected\u0027, \u0027https://attacker.tld/phish\u0027);\ntest(\u0027[3] Attacker domain string-prefixing victim domain, vulnerable case\u0027, \u0027https://example.com.attacker.tld/phish\u0027);\ntest(\u0027[4] Attacker domain, dash variant, vulnerable case\u0027, \u0027https://example.com-attacker.tld/phish\u0027);\n```\n\nStep 4, run it:\n```\n$ php poc.php\n```\n\nActual output:\n```\n=== Grav\\Common\\Uri::referrer() executed against real, unmodified source ===\nSite base ($root, as init() would set it) = https://example.com\n\n[1] Legitimate same-site referrer\n Referer sent : https://example.com/some/page\n referrer() returned : /some/page\n Same-origin check : ACCEPTED (Referer treated as same-origin)\n\n[2] Unrelated attacker site, sanity check, must be rejected\n Referer sent : https://attacker.tld/phish\n referrer() returned : /DEFAULT_FALLBACK_USED\n Same-origin check : REJECTED (fallback used, correct)\n\n[3] Attacker domain string-prefixing victim domain, vulnerable case\n Referer sent : https://example.com.attacker.tld/phish\n referrer() returned : .attacker.tld/phish\n Same-origin check : ACCEPTED (Referer treated as same-origin)\n\n[4] Attacker domain, dash variant, vulnerable case\n Referer sent : https://example.com-attacker.tld/phish\n referrer() returned : -attacker.tld/phish\n Same-origin check : ACCEPTED (Referer treated as same-origin)\n```\n\nInterpretation: test 2 proves the harness correctly rejects a genuinely unrelated origin, so the acceptance in tests 3 and 4 is not a harness artifact. `https://example.com.attacker.tld` and `https://example.com-attacker.tld`, both fully attacker owned and registerable domains, are treated by `referrer()` as if they were `https://example.com` itself.\n\nFor a live end to end check against a running installation, this is the manual equivalent with curl once a Grav site is deployed at a known host, and it exercises the exact same `str_starts_with` comparison inside the real request path, not a standalone harness:\n```\ncurl -s -H \"Referer: https://TARGETHOST.attacker.tld/x\" https://TARGETHOST/some/route\n```\nI did not have a fully bootstrapped live Grav instance available in this environment, composer install requires packagist.org, which was not reachable from the sandbox I was working in, so I was not able to additionally capture that live HTTP round trip. The harness above exercises the identical, unmodified vulnerable method and comparison from the real source file, so the defect itself is verified. What I could not verify from this repository alone is the specific downstream consumer of the return value, since `Pages::referrerRoute()`\u0027s only real caller I could find references, per its own docblock example, which mentions `/admin`, is expected to live in the Admin plugin, `getgrav/grav-plugin-admin`, a separate repository not included in this checkout. If that is where a post login redirect target gets built from this value, please confirm on your end, since it would raise the severity of this report from an origin check bypass to a concrete open redirect after login.\n\n## Impact\n\nAn attacker who gets a victim to click a link, or to load a page that issues a cross-site request, from an attacker-controlled domain that string-prefixes the victim\u0027s Grav site domain can make the application treat that request as though it originated on site when it did not. The function also returns a relative route value derived directly from attacker-controlled input, via `substr($referrer, strlen($base))`, seen in test 3 and 4 above as `.attacker.tld/phish` and `-attacker.tld/phish`. If that value is later reused to build a redirect target, this becomes an open redirect. I was not able to fully confirm that chain from this repository alone, since the concrete consumer appears to live in the separate Admin plugin repository, but the origin check itself is unambiguously broken, and it is a reusable, security documented API, the docblock for `referrer()` explicitly states it checks that the referrer came from the site.\n\n## Suggested fix\n\nAnchor the comparison the same way the codebase already does correctly elsewhere:\n```php\n// Uri::referrer()\nif (!is_string($referrer) || !($referrer === $base || str_starts_with($referrer, $base . \u0027/\u0027))) { ... }\n\n// Pages::referrerRoute()\nif (!is_string($referrer) || !($referrer === $root || str_starts_with($referrer, $root . \u0027/\u0027))) { return null; }\n```\nA more robust alternative is to parse both values with `parse_url()` and compare `scheme`, `host`, and `port` as discrete fields instead of doing any string prefix comparison.\n\n## Additional notes\n\nWhile reviewing this release I also checked `Utils::checkFilename()` and the `uploads_dangerous_extensions` list, the `Security::detectXss()` regex handling of `on_events` and `xmlns`, and the `twig_sandbox` allow list in `system/config/security.yaml`. All three looked solid and appear to already reflect the fixes from prior advisories, GHSA-w8cg-7jcj-4vv2, GHSA-c2q3-p4jr-c55f, GHSA-j274-39qw-32c9. I did not find further issues to report there. Given this pattern has now recurred at least three times in this codebase, the static asset server, `Uri::referrer()`, and `Pages::referrerRoute()`, it may be worth grepping for every remaining `str_starts_with($x, $base)` call site touching URLs or paths.\n\n===========================================================\nCWE FIELD\n===========================================================\nCWE-346, Origin Validation Error\n\n===========================================================\nCVSS CALCULATOR SELECTIONS (v3.1)\n===========================================================\nAttack Vector: Network\nAttack Complexity: Low\nPrivileges Required: None\nUser Interaction: Required\nScope: Unchanged\nConfidentiality: None\nIntegrity: Low\nAvailability: None\n\nResulting vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N\nResulting score: 4.3, severity Medium\n\nNote for the maintainer: this is a conservative rating for the origin check bypass on its own. If you confirm that `Pages::referrerRoute()`\u0027s output feeds an unvalidated redirect target in the Admin plugin\u0027s post login flow, please rescore, Integrity would likely move to High and this becomes a credential phishing primitive right after a real login, which is meaningfully worse than the score above reflects.\n\n===========================================================\nSEVERITY FIELD\n===========================================================\nModerate, pending your confirmation of the Admin plugin call site, see note above",
"id": "GHSA-9ccq-2jfg-qw33",
"modified": "2026-09-17T20:24:38Z",
"published": "2026-09-17T20:24:38Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/getgrav/grav/security/advisories/GHSA-9ccq-2jfg-qw33"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-72702"
},
{
"type": "PACKAGE",
"url": "https://github.com/getgrav/grav"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/grav-cms-before-origin-validation-bypass-via-referer"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "Grav: Origin validation bypass in Uri::referrer() and Pages::referrerRoute() via unanchored prefix match"
}
No mitigation information available for this CWE.
CAPEC-111: JSON Hijacking (aka JavaScript Hijacking)
An attacker targets a system that uses JavaScript Object Notation (JSON) as a transport mechanism between the client and the server (common in Web 2.0 systems using AJAX) to steal possibly confidential information transmitted from the server back to the client inside the JSON object by taking advantage of the loophole in the browser's Same Origin Policy that does not prohibit JavaScript from one website to be included and executed in the context of another website.
CAPEC-141: Cache Poisoning
An attacker exploits the functionality of cache technologies to cause specific data to be cached that aids the attackers' objectives. This describes any attack whereby an attacker places incorrect or harmful material in cache. The targeted cache can be an application's cache (e.g. a web browser cache) or a public cache (e.g. a DNS or ARP cache). Until the cache is refreshed, most applications or clients will treat the corrupted cache value as valid. This can lead to a wide range of exploits including redirecting web browsers towards sites that install malware and repeatedly incorrect calculations based on the incorrect value.
CAPEC-142: DNS Cache Poisoning
A domain name server translates a domain name (such as www.example.com) into an IP address that Internet hosts use to contact Internet resources. An adversary modifies a public DNS cache to cause certain names to resolve to incorrect addresses that the adversary specifies. The result is that client applications that rely upon the targeted cache for domain name resolution will be directed not to the actual address of the specified domain name but to some other address. Adversaries can use this to herd clients to sites that install malware on the victim's computer or to masquerade as part of a Pharming attack.
CAPEC-160: Exploit Script-Based APIs
Some APIs support scripting instructions as arguments. Methods that take scripted instructions (or references to scripted instructions) can be very flexible and powerful. However, if an attacker can specify the script that serves as input to these methods they can gain access to a great deal of functionality. For example, HTML pages support <script> tags that allow scripting languages to be embedded in the page and then interpreted by the receiving web browser. If the content provider is malicious, these scripts can compromise the client application. Some applications may even execute the scripts under their own identity (rather than the identity of the user providing the script) which can allow attackers to perform activities that would otherwise be denied to them.
CAPEC-21: Exploitation of Trusted Identifiers
An adversary guesses, obtains, or "rides" a trusted identifier (e.g. session ID, resource ID, cookie, etc.) to perform authorized actions under the guise of an authenticated user or service.
CAPEC-384: Application API Message Manipulation via Man-in-the-Middle
An attacker manipulates either egress or ingress data from a client within an application framework in order to change the content of messages. Performing this attack can allow the attacker to gain unauthorized privileges within the application, or conduct attacks such as phishing, deceptive strategies to spread malware, or traditional web-application attacks. The techniques require use of specialized software that allow the attacker to perform adversary-in-the-middle (CAPEC-94) communications between the web browser and the remote system. Despite the use of AiTH software, the attack is actually directed at the server, as the client is one node in a series of content brokers that pass information along to the application framework. Additionally, it is not true "Adversary-in-the-Middle" attack at the network layer, but an application-layer attack the root cause of which is the master applications trust in the integrity of code supplied by the client.
CAPEC-385: Transaction or Event Tampering via Application API Manipulation
An attacker hosts or joins an event or transaction within an application framework in order to change the content of messages or items that are being exchanged. Performing this attack allows the attacker to manipulate content in such a way as to produce messages or content that look authentic but may contain deceptive links, substitute one item or another, spoof an existing item and conduct a false exchange, or otherwise change the amounts or identity of what is being exchanged. The techniques require use of specialized software that allow the attacker to man-in-the-middle communications between the web browser and the remote system in order to change the content of various application elements. Often, items exchanged in game can be monetized via sales for coin, virtual dollars, etc. The purpose of the attack is for the attack to scam the victim by trapping the data packets involved the exchange and altering the integrity of the transfer process.
CAPEC-386: Application API Navigation Remapping
An attacker manipulates either egress or ingress data from a client within an application framework in order to change the destination and/or content of links/buttons displayed to a user within API messages. Performing this attack allows the attacker to manipulate content in such a way as to produce messages or content that looks authentic but contains links/buttons that point to an attacker controlled destination. Some applications make navigation remapping more difficult to detect because the actual HREF values of images, profile elements, and links/buttons are masked. One example would be to place an image in a user's photo gallery that when clicked upon redirected the user to an off-site location. Also, traditional web vulnerabilities (such as CSRF) can be constructed with remapped buttons or links. In some cases navigation remapping can be used for Phishing attacks or even means to artificially boost the page view, user site reputation, or click-fraud.
CAPEC-387: Navigation Remapping To Propagate Malicious Content
An adversary manipulates either egress or ingress data from a client within an application framework in order to change the content of messages and thereby circumvent the expected application logic.
CAPEC-388: Application API Button Hijacking
An attacker manipulates either egress or ingress data from a client within an application framework in order to change the destination and/or content of buttons displayed to a user within API messages. Performing this attack allows the attacker to manipulate content in such a way as to produce messages or content that looks authentic but contains buttons that point to an attacker controlled destination.
CAPEC-510: SaaS User Request Forgery
An adversary, through a previously installed malicious application, performs malicious actions against a third-party Software as a Service (SaaS) application (also known as a cloud based application) by leveraging the persistent and implicit trust placed on a trusted user's session. This attack is executed after a trusted user is authenticated into a cloud service, "piggy-backing" on the authenticated session, and exploiting the fact that the cloud service believes it is only interacting with the trusted user. If successful, the actions embedded in the malicious application will be processed and accepted by the targeted SaaS application and executed at the trusted user's privilege level.
CAPEC-59: Session Credential Falsification through Prediction
This attack targets predictable session ID in order to gain privileges. The attacker can predict the session ID used during a transaction to perform spoofing and session hijacking.
CAPEC-60: Reusing Session IDs (aka Session Replay)
This attack targets the reuse of valid session ID to spoof the target system in order to gain privileges. The attacker tries to reuse a stolen session ID used previously during a transaction to perform spoofing and session hijacking. Another name for this type of attack is Session Replay.
CAPEC-75: Manipulating Writeable Configuration Files
Generally these are manually edited files that are not in the preview of the system administrators, any ability on the attackers' behalf to modify these files, for example in a CVS repository, gives unauthorized access directly to the application, the same as authorized users.
CAPEC-76: Manipulating Web Input to File System Calls
An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.
CAPEC-89: Pharming
A pharming attack occurs when the victim is fooled into entering sensitive data into supposedly trusted locations, such as an online bank site or a trading platform. An attacker can impersonate these supposedly trusted sites and have the victim be directed to their site rather than the originally intended one. Pharming does not require script injection or clicking on malicious links for the attack to succeed.