Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool invalidatecredentialscache

Cassandra 4.1+

This command is available in Cassandra 4.1 and later.

Invalidates the credentials cache on the node.


Terminal window
nodetool [connection_options] invalidatecredentialscache

See connection options for connection options.

nodetool invalidatecredentialscache clears all cached credential entries on the node. The credentials cache stores authentication information (username/password hashes), allowing Cassandra to validate login attempts without querying the system_auth.roles table for every connection.

After invalidation, subsequent login attempts trigger fresh credential lookups from the system_auth tables.

Authentication Required

The credentials cache is only relevant when authentication is enabled (PasswordAuthenticator or custom authenticator). If running with AllowAllAuthenticator, this cache is not used.


Terminal window
nodetool invalidatecredentialscache
Terminal window
# After changing a user's password
nodetool invalidatecredentialscache

Cached DataDescription
UsernameThe role/user name
Password hashBcrypt hash of the password
Login statusWhether the role can login
Without Credentials Cache:
Login Attempt → Query system_auth.roles → Verify password → Establish session
With Credentials Cache:
Login Attempt → Check cached credentials → Establish session
(Avoids auth table query on every login)

When password changes don't immediately take effect:

Terminal window
# Change password
cqlsh -e "ALTER ROLE user_name WITH PASSWORD = 'new_password';"
# Force cache refresh
nodetool invalidatecredentialscache

When disabling login access:

Terminal window
# Disable login
cqlsh -e "ALTER ROLE compromised_user WITH LOGIN = false;"
# Immediate effect required
nodetool invalidatecredentialscache

When immediate credential invalidation is critical:

emergency_credential_revoke.sh
#!/bin/bash
USER="$1"
# Change password to random value
NEW_PASS=$(openssl rand -base64 32)
cqlsh -e "ALTER ROLE $USER WITH PASSWORD = '$NEW_PASS';"
# Disable login
cqlsh -e "ALTER ROLE $USER WITH LOGIN = false;"
# Clear cache on all nodes
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
ssh "$node" "nodetool invalidatecredentialscache"
done
echo "User $USER credentials invalidated cluster-wide."

When authentication appears incorrect:

Terminal window
# Clear potentially stale credentials
nodetool invalidatecredentialscache
# Retry login

AspectImpact
Cached credentialsAll cleared
Next loginsRequire auth table lookups
Existing connectionsNot affected
ScenarioBehavior
Password changeNew password required immediately
Login disabledCannot establish new connections
Role deletedCannot login

Existing Connections

Invalidating credentials cache only affects new login attempts. Existing connections remain valid until they are closed or timeout.


The cassandra.yaml parameter names vary by version:

Cassandra VersionValidity ParameterUpdate Interval Parameter
Pre-4.1credentials_validity_in_mscredentials_update_interval_in_ms
4.1+credentials_validitycredentials_update_interval
# cassandra.yaml (4.1+)
credentials_validity: 2s
credentials_update_interval: 1s
credentials_cache_max_entries: 1000
# cassandra.yaml (Pre-4.1)
# credentials_validity_in_ms: 2000
# credentials_update_interval_in_ms: 1000
# credentials_cache_max_entries: 1000

Credentials are automatically refreshed based on credentials_validity. Invalidation forces immediate refresh for new connections.


For credential changes to take effect cluster-wide immediately:

invalidate_credentials_cluster.sh
#!/bin/bash
echo "Invalidating credentials cache cluster-wide..."
# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do
echo -n "$node: "
ssh "$node" 'nodetool invalidatecredentialscache 2>/dev/null && echo "invalidated" || echo "FAILED"'
done
echo "Credentials cache cleared on all nodes."
rotate_password.sh
#!/bin/bash
USER="$1"
NEW_PASSWORD="$2"
if [ -z "$USER" ] || [ -z "$NEW_PASSWORD" ]; then
echo "Usage: $0 <username> <new_password>"
exit 1
fi
echo "=== Password Rotation ==="
# 1. Change password
echo "1. Changing password for $USER..."
cqlsh -e "ALTER ROLE $USER WITH PASSWORD = '$NEW_PASSWORD';"
# 2. Invalidate cache cluster-wide
echo "2. Invalidating credentials cache..."
# Get list of node IPs from local nodetool status
nodes=$(nodetool status | grep "^UN" | awk '{print $2}')
for node in $nodes; do
ssh "$node" "nodetool invalidatecredentialscache 2>/dev/null"
done
echo "3. Password changed. New password takes effect immediately."
echo ""
echo "NOTE: Existing connections continue to work."
echo "For complete session termination, restart affected applications."

lockout_user.sh
#!/bin/bash
USER="$1"
echo "=== Immediate User Lockout ==="
# 1. Disable login
cqlsh -e "ALTER ROLE $USER WITH LOGIN = false;"
# 2. Clear cache on all nodes
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
ssh "$node" "nodetool invalidatecredentialscache"
done
echo "User $USER locked out."
echo ""
echo "NOTE: To terminate existing connections, may need to:"
echo " - Restart client applications"
echo " - Or wait for connection timeout"
password_compromise_response.sh
#!/bin/bash
USER="$1"
echo "=== Password Compromise Response ==="
# 1. Generate new random password
NEW_PASS=$(openssl rand -base64 24)
# 2. Change password
cqlsh -e "ALTER ROLE $USER WITH PASSWORD = '$NEW_PASS';"
# 3. Invalidate cache cluster-wide
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
ssh "$node" "nodetool invalidatecredentialscache"
done
# 4. Log the incident
echo "$(date): Password compromised for $USER - password reset" >> /var/log/security_incidents.log
echo "Password reset complete."
echo "New temporary password: $NEW_PASS"
echo "User should change this password immediately."

Terminal window
# Invalidate on all nodes
for node in $(nodetool status | grep "^UN" | awk '{print $2}'); do
ssh "$node" "nodetool invalidatecredentialscache"
done
# Verify the change was stored
cqlsh -e "SELECT role, salted_hash FROM system_auth.roles WHERE role = 'username';"
Terminal window
# Ensure LOGIN = false is set
cqlsh -e "SELECT role, can_login FROM system_auth.roles WHERE role = 'username';"
# Invalidate cache
nodetool invalidatecredentialscache
# Note: Existing connections remain until closed
Terminal window
# Check if auth tables are accessible
nodetool status
# Check for auth errors
grep -i "auth" /var/log/cassandra/system.log | tail -20
# Verify superuser still exists
cqlsh -u cassandra -p cassandra -e "SELECT * FROM system_auth.roles;"

Credentials Cache Guidelines

  1. Always invalidate cluster-wide - For password/login changes
  2. Use short validity periods - For security-sensitive environments
  3. Immediate response - Invalidate immediately for security incidents
  4. Test changes - Verify authentication works as expected
  5. Document procedures - Have runbooks for credential management

Security Best Practices

  • Invalidate cache immediately when revoking access
  • Use strong passwords (Cassandra uses bcrypt)
  • Monitor failed login attempts
  • Consider shorter credentials_validity_in_ms for sensitive environments
  • Remember existing connections are not affected

CommandRelationship
invalidatepermissionscacheInvalidate permissions cache
invalidaterolescacheInvalidate roles cache