ghsa-j7px-6hwj-hpjg
Vulnerability from github
Published
2021-12-20 17:59
Modified
2024-02-15 06:33
Summary
Open Redirect in OAuth2 Proxy
Details

Impact

As users can provide a redirect address for the proxy to send the authenticated user to at the end of the authentication flow. This is expected to be the original URL that the user was trying to access. This redirect URL is checked within the proxy and validated before redirecting the user to prevent malicious actors providing redirects to potentially harmful sites.

However, by crafting a redirect URL with HTML encoded whitespace characters (eg. %0a, %0b,%09,%0d) the validation could be bypassed and allow a redirect to any URL provided.

Patches

@rootxharsh and @iamnoooob provided this patch as potential solution: ``` From 4b941f56eda310b5c4dc8080b7635a6bfabccad4 Mon Sep 17 00:00:00 2001 From: Harsh Jaiswal harsh@pop-os.localdomain Date: Fri, 1 May 2020 20:38:31 +0530 Subject: [PATCH] Fixes redirect issue


oauthproxy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/oauthproxy.go b/oauthproxy.go index 1e9bb7c..f8beb4d 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -577,8 +577,9 @@ func validOptionalPort(port string) bool {

// IsValidRedirect checks whether the redirect URL is whitelisted func (p *OAuthProxy) IsValidRedirect(redirect string) bool { + matched, _ := regexp.MatchString(^/\s+/|\\, redirect) switch { - case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//") && !strings.HasPrefix(redirect, "/\"): + case strings.HasPrefix(redirect, "/") && !strings.HasPrefix(redirect, "//") && !matched: return true case strings.HasPrefix(redirect, "http://") || strings.HasPrefix(redirect, "https://"): redirectURL, err := url.Parse(redirect) -- 2.17.1 ```

This issue was also reported to us separately by @mik317 several hours later

The fix was implemented in #xxx and released as version 5.1.1

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/oauth2-proxy/oauth2-proxy"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "5.1.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2020-11053"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-601"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2021-05-24T21:05:58Z",
    "nvd_published_at": "2020-05-07T21:15:11Z",
    "severity": "HIGH"
  },
  "details": "### Impact\nAs users can provide a redirect address for the proxy to send the authenticated user to at the end of the authentication flow. This is expected to be the original URL that the user was trying to access.\nThis redirect URL is checked within the proxy and validated before redirecting the user to prevent malicious actors providing redirects to potentially harmful sites.\n\nHowever, by crafting a redirect URL with HTML encoded whitespace characters (eg. `%0a`, `%0b`,`%09`,`%0d`) the validation could be bypassed and allow a redirect to any URL provided.\n\n### Patches\n@rootxharsh and @iamnoooob provided this patch as potential solution:\n```\nFrom 4b941f56eda310b5c4dc8080b7635a6bfabccad4 Mon Sep 17 00:00:00 2001\nFrom: Harsh Jaiswal \u003charsh@pop-os.localdomain\u003e\nDate: Fri, 1 May 2020 20:38:31 +0530\nSubject: [PATCH] Fixes redirect issue\n\n---\n oauthproxy.go | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/oauthproxy.go b/oauthproxy.go\nindex 1e9bb7c..f8beb4d 100644\n--- a/oauthproxy.go\n+++ b/oauthproxy.go\n@@ -577,8 +577,9 @@ func validOptionalPort(port string) bool {\n\n // IsValidRedirect checks whether the redirect URL is whitelisted\n func (p *OAuthProxy) IsValidRedirect(redirect string) bool {\n+       matched, _ := regexp.MatchString(`^/\\s+/|\\\\`, redirect)\n        switch {\n-       case strings.HasPrefix(redirect, \"/\") \u0026\u0026 !strings.HasPrefix(redirect, \"//\") \u0026\u0026 !strings.HasPrefix(redirect, \"/\\\\\"):\n+       case strings.HasPrefix(redirect, \"/\") \u0026\u0026 !strings.HasPrefix(redirect, \"//\") \u0026\u0026 !matched:\n                return true\n        case strings.HasPrefix(redirect, \"http://\") || strings.HasPrefix(redirect, \"https://\"):\n                redirectURL, err := url.Parse(redirect)\n--\n2.17.1\n```\n\nThis issue was also reported to us separately by @mik317 several hours later\n\nThe fix was implemented in [#xxx]() and released as version 5.1.1",
  "id": "GHSA-j7px-6hwj-hpjg",
  "modified": "2024-02-15T06:33:23Z",
  "published": "2021-12-20T17:59:10Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/oauth2-proxy/oauth2-proxy/security/advisories/GHSA-j7px-6hwj-hpjg"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-11053"
    },
    {
      "type": "WEB",
      "url": "https://github.com/oauth2-proxy/oauth2-proxy/commit/0d5fa211df8ef2449347a56b22c779eb8d894c43"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Open Redirect in OAuth2 Proxy"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.


Loading…

Loading…