Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add security foundations section #487

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions docs/security/definitions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
sidebar_position: 2
---

# Definitions
coroiu marked this conversation as resolved.
Show resolved Hide resolved

<dl>
<dt>Vault data</dt>
<dd>
The collection of a userโ€™s sensitive and private information that they choose to store
securely within Bitwarden's secure environment. This data typically includes:

- **Passwords**: Credentials for various websites, applications, and services.
- **Usernames**: Associated usernames for accounts.
- **Secure Notes**: Encrypted notes containing sensitive information that the user wants to keep
secure.
- **Credit Card Information**: Payment card details like card number, expiration date, CVV, etc.
- **Identities**: Personal information such as names, addresses, phone numbers, and email addresses
that can be used to autofill forms.
- **Attachments**: Any files uploaded by the user to be stored securely within the vault.

</dd>
<dt>User</dt>
<dd>The owner of the vault data.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Does a User include an organization?

  2. Who is the owner of vault data? For example - organizations often consider themselves the "owner" of data stored in an individual user's vault if it's a business account. But we generally mean "the User or Organization linked to the cipher in the database". This will increase as we give organizations more control over individual accounts (e.g. password reset, delete).

Copy link
Contributor Author

@coroiu coroiu Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweaked this a little bit to avoid the question of ownership

<dt>Protected data</dt>
<dd>
Data stored in a format that is unreadable without additional information. Usually synonymous to
encrypted, but with additional expectations about how the key is stored. Encrypted data which is
stored together with its decryption key in plain text is not considered to be protected, even
thought it is encrypted.
</dd>
<dt>Communication channel</dt>
<dd>
A medium through which two or more entities, such as processes,
applications, or systems, exchange data or messages. This can include communication between
components on the same machine, such as inter-process communication (IPC), or over a network, such
as between a client and a server. Common types of communication channels include sockets, APIs,
message queues, shared memory, and HTTP connections.
</dd>
<dt>Secure channel</dt>
<dd>
A communication channel that provides confidentiality and integrity for the data transmitted
between two or more parties.

- **Confidentiality**: The data is unreadable to unauthorized
parties, typically using encryption.
- **Integrity**: The data cannot be altered or tampered with
without detection during transmission.

</dd>
<dt>Trusted channel</dt>
<dd>
A secure channel that also provides authenticity.

- **Authenticity**: The identities of the
communicating parties are verified, ensuring that data is exchanged only between the intended
parties.

</dd>
<dt>Partially trusted channel</dt>
<dd>
A communication channel where trust is asymmetrical, meaning only some of the parties trust the
channel. One party may have verified the other(s) and thus trusts the channel, while the other
party or parties may not have done so, making the channel trusted by one party but untrusted by
the other(s).
</dd>
<dt>Fully trusted Channel</dt>
<dd>
A communication channel where all parties have verified each otherโ€™s identities. This means the
channel provides confidentiality, integrity, and authenticity, ensuring that the data is secure,
unaltered, and exchanged only between the trusted parties.
</dd>
<dt>Data at rest</dt>
<dd>
Any data that is stored on a device or medium that is not actively being used, processed, or
transmitted. This includes (but is not limited to) data stored on disk on the users devices, or on
disk on the server side.
</dd>
<dt>Data in use</dt>
<dd>
Any data that is actively being used, processed or accessed. This includes (but is not limited to) data that is
temporarily held in volatile memory (like RAM) for quick access, computation, or rendering.
</dd>
<dt>Data in transit</dt>
<dd>
Data that is actively being transferred from one location to another, such as between memory locations, processes,
or between devices across a network.
</dd>
<dt>Data sharing</dt>
<dd>
The controlled process in which data leaves the Bitwarden secure environment unprotected. As a consequence the
guarantees made by this document will no longer apply. The receiving party may or may not have its own guarantees.
</dd>
<dt>Data leaking</dt>
<dd>
The process in which data unintentionally leaves the Bitwarden secure environment unprotected.
</dd>
<dt>Informed and explicit consent</dt>
<dd>
The process by which the User is provided with all relevant information regarding an action, understands it, and
agrees to the terms in a clear and unmistakable way.

