CVE-2023-32691: Github.com/ginuerzh/gost Ginuerzh/gost Vulnerable To Timing Attack Vulnerability

MODERATE
Advisory Identifier: GHSA-qjrq-hm79-49ww
CVSS 5.9
CWE-203
Published
Advisory Summary

CVE-2023-32691 is a MODERATE (CVSS 5.9) ginuerzh/gost vulnerable to timing attack vulnerability (CWE-203: Observable Discrepancy) affecting Github.com/ginuerzh/gost libraries in the Go ecosystem. The issue involves ginuerzh/gost vulnerable to timing attack. Remediation is available in the latest vendor maintenance releases.

CVE-2023-32691 at a Glance

CVE Identifier CVE-2023-32691
GHSA Identifier GHSA-qjrq-hm79-49ww
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-203: Observable Discrepancy
Affected Product Github.com/ginuerzh/gost
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2023-32691

To remediate this vulnerability, upgrade all affected Github.com/ginuerzh/gost dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/ginuerzh/gost fixed: Latest secure release
Upgrade github.com/ginuerzh/gost to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/ginuerzh/gost

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-32691, inspect your project dependencies for Github.com/ginuerzh/gost:

inspect dependencies for github.com/ginuerzh/gost

Analyze the terminal output to locate any version of Github.com/ginuerzh/gost in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-203: Observable Discrepancy, where the product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor. In Github.com/ginuerzh/gost, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

[Timing attacks](https://en.wikipedia.org/wiki/Timing_attack) occur when an attacker can guess a secret by observing a difference in processing time for valid and invalid inputs. Sensitive secrets such as passwords, token and API keys should be compared only using a constant-time comparision function. More information on this attack type can be found in [this blog post](https://verboselogging.com/2012/08/20/a-timing-attack-in-action). # Root Cause Analysis In this case, the vulnerability occurs due to the following code. https://github.com/ginuerzh/gost/blob/1c62376e0880e4094bd3731e06bd4f7842638f6a/auth.go#L46-L46 Here, a untrusted input, sourced from a HTTP header, is compared directly with a secret. Since, this comparision is not secure, an attacker can mount a side-channel timing attack to guess the password. # Remediation This can be easily fixed using a constant time comparing function such as `crypto/subtle`'s `ConstantTimeCompare`. An example fix can be found in https://github.com/runatlantis/atlantis/commit/48870911974adddaa4c99c8089e79b7d787fa820 Alternatively, one can apply the patch below ``` From d18cff85e1a565f688f717fd8f2cacea62ff9dbf Mon Sep 17 00:00:00 2001 From: Porcupiney Hairs <porcupiney.hairs@protonmail.com> Date: Sun, 7 May 2023 01:03:33 +0530 Subject: [PATCH] Fix : Timing attack --- auth.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/auth.go b/auth.go index 1be96e9..be13f23 100644 --- a/auth.go +++ b/auth.go @@ -2,6 +2,7 @@ package gost import ( "bufio" + "crypto/subtle" "io" "strings" "sync" @@ -43,7 +44,8 @@ func (au *LocalAuthenticator) Authenticate(user, password string) bool { } v, ok := au.kvs[user] - return ok && (v == "" || password == v) + passOk := subtle.ConstantTimeCompare([]byte(password), []byte(v)) == 0 + return ok && (v == "" || passOk) } // Add adds a key-value pair to the Authenticator. -- 2.25.1 ```

CVE-2023-32691 Affected Github.com/ginuerzh/gost Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
github.com/ginuerzh/gost
Go
≤ 2.11.5

References

Frequently Asked Questions

What is CVE-2023-32691?
CVE-2023-32691 is a security vulnerability in Github.com/ginuerzh/gost involving ginuerzh/gost vulnerable to Timing Attack under CWE-203: Observable Discrepancy.
Which Github.com/ginuerzh/gost versions are affected?
Affected versions include releases prior to current release patches across affected packages: github.com/ginuerzh/gost.
What version fixes CVE-2023-32691?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/ginuerzh/gost affected?
Yes, github.com/ginuerzh/gost is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2023-32691?
CVE-2023-32691 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N.
What CWE is associated with CVE-2023-32691?
CVE-2023-32691 is classified under CWE-203: Observable Discrepancy (The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor.).
How can I check Go dependencies for CVE-2023-32691?
Run the dependency tree command: 'inspect dependencies for github.com/ginuerzh/gost'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qjrq-hm79-49ww",
  "modified" : "2023-05-30T06:42:29Z",
  "published" : "2023-05-22T19:47:15Z",
  "aliases" : [ "CVE-2023-32691" ],
  "summary" : "ginuerzh/gost vulnerable to Timing Attack",
  "details" : "[Timing attacks](https://en.wikipedia.org/wiki/Timing_attack) occur when an attacker can guess a secret by observing a difference in processing time for valid and invalid inputs. Sensitive secrets such as passwords, token and API keys should be compared only using a constant-time comparision function.\nMore information on this attack type can be found in [this blog post](https://verboselogging.com/2012/08/20/a-timing-attack-in-action). \n\n# Root Cause Analysis\n\nIn this case, the vulnerability occurs due to the following code.\n\nhttps://github.com/ginuerzh/gost/blob/1c62376e0880e4094bd3731e06bd4f7842638f6a/auth.go#L46-L46\n\nHere, a untrusted input, sourced from a HTTP header, is compared directly with a secret. \nSince, this comparision is not secure, an attacker can mount a side-channel timing attack to guess the password.\n\n# Remediation\n\nThis can be easily fixed using a constant time comparing function such as `crypto/subtle`'s `ConstantTimeCompare`. \nAn example fix can be found in https://github.com/runatlantis/atlantis/commit/48870911974adddaa4c99c8089e79b7d787fa820 Alternatively, one can apply the patch below\n\n```\nFrom d18cff85e1a565f688f717fd8f2cacea62ff9dbf Mon Sep 17 00:00:00 2001\nFrom: Porcupiney Hairs <porcupiney.hairs@protonmail.com>\nDate: Sun, 7 May 2023 01:03:33 +0530\nSubject: [PATCH] Fix : Timing attack\n\n---\n auth.go | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/auth.go b/auth.go\nindex 1be96e9..be13f23 100644\n--- a/auth.go\n+++ b/auth.go\n@@ -2,6 +2,7 @@ package gost\n \n import (\n \t\"bufio\"\n+\t\"crypto/subtle\"\n \t\"io\"\n \t\"strings\"\n \t\"sync\"\n@@ -43,7 +44,8 @@ func (au *LocalAuthenticator) Authenticate(user, password string) bool {\n \t}\n \n \tv, ok := au.kvs[user]\n-\treturn ok && (v == \"\" || password == v)\n+\tpassOk := subtle.ConstantTimeCompare([]byte(password), []byte(v)) == 0\n+\treturn ok && (v == \"\" || passOk)\n }\n \n // Add adds a key-value pair to the Authenticator.\n-- \n2.25.1\n\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/ginuerzh/gost"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.11.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ginuerzh/gost/security/advisories/GHSA-qjrq-hm79-49ww"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-32691"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ginuerzh/gost"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ginuerzh/gost/blob/1c62376e0880e4094bd3731e06bd4f7842638f6a/auth.go#L46"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-203" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-22T19:47:15Z",
    "nvd_published_at" : "2023-05-30T04:15:09Z"
  }
}