CVE-2025-30223

CVE-2025-30223 is a critical-severity cross-site scripting (XSS) vulnerability in github.com/beego/beego/v2 (go), affecting versions < 2.3.6. It is fixed in 2.3.6.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Beego allows Reflected/Stored XSS in Beego's RenderForm() Function Due to Unescaped User Input

A Cross-Site Scripting (XSS) vulnerability exists in Beego's RenderForm() function due to improper HTML escaping of user-controlled data. This vulnerability allows attackers to inject malicious JavaScript code that executes in victims' browsers, potentially leading to session hijacking, credential theft, or account takeover. The vulnerability affects any application using Beego's RenderForm() function with user-provided data. Since it is a high-level function generating an entire form markup, many developers would assume it automatically escapes attributes (the way most frameworks do).

Details

The vulnerability is located in the renderFormField() function in Beego's templatefunc.go file (around lines 316-356). This function directly injects user-provided values into HTML without proper escaping:

return fmt.Sprintf(`%v<input%v%v name="%v" type="%v" value="%v"%v>`, 
    label, id, class, name, fType, value, requiredString)

None of the values (label, id, class, name, value) are properly HTML-escaped before being inserted into the HTML template. This allows attackers to break out of the attribute context or inject HTML tags directly.
The vulnerability can be exploited in two main ways:

  • Attribute Injection: By injecting code into fields like DisplayName, an attacker can break out of the attribute context and execute JavaScript.
  • Content Injection: By injecting HTML tags into textarea content, an attacker can execute JavaScript.

The RenderForm() function returns template.HTML, which bypasses Go's automatic HTML escaping, making this vulnerability particularly dangerous.

PoC

Retrieve the following (secret) gist: https://gist.github.com/thevilledev/8fd0cab3f098320aa9daab04be59fd2b

To run it:

go mod init beego-xss-poc
go mod tidy
go run poc.go

Open your browser and navigate to http://localhost:8080/

The application demonstrates the vulnerability through several examples:

  • /profile - Shows a profile with malicious data in the Display Name and Bio fields
  • /admin - Shows multiple user profiles, including one with malicious data
  • /submit - Allows you to create your own profile with malicious data

In addition, you may use this Go test in templatefunc_test.go. The test passes, validating the vulnerability.

func TestRenderFormXSSVulnerability(t *testing.T) {
	type UserProfile struct {
		DisplayName string `form:"displayName,text,Name:"`
		Bio         string `form:",textarea"`
	}

	// Test case 1: Attribute injection in input field
	maliciousUser := UserProfile{
		DisplayName: `" onmouseover="alert('XSS')" data-malicious="`,
		Bio:         "Normal bio text",
	}

	output := RenderForm(&maliciousUser)

	// The vulnerable output would contain the unescaped JavaScript
	if !strings.Contains(string(output), `onmouseover="alert('XSS')"`) {
		t.Errorf("Expected XSS vulnerability in attribute, but got safe output: %v", output)
	}

	// Test case 2: Script injection in textarea
	maliciousUser2 := UserProfile{
		DisplayName: "Normal Name",
		Bio:         `</textarea><script>alert('XSS')</script><textarea>`,
	}

	output = RenderForm(&maliciousUser2)

	// The vulnerable output would contain the unescaped script tag
	if !strings.Contains(string(output), `</textarea><script>alert('XSS')`) {
		t.Errorf("Expected XSS vulnerability in textarea content, but got safe output: %v", output)
	}
}

Mitigation

The vulnerability can be fixed by properly escaping all user-provided values before inserting them into HTML, for example:

// Convert value to string and escape it
valueStr := ""
if value != nil {
    valueStr = template.HTMLEscapeString(fmt.Sprintf("%v", value))
}

// Escape the name and label
escapedName := template.HTMLEscapeString(name)
escapedLabel := template.HTMLEscapeString(label)
escapedType := template.HTMLEscapeString(fType)

return fmt.Sprintf(`%v<input%v%v name="%v" type="%v" value="%v"%v>`, 
    escapedLabel, id, class, escapedName, escapedType, valueStr, requiredString)

Impact

This is a high-severity vulnerability with the following impacts:

  • Cross-Site Scripting (XSS): Allows execution of arbitrary JavaScript in the context of the victim's browser.
  • Session Hijacking: Attackers can steal session cookies and impersonate victims.
  • Credential Theft: Attackers can create fake login forms to steal credentials.
  • Account Takeover: Attackers can perform actions on behalf of the victim.
  • Data Exfiltration: Sensitive data visible in the browser can be stolen.

This is particularly concerning in admin panels or user management interfaces where one user's data is displayed to another user (typically an administrator).

Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.

CVE-2025-30223 has a CVSS score of 9.3 (Critical). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.3.6); upgrading removes the vulnerable code path.

Affected versions

github.com/beego/beego/v2 (< 2.3.6) github.com/beego/beego (<= 1.12.14)

Security releases

github.com/beego/beego/v2 → 2.3.6 (go)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Upgrade github.com/beego/beego/v2 to 2.3.6 or later to resolve this vulnerability.

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2025-30223? CVE-2025-30223 is a critical-severity cross-site scripting (XSS) vulnerability in github.com/beego/beego/v2 (go), affecting versions < 2.3.6. It is fixed in 2.3.6. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
  2. How severe is CVE-2025-30223? CVE-2025-30223 has a CVSS score of 9.3 (Critical). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which packages are affected by CVE-2025-30223?
    • github.com/beego/beego/v2 (go) (versions < 2.3.6)
    • github.com/beego/beego (go) (versions <= 1.12.14)
  4. Is there a fix for CVE-2025-30223? Yes. CVE-2025-30223 is fixed in 2.3.6. Upgrade to this version or later.
  5. Is CVE-2025-30223 exploitable, and should I be worried? Whether CVE-2025-30223 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2025-30223 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2025-30223? Upgrade github.com/beego/beego/v2 to 2.3.6 or later.

Other vulnerabilities in github.com/beego/beego/v2

Stop the waste.
Protect your environment with Kodem.