This article takes a long-form look at what privacy rules are. For more concise, technical documentation, see our core reference entry.
Reference: Privacy
Privacy rules are an essential part of your app's security. Any database data that's private or sensitive needs to be protected with privacy rules to be considered secure.
Stay on top of your app's privacy rules so your users can safely entrust their data to your app.
Privacy rules are conditions you set up on each data type to protect your data from being viewed and edited by unauthorized users.
What are privacy rules?
All the data you store in the database is hosted on a server. Privacy rules instruct that server to only send data to the browser, or write to the database, if certain conditions are met.
For example, you could allow your products to be viewable only by people who are logged in. Written out in plain terms, the rule would be:
Only return the data if the current user is logged in
The logic here is that you ask the server for information using a data source like Do a search for and an operator like Product's Name to show a product's name. If the privacy rule above is active, Bubble only returns the data if the query came from a logged-in user.
This is essential to app security because it's stopped on the server side. The data stays encrypted in the database instead of being sent to the browser, where it could be viewed.
As illustrated above, privacy rules make up a sort of firewall for your data. Every request to the database goes through a process of authentication and authorization¹ before it's completed or rejected.
Client-side data
Before exploring privacy rules further, it's important to understand that any data reaching your user's device is, by definition, no longer secure. As long as data has been downloaded to a user's device, even if it isn't displayed anywhere in your app, the person using that device can access it by looking at the data traffic being sent to and from the Bubble server.
This is a fairly technical subject. Suffice it to say that the only way data remains truly inaccessible is to make sure it isn't sent from the server in the first place, and privacy rules are how you do that.
It's also worth stressing that in most cases, you want data to reach the device. If it didn't, you wouldn't be able to work with data at all. The task is making sure only the intended information is sent, and no unauthorized data.
In an eCommerce store, you'd likely have data with different security requirements:
All products should be viewable by anyone. If not, no one can buy anything.
All shopping carts should be viewable only by the user who created them, to keep purchase history private.
Products are known as public data, and the shopping cart is private data.
What does server-side and client-side mean?
What does server-side and client-side mean?
Server-side means something happens on Bubble's servers, before any data is sent out. The user's device never sees the work being done, only the result the server decides to send.
Client-side means something happens on the user's own device, in their browser or app, after data has already arrived there. Because the data is already on their machine at that point, anything done client-side can't protect it.
This is why privacy rules run server-side: it's the only place where withholding data actually keeps it out of reach.
Article: Client-side and server-side
How privacy rules work
Bubble API: Using the Bubble API introduces some additional settings in the privacy rule tab. You can read more about those in the articles below.
Article: Data API privacy rules
Article: Workflow API privacy rules
Bubble has a privacy rule editor that lets you control the privacy settings for all your data types in one central place. You'll find it by going to the Data tab and clicking Privacy.
Privacy rules protect your data types in the following ways:
You can stop specific fields from being viewed
You can stop specific fields from being used as search constraints
You can stop the data type from being found with
Do a search forYou can stop users from viewing uploaded files
You can stop users from making changes with auto-binding
Caution: Privacy rules don't update automatically on a page if the rules affecting a user change while that user is on the page.
For example, if a user has a page open where they can see a thing, then clicks a button that changes which privacy rules apply to them so they can no longer see it, that new outcome won't be reflected on the page until it's refreshed.
Managing the security of private files requires configuring settings in both the privacy rules and the element responsible for uploading the file.
Article section: Files | Uploading private files
Privacy rules are built from two pieces of information:
The attributes of the database thing
The attributes of the current user
By combining these two, you can flexibly set up rules that determine who the user is and what they're trying to access. Here's another rule written out as a sentence:
Only return the data if the thing's Creator is the current user
This involves both the thing in question and the current user. If the current user and the creator of the thing are the same, Bubble returns the data. If they aren't, the data stays securely on the server.
Client-side filtering: Privacy rules are applied on the server. Once data reaches the client, those rules no longer apply, since the data is already on the user's device. Client-side operations like filtering, sorting, or counting work on data that's already been returned, and don't trigger additional privacy checks.
Article: Client-side and server-side
The privacy rule editor
The Privacy section is split into two panels. On the left is a list of every data type in your app, each showing its current status, either Privacy rules applied or Publicly visible. If you have a lot of data types, you can filter the list with the search box above it.
You'll find privacy rules in the Data tab and Privacy section.
Select a data type to see its rules on the right. A data type can have several rules, and each one can be given a name that describes who it covers, such as "User's own data." Click New rule to add another. Each rule can be collapsed while you work, and deleted or commented on using the icons in its header. If a data type has many rules or fields, the Search rules and fields box helps you find the one you're after.
Creating a new privacy rule
The genereal steps to create a new privacy rules are as follows. We'll cover more details and examples further down in the article:
Open the Privacy section
Go to the Data tab and click Privacy.
Select a data type
In the left panel, select the data type you want to protect. Its existing rules appear on the right.
Create a new rule
Click New rule and give it a name that describes who it covers, like "User's own data."
Set the condition
In the When field, build a dynamic expression that defines which users the rule applies to.
Set the record-level permissions
Choose whether users matching the rule can find this in searches and view files attached to this.
Set the field permissions
For each field, choose whether it can be viewed, used as a search constraint, and saved with auto-bind.
Privacy rule settings
Each privacy rule is made up of several settings, and the easiest way to understand them is to read them from left to right, like an English sentence.
The sentence above says:
When the current user is logged in, they can...
...find this thing in searches,
view files attached to this thing,
view the following fields,
constrain searches by the following fields,
use auto-bind on the following fields.
The settings and their labels are meant to be taken literally. View all fields means view all fields. It doesn't stop someone from making changes to the field in a workflow. Likewise, Find this in searches applies to Do a search for specifically, but the record can still be fetched in other ways.
We recommend playing around with the settings and viewing the results on a page, to learn how they affect what users can see and do.
Working with the field list
Each field on the data type gets its own row, with a checkbox for View, Constraint, and Auto-bind. Each row also shows the field's type, such as text, image, date, or a data type like Post, which helps when you're deciding how sensitive a field is.
A few things make the list easier to work with on data types that have many fields:
Each column header has its own checkbox, so you can grant or remove a permission across every field at once rather than one at a time.
The header also shows how many fields currently have that permission enabled, giving you a quick sense of how open the data type is.
You can sort the list by field name, or search within it using the Search rules and fields box.
Some fields show a dash instead of a checkbox in the Auto-bind column. These are fields that can't be auto-bound at all, such as built-in fields like Created Date and Modified Date.
A note on the slug field: Slug fields are designed to be public and searchable, so the Constraint permission can't be disabled on them. Slugs should never contain sensitive information.
Multi-level data references and searches
There's an important limitation to be aware of when conditions reference related data more than one level deep².
Privacy rules can evaluate fields that belong directly to the data type, but they can't traverse multiple layers of relationships to grant search access³. If a rule uses a chained reference, such as accessing a field on a related thing and then another field beyond that, Bubble can't use that rule to grant search access.
To avoid this limitation, structure your data so the fields required for privacy checks only need to reach one level in their expression.
In the example above, instead of checking the cart's creator's X, we check the current user, reducing the levels from two to one.
Privacy rules and workflows
Do privacy rules affect your app's workflows? The answer is yes and no.
View all fields doesn't stop you from using Make changes to a thing to update that field in a workflow. It can, however, stop you from correctly checking a condition, if the current user is unable to view the field the condition is based on.
Find this in searches doesn't stop you from making changes to a thing, but it can stop you from getting the search results you want in a workflow. If you use
Do a search forin a workflow, the search only returns data the current user has access to.Allow auto-binding stops a user from making changes through auto-bound elements, but it doesn't stop them from making those same changes in a workflow.
There are two important lessons here:
Think of a workflow as being run by the current user. The same restrictions apply to the workflow as anywhere else in your app.
To stop workflows from performing tasks you don't want them to, use conditional expressions in the Only when field on the workflow or on a specific action.
Overriding privacy rules in a workflow
Sometimes you'll need to override privacy rules when a user takes a specific action. For example:
User 1 doesn't have permission to search for any other users.
When User 1 runs a specific action, you need to search all other users to make a change.
In other words, you need to override the privacy rule that stops User 1 from searching for other users. You do this with an API workflow, checking Ignore privacy rules when running the workflow.
This lets you run workflows that perform an important task with full access to data, without compromising security by opening that access up to the current user. The operation runs purely server-side, so your users can't see it or even know it's running.
Search privacy modes
Search privacy modes control which fields a user can filter on when they search.
Why constraints need their own protection
When you set up a Do a search for, you can narrow the results using constraints. A constraint is a filter, such as Salary > 100,000 or Status is "approved".
A user can learn something about a field without ever viewing it. Imagine a Salary field protected by a privacy rule. The user can't see the number, but if they're allowed to search with the constraint Salary > 100,000, the records that come back tell them who earns more than that. The field's value never appears on screen, but it can be inferred from the records the search returns.
Search privacy modes are how you close that gap.
What does inference mean here?
What does inference mean here?
Inference is working out a piece of information indirectly, from clues, rather than seeing it stated outright.
In this context, someone never sees the protected field itself. Instead, they run search after search with different constraint values and watch which records come back each time. Each search narrows things down a little further, and over enough attempts, the hidden values can be reconstructed piece by piece.
The three modes
You set the search privacy mode in the Settings tab, in the General section. The setting applies to the application branch you're working in.
Mode | Explanation | Recommendation |
Off | Constraints aren't restricted. Any field on any data type can be used in a search constraint. | Not recommended for apps that perform searches on sensitive data. |
Automatic | A user can search using constraints already defined on your app's pages and workflows. If a constraint isn't defined anywhere in your app's pages or workflows, Bubble blocks it unless you've granted permission for that field. | Balances security and convenience, and existing apps won't break. If your app searches sensitive data, we recommend strict mode. |
Strict | Every constraint needs explicit permission. A field can only be used in a search constraint if its privacy rule allows it. | Recommended for apps performing searches on sensitive data. Gives you precise control. |
How automatic mode decides what to allow
Automatic mode protects your data without breaking the searches your app already relies on. To do that, it looks at where each search comes from.
When a search runs, Bubble checks whether the constraint and its operator match one defined on one of your app's pages or workflows. If it finds a match, it allows the constraint. If it doesn't, the constraint is only allowed when you've granted permission for that field.
Searches made through the Data API always need explicit permission. They run outside the context of your pages, so Bubble has no page-defined search to match them against.
Which mode should I choose?
As long as your app handles any kind of private data, we recommend strict mode. No field can be used as a search constraint unless you've explicitly allowed it, which removes the search inference risk across every field at once.
Strict mode takes a little more setup. You'll need to allow constraints on the fields your searches depend on, and we recommend using the search tool with the Uses constraint field operator to find where specific fields are used as constraints. The payoff is predictable search permissions: a field is constrainable only when you say so, with no behind-the-scenes matching.
Automatic mode is a strong default while you get there. It protects undefined constraints, including Data API searches, without breaking the searches already built into your pages.
Off mode gives no constraint protection, so we only recommend it for apps that hold no private data.
Allowing a field in constraints
This setting controls which fields a user can use as a search constraint.
Enabled: the field can be used as a search constraint.
Disabled: the field can't be used as a search constraint.
Allowing a constraint on a field users can't view can expose that field's values through search inference. The security dashboard flags this combination for sensitive fields, so you can confirm it's intentional.
Checklist: transitioning to strict mode
Checklist: transitioning to strict mode
Use this checklist to find and resolve any searches that may break when strict mode is enabled.
Find all fields where Constraint is unchecked. Go through each data type's privacy rules and note every field where Constraint is disabled.
Check each field with the app search tool. Use the Uses constraint field filter to find any expressions in your app that use the field as a constraint.
If the search returns no results, leave the field as is. No expressions depend on it, so the current setting is safe.
If the search returns results, choose one of the following:
Enable Constraint on the relevant privacy rule, if you want to keep the field constrainable for users matching that rule.
Refactor the affected expression to use a different field as the constraint.
Refactor your data schema so a less sensitive field can be used in place of the original constraint.
Privacy rule examples
Example 1: Shopping cart
Say you have a custom data type called Shopping Cart. It should only be found in searches and viewable by the person who created it. But if no one else can see the order, how do you deliver the product?
Someone else needs to be able to see it, but that access must be restricted. You can set up a custom field on each user called Admin (yes/no), which grants access to see anyone's cart. On the cart itself, you can use the existing, automatically populated Created by field.
The user should look like this:
We set up a simple yes/no field to separate admin users from regular users. Note that we have set the default value to no to make sure that new users are not an admin by default.
This setup requires three privacy rules:
Grant access to admins
The first rule gives access to search for and view fields on the cart if the current user's Admin field is set to yes.
Grant access to admins Grant access to the cart's creator
The second rule gives access to search for and view fields on the cart if the current user is the one who created it.
Close off everyone else
The third is the automatically generated Everyone else rule, which states that everyone else should have no access.
Pay especially close attention to the bottom rule. This is the one that determines what happens to everyone else. We've unchecked all its boxes here, making sure only admins and cart owners get access.
A good way to think about privacy rules is that they're additive. Every rule a user matches contributes its permissions, and those permissions stack up. The user ends up with the combined access of all matching rules, not the strictest one.
With privacy rules, you don't prohibit access, you grant it.
Following that logic, our two top rules are granting access to the cart if you're the cart's creator, or if you're an admin, as specified by the Admin yes/no field.
Example 2: Sharing tasks
This example looks at how properties on the data type itself can grant access under certain circumstances.
Imagine a task management app where access to tasks follows two simple rules:
The creator of a task has full access to their tasks.
The creator can invite other users into a specific task, granting them access.
You need some way to determine whether a user has been invited to a specific task. Keep in mind that you want to add that permission only to certain tasks, not all of them.
You can solve this by adding a custom field on the Task data type that holds a list of all users invited to it. The database structure can look like this:
Whenever you want to give someone access to a task, you add them to the list using a workflow:
Since the Invited users field is set to be a list, Bubble lets you use the add function to add that single user to the list of invited users. If you wanted to add several users at once, you'd use add list instead.
Setting up the privacy rule again takes three rules:
Grant access to the task's creator
The first rule states that if the current user is the creator of the task⁴, they should have access.
Grant access to invited users
The second states that if the current user is in the list of invited users, they should have access.
Close off everyone else
The third, the Everyone else rule, states that no one else should have access.
In the privacy rule editor, it looks like this:
Again, the two rules grant access under specific circumstances, while the bottom rule does not grant permission to everyone else.
Ending notes
Privacy rules are the most important safeguard you have for protecting your users' data, so it's worth getting to know them well and making a habit of setting data up securely from day one. Privacy rules act on the server side, which keeps data from being stolen, tampered with, or accidentally leaked, since the information never leaves the server.
Bubble offers a robust set of security features for you to take advantage of. As the developer, it's up to you to use them correctly to keep your users' private data private.
Other ways to learn
Video lessons
Video lessons
Books
Books
The Ultimate Guide to Bubble Security by Petter Amlie
Notes
Authentication is the process of determining who a user is.
Authorization is the process of determining what that user has access to.
In this context, a level refers to accessing a field on a related thing, and then accessing another field beyond that.
For example, in the expression
This Post's Creator's Admin is yes,Creatoris the first level of reference, andAdminis one level deeper thanCreator.The Find this in searches property, which applies to the
Do a search fordata source in your app.Created by is a built-in field that's automatically populated. It can't be changed.
If you want a dynamic owner, for example to transfer ownership from one user to another, you may want to set up an additional field you can manipulate directly.












