Repository navigation
Description
Title
Authorization enforced only in the Swing UI; all admin functions accessible by any user
Summary
The application checks the admin column only in the client-side UI (MainInterface.java) to show or hide admin functionality. The underlying database operations have no authorization verification. Because the thick client connects to MySQL as root, any user can bypass the UI and directly execute administrative SQL statements.
Affected Version
Commit: 70a6eb6b96fe64575d8051f1a59055bfc5dc5885
Vulnerability Type
Client-Side Enforcement of Server-Side Security (CWE-602)
Affected Code
File: src/view/MainInterface.java, lines 71-86
if(Landing.sureadmin(user)) {
Admin admin = new Admin();
admin.setUser(user);
admin.setFrame(this);
jTabbedPane.add("账户管理", admin.jPanel2);
BookAdmin bookAdmin = new BookAdmin();
bookAdmin.setModel(search.model);
jTabbedPane.add("图书管理", bookAdmin.jPanel2);
} else {
AccountManagement management = new AccountManagement();
management.setUser(user);
management.setFrame(this);
jTabbedPane.add("账户管理", management.jPanel2);
}File: src/database/UpdateAdmin.java — all methods (deleteuser, updateuser, updateadmin, updatepass) perform operations without checking the caller's role.
File: src/database/Book.java — addbook, modifybook, deletebook have no authorization checks.
File: src/database/Category.java — addcategory, setcategory have no authorization checks.
Root Cause
The application uses a two-tier architecture: a Java Swing desktop client connects directly to MySQL with a shared root account. Authorization is implemented exclusively by hiding UI elements from non-admin users. The database layer trusts every caller unconditionally. There is no middleware, no API layer, and no stored-procedure-based access control to enforce roles. Any user who modifies the client binary, uses a database client, or writes a simple JDBC program can perform any operation. Additionally, Landing.sureadmin() returns true when the user lookup produces no rows (src/database/Landing.java, lines 56-65), so the administrator UI is granted by default if the account is missing at check time — a second, fail-open authorization defect.
Steps to Reproduce
-
Deploy the application and import
mis.sql. -
Register two accounts:
normaluser(non-admin) andadminuser(if the table was empty,normaluserbecomes admin; otherwise register when users exist to getadmin=0). -
As
normaluser, the UI shows only the regular account management tab; admin tabs are hidden. -
Open a MySQL client using the hardcoded credentials from
ConnectDatabase.java:
mysql -h localhost -u root -p123456 mis- Promote
normaluserto admin:
UPDATE usertable SET admin = 1 WHERE user = 'normaluser';- Delete another user:
DELETE FROM usertable WHERE user = 'adminuser';- Reset any user's password:
UPDATE usertable SET password = 'hacked' WHERE user = 'normaluser';- Add, modify, or delete books:
INSERT INTO booktable (category, bookname, author, press, state) VALUES ('test', 'Evil Book', 'Attacker', 'None', '在馆');
DELETE FROM booktable WHERE bookid = 1;- All operations succeed because the MySQL
rootaccount has full privileges and no application-level authorization is enforced.
Impact
- Complete authorization bypass: any authenticated user (or anyone with the published credentials) can perform every administrative action.
- Privilege escalation: a non-admin user can promote themselves to admin.
- Data integrity destruction: arbitrary deletion of users, books, categories, and borrowing records.
- Password takeover: an attacker can reset any user's password.
- The UI-only access control provides no security against a minimally skilled attacker.
Remediation
- Introduce a server-side middleware layer (e.g., a REST API with role-based access control) between the client and the database.
- Never connect a client application directly to the database with a superuser account.
- Use a dedicated low-privilege MySQL user for the application, and enforce row-level or role-based access via stored procedures or a backend service.
- Validate the user's role on the server side for every privileged operation.
- Remove the hardcoded
rootcredentials from the client.
CVSS Score
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — 8.8 (High)
Activity