security-hardening

star 241

RBAC configuration, row policies, quotas, network security, audit logging, and access control best practices.

duyet By duyet schedule Updated 5/9/2026

name: security-hardening description: "RBAC configuration, row policies, quotas, network security, audit logging, and access control best practices."

Security Hardening

RBAC (Role-Based Access Control)

  • Create roles: CREATE ROLE analyst
  • Grant permissions: GRANT SELECT ON db.* TO analyst
  • Assign to users: GRANT analyst TO user1
  • Hierarchical: roles can inherit from other roles
  • Check grants: SHOW GRANTS FOR user1
  • Inspect user: SHOW CREATE USER username
  • Password rotation: ALTER USER username IDENTIFIED BY 'new_password'

Row Policies

  • Restrict row access per user: CREATE ROW POLICY p ON db.table FOR SELECT USING tenant_id = currentUser()
  • Policies are AND-ed together
  • Use for multi-tenant data isolation
  • Check policies: system.row_policies

Quotas

  • Limit resource usage per user/IP: CREATE QUOTA q FOR user1 ... LIMIT max_queries = 100
  • Quota intervals: per hour, per day, etc.
  • Limits: max_queries, max_result_rows, max_read_rows, max_execution_time
  • Monitor: system.quota_usage

Network Security

  • Restrict user access by IP: CREATE USER u HOST IP '10.0.0.0/8'
  • Use TLS for client connections
  • Inter-server encryption for replication
  • Separate ports for internal vs external access

Audit Logging

  • Enable system.session_log for login tracking
  • system.query_log records all queries with user info
  • system.text_log for server-level events
  • Configure log retention with TTL

Best Practices

  • Principle of least privilege — grant only needed permissions
  • Use roles, not direct user grants
  • Separate read-only and admin users
  • Enable quotas for all non-admin users
  • Regular audit of grants and access patterns
  • Use readonly = 1 setting for monitoring connections
Install via CLI
npx skills add https://github.com/duyet/clickhouse-monitoring --skill security-hardening
Repository Details
star Stars 241
call_split Forks 39
navigation Branch main
article Path SKILL.md
More from Creator