CVE-2022-31038: Gogs.io/gogs Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-xq4v-vrp9-vcf2
CVSS 5.4
CWE-80 CWE-79
Published
Advisory Summary

CVE-2022-31038 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Gogs.io/gogs libraries in the Go ecosystem. The issue involves cross-site scripting vulnerability in repository issue list in gogs. Remediation is available by upgrading affected packages to version 0.12.9.

CVE-2022-31038 at a Glance

CVE Identifier CVE-2022-31038
GHSA Identifier GHSA-xq4v-vrp9-vcf2
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Gogs.io/gogs
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.4

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

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

How to Fix CVE-2022-31038

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

gogs.io/gogs fixed: 0.12.9
Upgrade gogs.io/gogs to 0.12.9
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 gogs.io/gogs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-31038, inspect your project dependencies for Gogs.io/gogs:

inspect dependencies for gogs.io/gogs

Analyze the terminal output to locate any version of Gogs.io/gogs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.12.9), 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-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Gogs.io/gogs, 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

### Impact `DisplayName` allows all the characters from users, which leads to an XSS vulnerability when directly displayed in the issue list. ### Patches `DisplayName` is sanitized before being displayed. Users should upgrade to 0.12.9 or the latest 0.13.0+dev. ### Workarounds Check and update the existing users' display names that contain malicious characters. ### References N/A ### For more information If you have any questions or comments about this advisory, please post on https://github.com/gogs/gogs/pull/7009.

CVE-2022-31038 Affected Gogs.io/gogs Versions

1 component(s)
Fixed Versions:
0.12.9
Product / Package Ecosystem Affected Versions Fixed Version
gogs.io/gogs
Go
< 0.12.9
0.12.9

References

Frequently Asked Questions

What is CVE-2022-31038?
CVE-2022-31038 is a security vulnerability in Gogs.io/gogs involving Cross-site Scripting vulnerability in repository issue list in Gogs under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Gogs.io/gogs versions are affected?
Affected versions include releases prior to 0.12.9 across affected packages: gogs.io/gogs.
What version fixes CVE-2022-31038?
Upgrading to 0.12.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gogs.io/gogs affected?
Yes, gogs.io/gogs is affected in releases prior to 0.12.9. Upgrade your dependency to 0.12.9 or later.
What is the CVSS score of CVE-2022-31038?
CVE-2022-31038 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2022-31038?
CVE-2022-31038 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check Go dependencies for CVE-2022-31038?
Run the dependency tree command: 'inspect dependencies for gogs.io/gogs'. 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-xq4v-vrp9-vcf2",
  "modified" : "2022-06-08T22:24:25Z",
  "published" : "2022-06-08T22:24:25Z",
  "aliases" : [ "CVE-2022-31038" ],
  "summary" : "Cross-site Scripting vulnerability in repository issue list in Gogs",
  "details" : "### Impact\n`DisplayName` allows all the characters from users, which leads to an XSS vulnerability when directly displayed in the issue list.\n\n### Patches\n`DisplayName` is sanitized before being displayed. Users should upgrade to 0.12.9 or the latest 0.13.0+dev.\n\n### Workarounds\nCheck and update the existing users' display names that contain malicious characters.\n\n### References\nN/A\n\n### For more information\nIf you have any questions or comments about this advisory, please post on https://github.com/gogs/gogs/pull/7009.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "gogs.io/gogs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.12.9"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/security/advisories/GHSA-xq4v-vrp9-vcf2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31038"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/pull/7009"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/commit/155cae1de8916fc3fde78f350763034b7422caee"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gogs/gogs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/releases/tag/v0.12.9"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-08T22:24:25Z",
    "nvd_published_at" : "2022-06-09T17:15:00Z"
  }
}