CVE-2022-23653: CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition in Backblaze B2_Command_Line_Tool
B2 Command Line Tool is the official command line tool for the backblaze cloud storage service. Linux and Mac releases of the B2 command-line tool version 3.2.0 and below contain a key disclosure vulnerability that, in certain conditions, can be exploited by local attackers through a time-of-check-time-of-use (TOCTOU) race condition. The command line tool saves API keys (and bucket name-to-id mapping) in a local database file (`$XDG_CONFIG_HOME/b2/account_info`, `~/.b2_account_info` or a user-defined path) when `b2 authorize-account` is first run. This happens regardless of whether a valid key is provided or not. When first created, the file is world readable and is (typically a few milliseconds) later altered to be private to the user. If the directory is readable by a local attacker and the user did not yet run `b2 authorize-account` then during the brief period between file creation and permission modification, a local attacker can race to open the file and maintain a handle to it. This allows the local attacker to read the contents after the file after the sensitive information has been saved to it. Users that have not yet run `b2 authorize-account` should upgrade to B2 Command-Line Tool v3.2.1 before running it. Users that have run `b2 authorize-account` are safe if at the time of the file creation no other local users had read access to the local configuration file. Users that have run `b2 authorize-account` where the designated path could be opened by another local user should upgrade to B2 Command-Line Tool v3.2.1 and remove the database and regenerate all application keys. Note that `b2 clear-account` does not remove the database file and it should not be used to ensure that all open handles to the file are invalidated. If B2 Command-Line Tool cannot be upgraded to v3.2.1 due to a dependency conflict, a binary release can be used instead. Alternatively a new version could be installed within a virtualenv, or the permissions can be changed to prevent local users from opening the database file.
AI Analysis
Technical Summary
CVE-2022-23653 is a time-of-check to time-of-use (TOCTOU) race condition vulnerability affecting the Backblaze B2 Command Line Tool versions 3.2.0 and below on Linux and Mac platforms. The B2 Command Line Tool is used to interact with Backblaze's cloud storage service, storing API keys and bucket name-to-ID mappings locally in a database file (commonly located at $XDG_CONFIG_HOME/b2/account_info, ~/.b2_account_info, or a user-defined path). When the command 'b2 authorize-account' is first executed, this database file is created and initially set with world-readable permissions before being quickly changed to private user-only permissions. This brief window, typically a few milliseconds, creates a race condition where a local attacker with read access to the directory can open and maintain a handle to the file before permissions are restricted. Consequently, the attacker can read sensitive API keys and configuration data once the file is populated with these secrets. The vulnerability requires local access and the ability to read the directory containing the configuration file before the user runs 'b2 authorize-account'. Users who have already authorized their account and whose configuration file was not accessible by other local users at creation time are not vulnerable. However, if the file was accessible, the attacker could have obtained credentials. The vulnerability does not require user interaction beyond the victim running the authorize command and does not require network access. There are no known exploits in the wild. Mitigation involves upgrading to version 3.2.1 or later, which fixes the race condition by properly setting file permissions atomically or immediately upon file creation. If upgrading is not possible, users can use a binary release, install the tool in a virtual environment, or manually restrict directory and file permissions to prevent unauthorized local access. Additionally, users who suspect compromise should delete the local database file and regenerate all API keys, as the 'b2 clear-account' command does not remove the database file or invalidate open file handles. This vulnerability is categorized under CWE-367 (TOCTOU race condition) and primarily impacts confidentiality due to potential unauthorized disclosure of API keys.
Potential Impact
For European organizations using the Backblaze B2 Command Line Tool on Linux or Mac systems, this vulnerability poses a risk of local privilege escalation in the form of credential disclosure. If an attacker gains local access—such as through shared workstations, compromised user accounts, or insider threats—they could exploit the race condition to extract API keys, enabling unauthorized access to cloud storage buckets. This could lead to data exfiltration, data tampering, or disruption of cloud storage services. The impact is particularly significant for organizations relying on Backblaze B2 for critical backups, archival storage, or data sharing, as compromised keys could undermine data confidentiality and integrity. Since the vulnerability requires local access and directory read permissions, environments with multi-user access or lax file permission policies are most at risk. The vulnerability does not directly impact availability but could indirectly cause service disruption if attackers delete or modify stored data. Given the increasing adoption of cloud storage solutions in European enterprises, especially in sectors like finance, healthcare, and government, the risk of sensitive data exposure is notable. However, the lack of known exploits and the requirement for local access somewhat limit the threat scope. Organizations with strict endpoint security and user access controls will be less vulnerable, but those with shared systems or insufficient permission management should prioritize remediation.
Mitigation Recommendations
1. Upgrade the B2 Command Line Tool to version 3.2.1 or later immediately to eliminate the race condition vulnerability. 2. If upgrading is not feasible due to dependency conflicts, deploy the official binary release or install the tool within a Python virtual environment to isolate and control permissions. 3. Restrict directory and file permissions where the configuration database is stored to prevent other local users from reading or opening the file during creation. This includes setting the directory permissions to disallow read or execute access by unauthorized users. 4. After upgrading, delete the existing local database file (e.g., ~/.b2_account_info) to invalidate any potentially compromised handles and regenerate all API keys via the Backblaze management console to prevent unauthorized access. 5. Avoid using 'b2 clear-account' as it does not remove the database file or invalidate open file handles. 6. Implement endpoint security measures to limit local user access and monitor for suspicious file access patterns. 7. Educate users about the importance of running 'b2 authorize-account' only in secure environments and ensuring that local directories are not accessible by unauthorized users. 8. Regularly audit file system permissions on user home directories and configuration paths to ensure compliance with least privilege principles.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Finland, Denmark, Ireland, Belgium, Austria
CVE-2022-23653: CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition in Backblaze B2_Command_Line_Tool
Description
B2 Command Line Tool is the official command line tool for the backblaze cloud storage service. Linux and Mac releases of the B2 command-line tool version 3.2.0 and below contain a key disclosure vulnerability that, in certain conditions, can be exploited by local attackers through a time-of-check-time-of-use (TOCTOU) race condition. The command line tool saves API keys (and bucket name-to-id mapping) in a local database file (`$XDG_CONFIG_HOME/b2/account_info`, `~/.b2_account_info` or a user-defined path) when `b2 authorize-account` is first run. This happens regardless of whether a valid key is provided or not. When first created, the file is world readable and is (typically a few milliseconds) later altered to be private to the user. If the directory is readable by a local attacker and the user did not yet run `b2 authorize-account` then during the brief period between file creation and permission modification, a local attacker can race to open the file and maintain a handle to it. This allows the local attacker to read the contents after the file after the sensitive information has been saved to it. Users that have not yet run `b2 authorize-account` should upgrade to B2 Command-Line Tool v3.2.1 before running it. Users that have run `b2 authorize-account` are safe if at the time of the file creation no other local users had read access to the local configuration file. Users that have run `b2 authorize-account` where the designated path could be opened by another local user should upgrade to B2 Command-Line Tool v3.2.1 and remove the database and regenerate all application keys. Note that `b2 clear-account` does not remove the database file and it should not be used to ensure that all open handles to the file are invalidated. If B2 Command-Line Tool cannot be upgraded to v3.2.1 due to a dependency conflict, a binary release can be used instead. Alternatively a new version could be installed within a virtualenv, or the permissions can be changed to prevent local users from opening the database file.
AI-Powered Analysis
Technical Analysis
CVE-2022-23653 is a time-of-check to time-of-use (TOCTOU) race condition vulnerability affecting the Backblaze B2 Command Line Tool versions 3.2.0 and below on Linux and Mac platforms. The B2 Command Line Tool is used to interact with Backblaze's cloud storage service, storing API keys and bucket name-to-ID mappings locally in a database file (commonly located at $XDG_CONFIG_HOME/b2/account_info, ~/.b2_account_info, or a user-defined path). When the command 'b2 authorize-account' is first executed, this database file is created and initially set with world-readable permissions before being quickly changed to private user-only permissions. This brief window, typically a few milliseconds, creates a race condition where a local attacker with read access to the directory can open and maintain a handle to the file before permissions are restricted. Consequently, the attacker can read sensitive API keys and configuration data once the file is populated with these secrets. The vulnerability requires local access and the ability to read the directory containing the configuration file before the user runs 'b2 authorize-account'. Users who have already authorized their account and whose configuration file was not accessible by other local users at creation time are not vulnerable. However, if the file was accessible, the attacker could have obtained credentials. The vulnerability does not require user interaction beyond the victim running the authorize command and does not require network access. There are no known exploits in the wild. Mitigation involves upgrading to version 3.2.1 or later, which fixes the race condition by properly setting file permissions atomically or immediately upon file creation. If upgrading is not possible, users can use a binary release, install the tool in a virtual environment, or manually restrict directory and file permissions to prevent unauthorized local access. Additionally, users who suspect compromise should delete the local database file and regenerate all API keys, as the 'b2 clear-account' command does not remove the database file or invalidate open file handles. This vulnerability is categorized under CWE-367 (TOCTOU race condition) and primarily impacts confidentiality due to potential unauthorized disclosure of API keys.
Potential Impact
For European organizations using the Backblaze B2 Command Line Tool on Linux or Mac systems, this vulnerability poses a risk of local privilege escalation in the form of credential disclosure. If an attacker gains local access—such as through shared workstations, compromised user accounts, or insider threats—they could exploit the race condition to extract API keys, enabling unauthorized access to cloud storage buckets. This could lead to data exfiltration, data tampering, or disruption of cloud storage services. The impact is particularly significant for organizations relying on Backblaze B2 for critical backups, archival storage, or data sharing, as compromised keys could undermine data confidentiality and integrity. Since the vulnerability requires local access and directory read permissions, environments with multi-user access or lax file permission policies are most at risk. The vulnerability does not directly impact availability but could indirectly cause service disruption if attackers delete or modify stored data. Given the increasing adoption of cloud storage solutions in European enterprises, especially in sectors like finance, healthcare, and government, the risk of sensitive data exposure is notable. However, the lack of known exploits and the requirement for local access somewhat limit the threat scope. Organizations with strict endpoint security and user access controls will be less vulnerable, but those with shared systems or insufficient permission management should prioritize remediation.
Mitigation Recommendations
1. Upgrade the B2 Command Line Tool to version 3.2.1 or later immediately to eliminate the race condition vulnerability. 2. If upgrading is not feasible due to dependency conflicts, deploy the official binary release or install the tool within a Python virtual environment to isolate and control permissions. 3. Restrict directory and file permissions where the configuration database is stored to prevent other local users from reading or opening the file during creation. This includes setting the directory permissions to disallow read or execute access by unauthorized users. 4. After upgrading, delete the existing local database file (e.g., ~/.b2_account_info) to invalidate any potentially compromised handles and regenerate all API keys via the Backblaze management console to prevent unauthorized access. 5. Avoid using 'b2 clear-account' as it does not remove the database file or invalidate open file handles. 6. Implement endpoint security measures to limit local user access and monitor for suspicious file access patterns. 7. Educate users about the importance of running 'b2 authorize-account' only in secure environments and ensuring that local directories are not accessible by unauthorized users. 8. Regularly audit file system permissions on user home directories and configuration paths to ensure compliance with least privilege principles.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-01-19T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9842c4522896dcbf260e
Added to database: 5/21/2025, 9:09:22 AM
Last enriched: 6/23/2025, 3:48:47 PM
Last updated: 8/13/2025, 11:05:20 AM
Views: 13
Related Threats
CVE-2025-53948: CWE-415 Double Free in Santesoft Sante PACS Server
HighCVE-2025-52584: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-46269: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-54862: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumCVE-2025-54759: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.