This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new c5e5162385d Fix account unlock permission check for unprivileged users
(#19301)
c5e5162385d is described below
commit c5e5162385d2b9ab4f2aa28f6adad7608a5f24db
Author: Hongzhi Gao <[email protected]>
AuthorDate: Tue Nov 17 14:45:56 2026 +0800
Fix account unlock permission check for unprivileged users (#19301)
---
.../org/apache/iotdb/db/it/auth/IoTDBAuthIT.java | 36 ++++++++++++++++++++++
.../security/TreeAccessCheckVisitor.java | 7 ++++-
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java
index a8c4f743de0..ca7cac626bf 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java
@@ -1745,6 +1745,42 @@ public class IoTDBAuthIT {
}
}
+ @Test
+ public void testAccountUnlockPermission() throws SQLException {
+ try (Connection adminCon = EnvFactory.getEnv().getConnection();
+ Statement adminStmt = adminCon.createStatement()) {
+ adminStmt.execute("CREATE USER unlock_user 'abcdef123456'");
+ String[] unlockStatements = {
+ "ALTER USER unlock_user ACCOUNT UNLOCK",
+ "ALTER USER root ACCOUNT UNLOCK",
+ "ALTER USER unlock_user @ '127.0.0.1' ACCOUNT UNLOCK"
+ };
+ try (Connection userCon =
EnvFactory.getEnv().getConnection("unlock_user", "abcdef123456");
+ Statement userStmt = userCon.createStatement()) {
+ for (String sql : unlockStatements) {
+ SQLException exception =
+ Assert.assertThrows(SQLException.class, () ->
userStmt.execute(sql));
+ assertEquals(TSStatusCode.NO_PERMISSION.getStatusCode(),
exception.getErrorCode());
+ assertTrue(exception.getMessage(),
exception.getMessage().contains("SECURITY"));
+ adminStmt.execute(sql);
+ }
+
+ adminStmt.execute("GRANT SECURITY ON root.** TO USER unlock_user");
+ for (String sql : unlockStatements) {
+ userStmt.execute(sql);
+ }
+
+ adminStmt.execute("REVOKE SECURITY ON root.** FROM USER unlock_user");
+ for (String sql : unlockStatements) {
+ SQLException exception =
+ Assert.assertThrows(SQLException.class, () ->
userStmt.execute(sql));
+ assertEquals(TSStatusCode.NO_PERMISSION.getStatusCode(),
exception.getErrorCode());
+ assertTrue(exception.getMessage(),
exception.getMessage().contains("SECURITY"));
+ }
+ }
+ }
+ }
+
@Test
public void testAudit() {
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/security/TreeAccessCheckVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/security/TreeAccessCheckVisitor.java
index 5dcb60d6cd5..18a155ad2ec 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/security/TreeAccessCheckVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/security/TreeAccessCheckVisitor.java
@@ -733,11 +733,16 @@ public class TreeAccessCheckVisitor extends
StatementVisitor<TSStatus, TreeAcces
}
return status;
+ case ACCOUNT_UNLOCK:
+ return checkGlobalAuth(
+ context.setAuditLogOperation(AuditLogOperation.DDL),
+ PrivilegeType.SECURITY,
+ statement::getUserName);
+
case REVOKE_USER:
case GRANT_USER:
case GRANT_ROLE:
case REVOKE_ROLE:
- case ACCOUNT_UNLOCK:
auditObject =
() ->
authorType == AuthorType.REVOKE_USER || authorType ==
AuthorType.GRANT_USER