🚀 November 12th Live Webinar: Debunking Serverless Misconceptions
Register here
Fauna logo
Product
Solutions
Pricing
Resources
Company
Log InContact usStart for free
Fauna logo
Pricing
Customers
Log InContact usStart for free
© 0 Fauna, Inc. All Rights Reserved.

Related posts

Announcing General Availability of Fauna SchemaFauna adds support for Change Data CaptureIntroducing Fauna's Datadog Integration: Seamless Observability for Your Database

Start for free

Sign up and claim your forever-free Fauna account
Sign up and get started

Table of Contents

security guide

Guide to Database Security Strategies, Policies, and Postures

Jun 28th, 2024|

Categories:

AuthorizationAuthenticationFeaturesSecurity
Database security is a critical component of modern application development and deployment. As data breaches become more sophisticated, securing your databases effectively is essential. Traditional security measures often focus on the application layer, but this approach can leave databases vulnerable to attacks once an intruder bypasses the application layer. Circumventing application layer security is a common tactic used by malicious actors to gain unauthorized access to sensitive data. Therefore, it is imperative to secure data at the source — the database itself. Relying solely on usernames and passwords is no longer sufficient; robust database security requires a layered approach that includes contextual and dynamic measures to adapt to evolving threats and ensure comprehensive protection.
This guide explores the intricacies of database security, including strategies, policies, and postures, and introduces Fauna’s advanced security capabilities. By offering multi-layered and interlocking security to secure data at the database level, Fauna ensures that your sensitive information is protected even if the application layer is compromised. This comprehensive approach to security provides robust protection against unauthorized access and data breaches, safeguarding your data from the ground up.

Understanding Database Security

What is Database Security?

Database security refers to the measures taken to protect databases from unauthorized access, misuse, and threats. It encompasses a variety of controls, such as access controls, encryption, and isolation, designed to safeguard the integrity, confidentiality, and availability of the database.

Components of Database Security

  1. Authentication: Verifying the identity of users accessing the database. This includes implementing strong, multi-factor authentication methods to ensure only authorized individuals can access the database, such as biometric verification, OTP (One-Time Passwords), or hardware tokens. When applications interface with the database, other mechanisms must be implemented. These can include the use of API keys, service accounts, and token-based authentication to securely verify and manage application access, ensuring robust protection against unauthorized access.
  2. Authorization: Defining and enforcing what authenticated users are allowed to do. Implementing Role-Based Access Control (RBAC) or Attribute-Based Access Control (ABAC) can restrict access based on user roles and attributes, ensuring users only have the permissions necessary for their role. While RBAC assigns permissions based on predefined roles, ABAC offers more granular and dynamic access control by evaluating attributes such as user identity, time of access, location, and specific actions being performed. This allows for a more flexible and context-aware security posture, dynamically adjusting permissions based on real-time conditions and reducing the risk of unauthorized access.
  3. Encryption: Protecting data at rest and in transit from unauthorized access. Using advanced encryption standards like AES-256 for data at rest and enforcing TLS 1.2+ (Transport Layer Security) for data in transit can prevent interception and tampering.
  4. Data Isolation: Ensuring that different users' or tenants' data are kept separate. Implementing strong data isolation techniques prevents data leakage and unauthorized access between users or tenants. This is especially important in multi-tenant environments where multiple customers' data coexist in the same database. By isolating data at the database level, each user's data remains secure and private, mitigating the risk of cross-tenant access and data breaches.
  5. Backup and Recovery: Ensuring data can be restored in case of loss or corruption. Scheduling regular backups and testing recovery processes frequently helps ensure data integrity and availability in case of a disaster or attack.

Importance of Database Security

Database security is crucial because:
  • Protects Sensitive Information: Prevents unauthorized access to personal, financial, and proprietary data.
  • Ensures Compliance: Meets regulatory requirements such as GDPR, HIPAA, and PCI DSS.
  • Maintains Trust: Ensures the integrity and availability of data, which is critical for business operations and customer trust.
  • Prevents Data Breaches: Reduces the risk of costly and damaging security incidents.

