Skip to content

Authorization enforced only in the Swing UI; all admin functions accessible by any user #4

Open

Description

@ThanatosXingYu

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

  1. Deploy the application and import mis.sql.

  2. Register two accounts: normaluser (non-admin) and adminuser (if the table was empty, normaluser becomes admin; otherwise register when users exist to get admin=0).

  3. As normaluser, the UI shows only the regular account management tab; admin tabs are hidden.

  4. Open a MySQL client using the hardcoded credentials from ConnectDatabase.java:

mysql -h localhost -u root -p123456 mis
  1. Promote normaluser to admin:
UPDATE usertable SET admin = 1 WHERE user = 'normaluser';
  1. Delete another user:
DELETE FROM usertable WHERE user = 'adminuser';
  1. Reset any user's password:
UPDATE usertable SET password = 'hacked' WHERE user = 'normaluser';
  1. 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;
  1. All operations succeed because the MySQL root account 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 root credentials 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions