Authentication and Authorization
Securing Your RPC Handlers with Role-Based Access Control
← Back to Understanding XRPL(d) RPC Architecture
Introduction
Security is paramount when building RPC handlers that interact with the XRP Ledger. Rippled implements a comprehensive role-based access control (RBAC) system to ensure that only authorized clients can execute sensitive operations.
In this section, you'll learn how to properly configure permissions, implement role checks, manage resource limits, and protect your custom handlers from unauthorized access.
The Role Hierarchy
Rippled defines five distinct permission levels:
FORBID < GUEST < USER < IDENTIFIED < ADMINRole Definitions
FORBID
Blacklisted client
Blocked due to abuse
GUEST
Unauthenticated public access
Public API endpoints, read-only queries
USER
Authenticated client
Standard API operations, account queries
IDENTIFIED
Trusted gateway or service
Transaction submission, privileged reads
ADMIN
Full administrative access
Node management, dangerous operations
Source Location: src/xrpld/core/Config.h
Role Determination
Roles are assigned based on the client's IP address and connection type:
IP-Based Assignment
Configuration
File: rippled.cfg
Assigning Roles to Handlers
When registering a handler, specify the minimum required role:
Example Registrations
Permission Enforcement
The RPC dispatcher automatically enforces role requirements before invoking handlers:
Automatic Check
Manual Check (Inside Handler)
For fine-grained control:
Resource Management
Rippled tracks API usage to prevent denial-of-service attacks:
Resource Charging
Resource Limits
Unlimited Resources
Admin connections have unlimited resources:
IP Whitelisting and Blacklisting
Whitelisting Admin IPs
Blacklisting Abusive Clients
Rippled uses a "Gossip" mechanism to share blacklisted IPs across the network:
Secure Gateway Mode
For production deployments, use secure gateway configuration:
Architecture
Configuration
Benefits:
Rippled only accepts connections from the proxy
Proxy handles TLS termination
Proxy performs initial authentication
Reduces attack surface
Password Authentication (WebSocket)
WebSocket connections support optional password authentication:
Configuration
Client Authentication
Example: Multi-Level Permission Handler
Let's build a handler with different behavior based on role:
Registration:
Behavior:
GUEST: Gets only account and balance
USER: Gets sequence and owner count
IDENTIFIED: Gets flags and previous transaction ID
ADMIN: Gets full administrative details
Best Practices
✅ DO
Always validate roles before sensitive operations
Use the minimum required role for each handler
Charge resources appropriately for expensive queries
Log security events for audit trails
Test with different roles during development
❌ DON'T
Don't hardcode IP addresses in handler code
Don't expose admin functions to lower roles
Don't skip resource charging for expensive operations
Don't leak sensitive information in error messages
Don't trust client-provided role information
Security Checklist
Before deploying a custom handler:
Conclusion
Rippled's authentication and authorization system provides robust protection for the RPC interface through a well-designed role hierarchy. By combining IP-based role assignment, automatic permission enforcement in the dispatcher, resource charging for expensive operations, and fine-grained access control, the system prevents unauthorized access while enabling legitimate use cases. Understanding these security patterns is essential for building handlers that are both functional and secure, and for deploying nodes that safely expose APIs to different client types.
Last updated