Common Causes of Database Security Breaches

  1. Weak Authentication: Use of default, weak, or compromised credentials. Attackers often exploit weak passwords or default credentials to gain access to databases. This includes using common passwords or not changing default passwords provided by the database software.
  2. Inadequate & Fixed Access Controls: Over-permissioned accounts and limited role-based access control. When users have more privileges than necessary, it increases the risk of accidental or malicious actions. With legacy RBAC policies that are coarse-grained and non-real time, it is challenging to enforce the principle of least privilege.
  3. Unpatched Vulnerabilities: Exploitation of known software flaws due to lack of timely updates. Cyber attackers frequently exploit known vulnerabilities in database software that have not been patched promptly. Keeping software up-to-date is essential for security.
  4. SQL Injection: Attackers injecting malicious SQL code through input fields. SQL injection attacks occur when an attacker can execute arbitrary SQL code on the database by manipulating input fields in web applications, often leading to unauthorized data access or manipulation.
  5. Insufficient Encryption: Data transmitted or stored without encryption. Data that is not encrypted is vulnerable to interception and unauthorized access, especially during transmission over public networks or when stored on compromised systems.
  6. Misconfiguration: Poorly configured database settings and services. Misconfigurations such as open database ports, excessive permissions, and unsecured backups can expose the database to attacks.
  7. Insider Threats: Malicious or negligent actions by employees or partners. Insiders with access to the database can intentionally or accidentally cause data breaches. This includes actions like data theft, accidental deletions, or unintentional security lapses.

Tips for Hardening Database Security

Strategies

  1. Zero Trust Architecture: Assume no one inside the network can be trusted by default, and verify every request. Segment your network, enforce strict identity verification, and continuously monitor user activities.
  2. Principle of Least Privilege: Ensuring that users and systems have only the minimum level of access necessary to perform their functions. By restricting permissions and access rights to the bare minimum, the potential attack surface is significantly reduced. This practice helps in minimizing the risk of internal threats and accidental data exposure.
  3. Secure Data at its Source: Focusing on securing the database itself, rather than relying solely on application layer defenses. By implementing robust security measures directly within the database, such as encryption, access controls, and activity monitoring, the data remains protected even if other layers are compromised. This approach ensures that sensitive information is safeguarded against unauthorized access, manipulation, or breaches.

Policies

  1. Strong Authentication Policies: Implement multi-factor authentication (MFA) and enforce strong password policies. Require MFA for all database access and set strict password rules (e.g., minimum length, complexity).
  2. Role-Based Access Control (RBAC): Assign permissions based on roles rather than individual users. Define roles with specific privileges and assign users to these roles based on their job functions.
  3. Attribute-Based Access Control (ABAC): Use dynamic attributes (user, data, environment) to control access. Implement ABAC policies that evaluate attributes in real time to grant or deny access.
  4. Regular Patching and Updates: Keep all database software and dependencies up-to-date. Automate the patching process and schedule regular maintenance windows.
  5. Encryption Policies: Encrypt sensitive data both at rest and in transit. Use strong encryption standards (e.g., AES-256) and enforce TLS for all data communications.
  6. Data Isolation: Ensuring that different users or tenants' data are kept separate within the database. Implementing robust data isolation techniques prevents data leakage and unauthorized access between users or tenants, which is crucial in multi-tenant environments where multiple customers' data coexist. By using methods such as row-level security, separate schemas, and partitioning, each user's data remains secure and private.

Postures

  1. Continuous Monitoring: Implement real-time monitoring and alerting for database activities. Use tools like intrusion detection systems (IDS) and database activity monitoring (DAM) solutions.
  2. Incident Response Plan: Develop and regularly update a plan for responding to security incidents. Define clear procedures for detection, containment, eradication, and recovery.
  3. Data Masking and Redaction: Hide sensitive data from unauthorized users. Use data masking techniques to obfuscate sensitive information in non-production environments.
  4. Backup and Disaster Recovery: Regularly backup data and test recovery procedures. Schedule frequent backups and conduct regular disaster recovery drills.
  5. User Education and Training: Educate employees on security best practices and phishing risks. Conduct regular training sessions and provide resources on recognizing security threats.

Fauna’s Advanced Security Capabilities

Fauna’s security architecture enables more fine-grained and dynamic approaches to managing access and permissions. This unlocks tailored security policies that can adapt to varying conditions and user contexts, ensuring robust protection while accommodating the diverse needs of modern applications. Fauna allows for the creation of security policies that evaluate multiple attributes such as user identity, time of access, and contextual conditions.
These policies ensure data is secured at the source by implementing robust encryption, access controls, and activity monitoring directly within the database. This approach minimizes the attack surface and provides a higher level of security compared to relying solely on application-layer defenses. Additionally, Fauna’s built-in security features, such as dynamic role assignment and scoped sessions, further enforce the principle of least privilege by ensuring users and applications have the minimum necessary access. This eliminates the need for extensive third-party solutions, reducing operational complexity and enhancing efficiency.

