CVE-2023-33962: JStachio XSS vulnerability Unescaped Single Quotes Vulnerability

MODERATE
Advisory Identifier: GHSA-gwxv-jv83-6qjr
CVSS 5.4
CWE-79
Published
Advisory Summary

CVE-2023-33962 is a MODERATE (CVSS 5.4) unescaped single quotes vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting JStachio XSS vulnerability libraries in the Maven ecosystem. The issue involves unescaped single quotes. Remediation is available by upgrading affected packages to version 1.0.1.

CVE-2023-33962 at a Glance

CVE Identifier CVE-2023-33962
GHSA Identifier GHSA-gwxv-jv83-6qjr
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product JStachio XSS vulnerability
Package Ecosystem Maven
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-2023-33962

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

io.jstach:jstachio fixed: 1.0.1
<dependency>
    <groupId>io.jstach</groupId>
    <artifactId>jstachio</artifactId>
    <version>1.0.1</version>
</dependency>
Verify Direct and Transitive Dependencies

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

mvn dependency:tree -Dincludes=io.jstach

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2023-33962, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=io.jstach

Analyze the terminal output to locate any version of JStachio XSS vulnerability in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.1), your application is affected.

Note: The mvn dependency:tree -Dincludes=io.jstach command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In JStachio XSS vulnerability, 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 #### Description: JStachio fails to escape single quotes `'` in HTML, allowing an attacker to inject malicious code. #### Reproduction Steps: Use the following template code: ```html <div attr='{{value}}'></div> ``` Set the value variable to `' onblur='alert(1)`. ```java public class Escaping { public static void main(String[] args) { Model model = new Model("' onblur='alert(1)"); String result = AttributeTemplate.of().execute(model); System.out.println(result); } @JStache(template = "<div attr='{{value}}'></div>", name="AttributeTemplate") @JStacheConfig(contentType= Html.class) public static class Model { public final String value; public Model(String value) { this.value = value; } public String getValue() { return value; } } } ``` Expected Result: The resulting output should have properly escaped the single quotes and not execute the injected JavaScript code. Actual Result: The resulting output is vulnerable and renders as follows: ```html <div attr='' onblur='alert(1)'></div> ``` #### Impact and Risk: This vulnerability can be exploited by an attacker to execute arbitrary JavaScript code in the context of other users visiting pages that use this template engine. This can lead to various consequences, including session hijacking, defacement of web pages, theft of sensitive information, or even the propagation of malware. #### Proposed Solution: To mitigate this vulnerability, the template engine should properly escape special characters, including single quotes. Common practice is to escape `'` as `&#39`. ### Patches - ### Workarounds As long as users stick with double quotes `"` for HTML attributes, they should not be affected. ### References For instance, [Rocker's general purpose HTML escaping](https://github.com/fizzed/rocker/blob/d749fbf68179b31a64d541f5e18e0e25bc5c2d1b/rocker-runtime/src/main/java/com/fizzed/rocker/runtime/DefaultHtmlStringify.java#L64)

CVE-2023-33962 Affected JStachio XSS vulnerability Versions

1 component(s)
Fixed Versions:
1.0.1
Product / Package Ecosystem Affected Versions Fixed Version
io.jstach:jstachio
Maven
< 1.0.1
1.0.1

References

Frequently Asked Questions

What is CVE-2023-33962?
CVE-2023-33962 is a security vulnerability in JStachio XSS vulnerability involving Unescaped single quotes under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which JStachio XSS vulnerability versions are affected?
Affected versions include releases prior to 1.0.1 across affected packages: io.jstach:jstachio.
What version fixes CVE-2023-33962?
Upgrading to 1.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jstachio affected?
Yes, io.jstach:jstachio is affected in releases prior to 1.0.1. Upgrade your dependency to 1.0.1 or later.
What is the CVSS score of CVE-2023-33962?
CVE-2023-33962 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-2023-33962?
CVE-2023-33962 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Maven dependencies for CVE-2023-33962?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=io.jstach'. 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-gwxv-jv83-6qjr",
  "modified" : "2023-06-06T00:45:18Z",
  "published" : "2023-06-06T00:45:18Z",
  "aliases" : [ "CVE-2023-33962" ],
  "summary" : "JStachio XSS vulnerability: Unescaped single quotes",
  "details" : "### Impact\n\n#### Description:\nJStachio fails to escape single quotes `'` in HTML, allowing an attacker to inject malicious code.\n\n#### Reproduction Steps:\nUse the following template code:\n```html\n<div attr='{{value}}'></div>\n```\n\nSet the value variable to `' onblur='alert(1)`.\n\n```java\npublic class Escaping {\n\n    public static void main(String[] args) {\n        Model model = new Model(\"' onblur='alert(1)\");\n        String result = AttributeTemplate.of().execute(model);\n        System.out.println(result);\n    }\n\n    @JStache(template = \"<div attr='{{value}}'></div>\",\n            name=\"AttributeTemplate\")\n    @JStacheConfig(contentType= Html.class)\n    public static class Model {\n\n        public final String value;\n\n        public Model(String value) {\n            this.value = value;\n        }\n\n        public String getValue() {\n            return value;\n        }\n    }\n}\n```\n\nExpected Result:\nThe resulting output should have properly escaped the single quotes and not execute the injected JavaScript code.\n\nActual Result:\nThe resulting output is vulnerable and renders as follows:\n```html\n<div attr='' onblur='alert(1)'></div>\n```\n\n#### Impact and Risk:\nThis vulnerability can be exploited by an attacker to execute arbitrary JavaScript code in the context of other users visiting pages that use this template engine. This can lead to various consequences, including session hijacking, defacement of web pages, theft of sensitive information, or even the propagation of malware.\n\n#### Proposed Solution:\nTo mitigate this vulnerability, the template engine should properly escape special characters, including single quotes. Common practice is to escape `'` as `&#39`.\n\n### Patches\n-\n\n### Workarounds\nAs long as users stick with double quotes `\"` for HTML attributes, they should not be affected.\n\n### References\nFor instance, [Rocker's general purpose HTML escaping](https://github.com/fizzed/rocker/blob/d749fbf68179b31a64d541f5e18e0e25bc5c2d1b/rocker-runtime/src/main/java/com/fizzed/rocker/runtime/DefaultHtmlStringify.java#L64)\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" : "Maven",
      "name" : "io.jstach:jstachio"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jstachio/jstachio/security/advisories/GHSA-gwxv-jv83-6qjr"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-33962"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jstachio/jstachio/issues/157"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jstachio/jstachio/pull/158"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jstachio/jstachio/commit/7b2f78377d1284df14c580be762a25af5f8dcd66"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jstachio/jstachio"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jstachio/jstachio/releases/tag/v1.0.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-06-06T00:45:18Z",
    "nvd_published_at" : "2023-05-30T22:15:10Z"
  }
}