- **Informed**: The person giving consent must have all necessary information to understand what they are agreeing to.
All or parts of the information may be assumed to be implicitly provided/understood by the context in which the user
is giving consent. This includes:
- **Purpose**: A clear explanation of what the consent is for, such as how their data will be used or what actions will be taken.
- **Risks and Benefits**: Disclosure of any potential risks, benefits, or consequences associated with their consent.
- **Alternatives**: Information about any alternatives to consenting and what happens if they choose not to consent.
- **Rights**: A description of their rights, such as the right to withdraw consent at any time without penalty.
- **Explicit consent**: Consent must be given clearly and unambiguously, typically through a direct and affirmative action,
such as clicking "I agree" or a similar action.

</dd>
<dt>Certify</dt>
<dd>Officially recognize (someone or something) as possessing certain qualifications or meeting certain standards.</dd>
<dt>Bitwarden secure environment</dt>
<dd>Any process or application that adheres to the "Security" section is treated as "within the Bitwarden secure environment".</dd>
</dl>
46 changes: 46 additions & 0 deletions docs/security/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
sidebar_position: 1
---

# Security

The Security section of this documentation outlines the foundational approach Bitwarden takes to
ensure the safety and integrity of user data. It provides a structured framework for understanding
Bitwarden's security philosophy, the principles it adheres to, and the specific requirements it
implements to meet its commitments.

## Conventions