Capabilities Overview

  • Authentication: Fauna offers a modern, stateless, and token-based authentication system, as well as seamless integration with external identity providers like Auth0. This approach ensures secure, scalable, and efficient verification of user identities.
  • Authorization: Supports both static RBAC and dynamic ABAC for precise access control.
  • Data Encryption: Ensures data is encrypted both in transit (using TLS) and at rest.
  • Data Isolation: : Fauna ensures robust data isolation through its native parent-child database architecture and scoped sessions. This design allows for strict separation of data across different applications or tenants, enhancing security and privacy.
  • Virtual Private Fauna: Provides a customizable, single-tenant environment for enhanced security and compliance. This solution unlocks multi-cloud environments and allows for customizable geo-distribution, giving customers greater control over data residency and performance. By isolating resources, VPF ensures that data remains private and compliant with stringent regulatory requirements, while also offering flexibility in deployment and scalability across different cloud providers.

Authentication and Authorization

Every transaction in Fauna is independently secured using secrets that serve as bearer tokens, scoped to specific databases or account contexts. Fauna supports anonymous access, identity-based access, and integration with external identity providers, offering a robust and flexible authentication system. Meanwhile, Fauna offers both ABAC and RBAC depending on use case, providing versatile options for managing access control.
  • ABAC: Dynamically assigns roles to JWTs and tokens based on user attributes, enabling real-time, data-driven access control.
  • RBAC: Grants static privileges based on predefined roles, ensuring consistent access policies.
Traditional database RBAC is a more static form of authorization with predefined policies dictating who gets to do what, and Fauna supports this. However, Fauna also supports ABAC. With ABAC, FQL (Fauna Query Language) can be used to determine if someone or something has authorization for a resource in real-time. For example, using ABAC, access permissions can be dynamically derived at query time based on multiple data attributes in the database, such as the time of day, specific data in a collection, or other criteria. These conditions can be mixed. A policy could be created to grant read and write permissions, but not delete, on a collection, only if the current time falls within the user's work schedule stored in their profile document. As soon as it hits 5 pm, that person loses all access to data in the database.
For even more control, data access can be restricted to server-side functions (User Defined Functions in Fauna). For example, consider a simple function that reads from a collection named 'Product'. A user could be given permission to call this server-side function and nothing else. This means the user cannot call any collection directly but can call this function to perform the specific actions defined within it. In this case, it allows access to very specific data from the Product collection, with no permissions to create, read, update, or delete documents directly. In the first line of the function, the function is instructed to operate under a different role named “readInventory,” which has a very narrow set of permissions to read this collection. So even though the user only has permission to call this function, the function itself operates under different permissions.
@role(readInventory)
function inventory(name){
 Product.byName(name) {
  name,
  description,
  quantity
 }
}
This pattern ensures very tight control, narrowing down what can be done in the database. The operation is not open-ended, preventing bad actors or users from injecting unauthorized operations. They can only perform the actions explicitly allowed by the function.

Data Security in Transit and at Rest

Fauna uses TLS 1.2+ for secure data transmission and encrypts data at rest using AES-256, ensuring robust protection against unauthorized access.

Private Endpoints and Multi-Tenancy

Fauna’s private endpoints enable secure VPC peering, while its multi-tenancy capabilities ensure strict data isolation between tenants, preventing cross-tenant data access.

Data Isolation

Fauna ensures robust data isolation through its native database multi-tenancy and scoped sessions. Parent-child databases allow for hierarchical organization and strict separation of data, enabling multi-tenancy and secure, isolated environments for different applications or customers. Scoped sessions further enhance isolation by restricting access to specific databases or collections based on the user's permissions. This architecture ensures that each user's data remains secure and private, preventing unauthorized access and data leakage across different tenants or applications. This approach also enables rapid, programmatic database creation and simplifies the development and deployment of multi-tenant applications – with Fauna, developers can write application code as if interacting with a single database. This minimizes the need for extensive manual intervention and infrastructure management.

Backup and Recovery

Fauna’s backup and restore system ensures data can be recovered in case of compromise or accidental loss, such as when new code deployment unintentionally deletes data. With configurable snapshot frequencies and retention periods, Fauna provides optimal security and data recovery options.

Conclusion

Securing your databases is essential to protect sensitive information, maintain compliance, and ensure operational integrity. Implementing robust security architectures, policies, and postures can significantly reduce the risk of breaches and enhance your overall security posture. Fauna offers advanced security features that simplify and strengthen your database security efforts. By implementing the principle of least privilege through fine-grained access controls like dynamic ABAC, Fauna ensures that users and systems have only the minimum level of access necessary, reducing potential attack surfaces.
Build secure applications with confidence leveraging Fauna’s enterprise security and compliance solutions.

If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, and serverless databases, Fauna is hiring

Share this post

‹︁ PreviousNext ›︁

Subscribe to Fauna's newsletter

Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.