Port 9042 is the Apache Cassandra CQL (Cassandra Query Language) native protocol port. Applications connect to port 9042 to execute CQL queries, manage schemas, and perform CRUD operations. Cassandra ships with authentication disabled by default – enable PasswordAuthenticator before any network exposure.
Port Number
9042
Protocol
TCP
Service
Apache Cassandra Native Protocol
Range
IANA Registered (1024–49151)
Test if default credentials work – if this succeeds, the cluster is critically misconfigured
cqlsh host 9042 -u cassandra -p cassandra -e 'DESCRIBE KEYSPACES;'Check Cassandra cluster topology, node states, and data distribution (requires JMX on port 7199)
nodetool statusCheck if authentication logging is enabled – silent auth failures indicate brute force attempts
nodetool getlogginglevels | grep authAudit Cassandra security configuration – authenticator, authorizer, and TLS settings
grep -E 'authenticator|authorizer|client_encryption' /etc/cassandra/cassandra.yamlList all Cassandra roles and their privileges – identify overprivileged accounts
cqlsh host 9042 -e "SELECT role, can_login, is_superuser FROM system_auth.roles;"Probe Cassandra native protocol on port 9042 for version info and cluster name disclosure
nmap -sV -p 9042 --script cassandra-info targetcqlsh host 9042 -u cassandra -p cassandra
nodetool enableauth (deprecated – edit cassandra.yaml instead)
cassandra.yaml: native_transport_port: 9042Port 9042 was introduced in Cassandra 1.2 (2012) as the native binary protocol port, replacing the Thrift-based interface on port 9160. The CQL native protocol was designed for efficiency (binary framing, multiplexing, prepared statements) and became the exclusive client interface when Thrift was removed in Cassandra 4.0 (2021). The decision to ship without authentication by default (AllowAllAuthenticator) was a deliberate developer-experience choice that made Cassandra easy to prototype with but catastrophically insecure in production. Shodan consistently finds thousands of internet-exposed Cassandra instances on port 9042 with default credentials, leading to data breaches and ransomware attacks against unprotected clusters.
How do I enable authentication on Cassandra port 9042?
1) Edit cassandra.yaml: set authenticator: PasswordAuthenticator and authorizer: CassandraAuthorizer. 2) Restart all nodes (rolling restart for zero downtime). 3) Login with default superuser: cqlsh -u cassandra -p cassandra. 4) Create a new superuser: CREATE ROLE admin WITH PASSWORD='strong' AND SUPERUSER=true AND LOGIN=true. 5) Drop or disable the default cassandra role. 6) Create application-specific roles with minimal GRANT permissions per keyspace.
How do I enable TLS encryption on Cassandra port 9042?
In cassandra.yaml, configure client_encryption_options: enabled: true, optional: false (force TLS), keystore: /path/keystore.jks, keystore_password: secret, require_client_auth: true (for mTLS). Alternatively, use port 9142 (native_transport_port_ssl) for TLS while keeping 9042 for localhost-only unencrypted connections. Generate keystores: keytool -genkey -keyalg RSA -alias cassandra -keystore keystore.jks.
What is the impact of CVE-2021-44521 on Cassandra?
CVE-2021-44521 allows remote code execution through User-Defined Functions (UDFs) in Cassandra 3.0-3.11.x and 4.0.x. An authenticated user who can execute CQL CREATE FUNCTION on port 9042 can escape the UDF sandbox and run arbitrary system commands as the cassandra OS user. Mitigation: upgrade to 3.0.26+, 3.11.12+, or 4.0.2+. Workaround: set enable_user_defined_functions: false in cassandra.yaml (default is false, but some deployments enable it for analytics).