CVE-2022-1543: Other (NVD-CWE-Other)
value: Improper handling of Length parameter in GitHub repository erudika/scoold prior to 1.49.4. When the text size is large enough the service results in a momentary outage in a production environment. That can lead to memory corruption on the server.
CWE description: NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
CVSS v3 base score: 8.8
Published: 2022-04-29T18:15Z
Repository: https://github.com/erudika/scoold
Language: Java
Files changed: src/main/java/com/erudika/scoold/controllers/ProfileController.java, src/main/java/com/erudika/scoold/core/Profile.java, src/main/java/com/erudika/scoold/utils/ScooldUtils.java
Commit date: 2022-04-26 22:40:13 +0300
Commit message: fixed profile name not limited in length

Diff: diff --git a/src/main/java/com/erudika/scoold/controllers/ProfileController.java b/src/main/java/com/erudika/scoold/controllers/ProfileController.java
index d8aed945..20d74873 100755
--- a/src/main/java/com/erudika/scoold/controllers/ProfileController.java
+++ b/src/main/java/com/erudika/scoold/controllers/ProfileController.java
@@ -238,11 +238,11 @@ public class ProfileController {
 		if (CONF.avatarEditsEnabled() && !StringUtils.isBlank(picture)) {
 			updateProfile = avatarRepository.store(showUser, picture);
 		}
 
 		if (CONF.nameEditsEnabled() && !StringUtils.isBlank(name)) {
-			showUser.setName(name);
+			showUser.setName(StringUtils.abbreviate(name, 256));
 			if (StringUtils.isBlank(showUser.getOriginalName())) {
 				showUser.setOriginalName(name);
 			}
 			if (!u.getName().equals(name)) {
 				u.setName(name);
diff --git a/src/main/java/com/erudika/scoold/core/Profile.java b/src/main/java/com/erudika/scoold/core/Profile.java
index 4d8f9605..5868feaa 100755
--- a/src/main/java/com/erudika/scoold/core/Profile.java
+++ b/src/main/java/com/erudika/scoold/core/Profile.java
@@ -441,11 +441,11 @@ public class Profile extends Sysprop {
 	public String getOriginalName() {
 		return originalName;
 	}
 
 	public void setOriginalName(String originalName) {
-		this.originalName = originalName;
+		this.originalName = StringUtils.abbreviate(originalName, 256);
 	}
 
 	public String getOriginalPicture() {
 		return originalPicture;
 	}
diff --git a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
index 2d5599ff..21e1c178 100755
--- a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
+++ b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java
@@ -343,11 +343,11 @@ public final class ScooldUtils {
 				&& !CONF.avatarEditsEnabled()) {
 			authUser.setPicture(u.getPicture());
 			update = true;
 		}
 		if (!CONF.nameEditsEnabled() &&	!StringUtils.equals(u.getName(), authUser.getName())) {
-			authUser.setName(u.getName());
+			authUser.setName(StringUtils.abbreviate(u.getName(), 256));
 			update = true;
 		}
 		if (!StringUtils.equals(u.getName(), authUser.getOriginalName())) {
 			authUser.setOriginalName(u.getName());
 			update = true;

Vulnerable code: 			showUser.setName(name);
		this.originalName = originalName;
			authUser.setName(u.getName());
Fixed code: 			showUser.setName(StringUtils.abbreviate(name, 256));
		this.originalName = StringUtils.abbreviate(originalName, 256);
			authUser.setName(StringUtils.abbreviate(u.getName(), 256));