### Key words

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in this section are to be interpreted as described in
[RFC2119](https://datatracker.ietf.org/doc/html/rfc2119).

### References

Principles in this documentation are labeled with unique identifiers (e.g., P01, P02, etc.) for easy
reference throughout the document and in related discussions. When referencing a principle, simply
use its identifier (e.g. P01).

Requirements in this documentation use a shorthand format (e.g. XX.N.y) to indicate their specific
location and context (e.g. VD.3.b).

## Structure of the security section

1. **Definitions** This part establishes the foundational terminology used throughout the document.
By clearly defining key conceptsโ€”such as what constitutes "vault data"โ€”it ensures that the rest
of the document is precise and unambiguous.
2. **Principles** The principles describe the overarching philosophies and commitments that guide
Bitwarden's approach to security. These principles are not actionable rules but rather serve as
the justifications for the requirements that follow. They define what Bitwarden aims to achieve
in its security posture and why certain decisions are made.
3. **Requirements** Building on the principles, the requirements are concrete, actionable steps that
Bitwarden is required to implement. These requirements ensure that the principles are upheld in
practice and provide a measurable way to assess Bitwarden's security efforts.

This structure is meant to avoid unnecessary repetition and establish a logical flow from high-level
philosophies to specific actions. It ensures that every requirement is tied to a well-defined
principle, making it clear why it exists and what it is meant to achieve. The document is designed
for both internal stakeholders and external users who seek to understand the company's security
model.
13 changes: 13 additions & 0 deletions docs/security/principles/01-locked-vault-is-secure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# P01 - A locked vault is secure

Clients must ensure that once the vault has been locked, no vault data can be accessed in plain
eliykat marked this conversation as resolved.
Show resolved Hide resolved
text, even if the device becomes compromised after the lock occurs. Protections are not guaranteed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about vault data that is intentionally stored in plain text? e.g. modification dates, folder guids, boolean values. Or is this excluded by the definition of "vault data"? (is metadata "sensitive and private information"?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is actually still an open thread in confluence about this because I was hoping to get Vault involved in classifying data a bit better. My idea is to split up the vault data into groups of varying sensitivity. In that case we might get:

  • High: Password
  • Moderate: Username
  • Low: Creation date

And then say something like "low sensitivity data" may be stored unprotected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would work!

Copy link
Contributor Author

@coroiu coroiu Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweak this a little bit by only grouping the data into highly sensitive and less sensitive (see 528330f) to avoid getting into hard discussions. What do you think?

if the device is compromised before the vault is locked.
coroiu marked this conversation as resolved.
Show resolved Hide resolved

## Key storage mechanisms must provide adequate protection

Mechanisms used for storing encryption keys when the vault is locked, such as PINs or auto-login,
must provide an appropriate level of security. If encryption keys are stored in less secure
environments (e.g. in the OS's keyring), the associated risks must be carefully considered and
mitigated to ensure that unauthorized access to the vault remains limited, even when convenience
features are used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# P02 - Limited security for vaults on semi-compromised devices

:::info Note

This principle applies only to unlocked vaults. Refer to [P01](./locked-vault-is-secure) for details
on protections for locked vaults.

:::

A semi-compromised device is one where malware exists in User Space but has not breached Kernel or
OS-level protections. On such devices, clients must leverage available protections to prevent
malware from accessing plaintext vault data while the vault is unlocked.

- **Technical controls** (e.g., data compartmentalization or HSMs): Clients should maximize the use
of Kernel/OS-level protections or other available system mechanisms to safeguard vault data.
- **Administrative controls** (e.g., biometrics, 2FA, approval flows): Clients should balance
security and usability, avoiding excessive complexity in the user flow.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# P03 - No security on fully compromised systems
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point-of-interest: this was previously called No guarantees for unlocked vaults on fully compromised devices. I changed it to make it more consistent with the other principles, but "no security" might seems a bit harsh

Copy link
Contributor

@quexten quexten Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the confluence point; I think we might need to add "no security guarantees on fully compromised bitwarden contexts"


:::info Note

This principle applies only to unlocked vaults. Refer to [P01](./locked-vault-is-secure) for details
on protections for locked vaults.

:::

:::info Note

Bitwarden does not currently support Trusted Execution Environments (TEEs). While TEEs could
potentially provide a secure processing space for vault data on compromised devices, their use is
limited by the environments in which Bitwarden operates. For this reason, TEEs are not considered
when defining what constitutes a fully compromised device.

:::

When hardware or OS-level integrity is fully compromised, vault data may become accessible to
attackers. While Bitwarden continuously strives to provide robust protections, certain threats fall
beyond the reach of software-based security measures.
7 changes: 7 additions & 0 deletions docs/security/principles/04-controlled-access.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# P04 - Controlled access to vault data

Clients must ensure that vault data, whether at rest or in use, is accessible only to authorized
parties and always under the user's explicit control. Even when unlocked, access to vault data must
be carefully restricted to specific contexts, such as autofill or explicit user actions. Isolation
mechanisms must be employed, particularly in environments prone to unauthorized accessโ€”such as
browsersโ€”to prevent exposure to third parties without the user's consent.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# P05 - Minimized impact of security breaches

Even with robust security measures in place, user error or unforeseen vulnerabilities can lead to
various security breaches, including the compromise of encryption keys or data leaks. Bitwarden
should take available actions to help users limit the damage caused by such breaches, both in scope
and duration. This involves:

- Detecting and invalidating compromised device sessions.
- Rotating encryption keys to reduce the risk of โ€œharvest now, decrypt laterโ€ attacks (forward
secrecy).
- Ensuring that any data added after a breach remains secure, maintaining post-compromise security.
2 changes: 2 additions & 0 deletions docs/security/principles/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: "Principles"
position: 3
120 changes: 120 additions & 0 deletions docs/security/requirements.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
sidebar_position: 4
---

# Requirements

The requirements in this section are organized hierarchically, with top-level requirements defining
the core rules and obligations that must be met, serving as broad objectives for Bitwarden's
security model. Sub-requirements expand on these by addressing specific scenarios, exceptions, or
clarifications, and may override their parent requirement when explicitly stated. Sibling
requirements at the same level must remain independent and free of contradictions.
Comment on lines +7 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Might be nice to align this to an industry standard like ISO/IEC/IEEE 29148, but there's only so much we can do in a markdown document


## Vault data (VD)

:::warning Draft - Early version

This section is still in its early stages and does not yet reflect current or future standards.

:::

1. Vault data **MUST** be protected _at rest_.

- a. The Client **MUST** encrypt vault data stored on disk.
- b. The Client **MUST** use the UserKey to encrypt vault data stored on the Server.
coroiu marked this conversation as resolved.
Show resolved Hide resolved
- c. The Client **SHOULD** ensure that no mechanisms exists such that vault data may be stored to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

Suggested change
- c. The Client **SHOULD** ensure that no mechanisms exists such that vault data may be stored to
- c. The Client **SHOULD** ensure that no mechanisms exist such that vault data may be stored to

disk unencrypted without user consent. This includes cases where it is not the Client itself
that stores the data to disk.
- d. The Client **MUST** encrypt any vault data derivatives that can be used to re-create the
original form or are considered to be vault data on their own.
- e. The Client **MUST NOT** store any artifacts (e.g. encryption keys) on disk such that the
encrypted vault data can be decrypted without any additional information provided by the User.
- i. The Client **MAY** store such artifacts if given an _informed and explicit consent_ by the
User.
- f. The Client **MUST NOT** store any artifacts (e.g. encryption keys) such that the vault data
can be decrypted by the Server, regardless of consent.

2. Vault data **MAY** be unprotected while _in use_.

- a. The Client **MAY** decrypt all vault data during vault unlock.
- i. The Client **SHOULD** minimize the quantity of decrypted vault data.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: we could make this more stringent

Suggested change
- i. The Client **SHOULD** minimize the quantity of decrypted vault data.
- i. The Client **SHOULD** limit decrypted data to the records actively in use by the user.

- b. The Client **MAY** leave vault data encrypted after unlock.
- c. The Client **MUST** ensure that unprotected data does not linger when no longer _in use_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we mean by linger? This is all very precise but "linger" is quite vague.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I think is not present in memory is what I'm looking for here, but that makes this requirement hard to implement. Maybe we should change it to a SHOULD at the same time

Suggested change
- c. The Client **MUST** ensure that unprotected data does not linger when no longer _in use_.
- c. The Client **SHOULD** ensure that unprotected data is not present in memory when no longer _in use_.

I still think this requirement will have a pretty large impact if adopted since it tends to discourage our huge caches, but having no caches is the current approach in the SDK so hopefully we won't have to prioritize any additional work just for this

Copy link
Member

@eliykat eliykat Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this; being more specific with the requirement while loosening the language a little (MUST -> SHOULD) seems like a good balance.


3. Vault data **SHOULD** be protected while _in transit_.

- 1. The Client **MAY** use unprotected transmissions to the display/monitor.
- 2. The Client **SHOULD** use a trusted channel when the transmission crosses process
boundaries.
- 3. The Client **MUST** use a trusted channel if there is a risk that the data can be
eavesdropped by unintended parties.
- 4. The Client **MUST** certify that the receiver is within the Bitwarden secure environment.
- 5. The Client **MUST** use a trusted channel when the transmission crosses device boundaries.

4. Vault data **MUST NOT** be shared without an _informed and explicit consent_ by the User.

- 1. The Client **MAY** trust the OS to gather consent.
- 2. The Client **MAY** augment the OS when the consent process is not sufficiently clear or
explicit.
- 3. The Client **SHOULD** guarantee that the third party is the receiver.

## Encryption keys (EK)

:::warning Draft - Early version

This section is still in its early stages and does not yet reflect current or future standards.

:::

1. The UserKey **MUST** have 256 bits of security.
2. The UserKey **MUST** be protected _at rest_.
3. The UserKey **MAY** be unprotected while _in use_.
4. The UserKey **MUST** be protected while _in transit_.
5. The UserKey **MUST NOT** be shared.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about account recovery and emergency access?

Suggested change
5. The UserKey **MUST NOT** be shared.
5. The UserKey **MUST NOT** be shared without _informed and explicit consent_ by the User.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're actually the second person to give me this exact comment so there is definitely room for improvement here. Account recovery and emergency access is not "sharing" according to the definition:

Data sharing
The controlled process in which data leaves the Bitwarden secure environment unprotected. As a consequence the guarantees made by this document will no longer apply. The receiving party may or may not have its own guarantees.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Given that "sharing" has a common use, maybe there is a more specific term that can be used here? (Maybe "export" - or would that be confused with a vault export?)

Alternatively, it's only used a couple of times - maybe you remove the definition and be explicit each time: "The UserKey MUST NOT leave the Bitwarden secure environment in an unprotected state."


As a separate question - does this document have anything to say about when data is exchanged/accessed between users then? EA and Account Recovery are within the Bitwarden secure environment, but it has security implications.

Copy link
Contributor Author

@coroiu coroiu Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both very good suggestions. I think we might need the definition just to make the document easier to read, but you are right that it might be mixed up with vault export. Still think its worth it though, I'll update it when I get a chance!

does this document have anything to say about when data is exchanged/accessed between users then? EA and Account Recovery are within the Bitwarden secure environment, but it has security implications.

Not yet. I think we should redefine this to be "Sharing" and then start writing some principles and requirements on it


## Authentication tokens (AT)

:::warning Draft - Early version

This section is still in its early stages and does not yet reflect current or future standards.

:::

1. The authentication tokens MUST be protected at rest if the client provides a mechanism for secure
Copy link
Member

@trmartin4 trmartin4 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. The authentication tokens MUST be protected at rest if the client provides a mechanism for secure
1. The authentication tokens **MUST** be protected at rest if the client provides a mechanism for secure

Suggestion to maintain consistency of font weight.

storage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. The authentication tokens **SHOULD** be protected in transit.

## Secure channels (SC)

:::info Reviewed - Awaiting implementation

This section has been reviewed and is awaiting implementation.

:::

1. A secure channel **MUST NOT** transmit unprotected data.
- a. Metadata related to the communication protocol **MAY** be transmitted unprotected.
- b. Metadata related to the communication protocol **MUST** be authenticated.
2. A secure channel **MUST** protect against unauthorized modifications of the data.
3. A secure channel **MUST** protect against replay of messages.
4. A secure channel **MAY** detect loss of data (e.g. dropped messages).
5. A long-lived secure channel **MUST** protect against the decryption of previously transmitted
data in the event of a future key compromise.
- a. High-traffic channels **MAY** expose a greater amount of data during key compromise to
maintain an acceptable user experience.
6. A long-lived secure channel **MUST** recover from key compromise to restore full confidentiality.
- a. High-traffic channels **MAY** experience a longer recovery period to maintain an acceptable
user experience.

## Trusted channels (TC)

:::warning Draft - Early version

This section is still in its early stages and does not yet reflect current or future standards.

:::

1. A trusted channel **MUST** also be a secure channel.
2. A trusted channel **MUST** guarantee the receiver(s), including unintended ones.
- a. The OS **MAY** be trusted to provide this guarantee.
- b. The User **MAY** be trusted to provide this guarantee (e.g. using fingerprints)
3. A trusted channel **MAY** be partially trusted.
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ async function createConfig() {
label: "Architecture",
sidebarId: "architecture",
},
{
type: "docSidebar",
position: "left",
label: "Security",
sidebarId: "security",
},
{
type: "custom-dev",
position: "right",
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const sidebars = {
getting_started: ["index", { type: "autogenerated", dirName: "getting-started" }],
contributing: [{ type: "autogenerated", dirName: "contributing" }],
architecture: [{ type: "autogenerated", dirName: "architecture" }],
security: [{ type: "autogenerated", dirName: "security" }],
};

module.exports = sidebars;