
Google Chrome extensions can introduce risk by running unapproved or unknown code within your organization. This blog shows how to block Chrome extension installation using Carbon Black App Control (formerly CB Protection), both through the GUI and with a Python + SQL automation method.
Malware force-installs Chrome extensions on 300,000 browsers, patches DLLs
Malicious extensions in the Chrome Web Store
๐ What We’re Blocking
Chrome extensions are installed into this folder:
C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default\Extensions\
Each subfolder in there is an extension identified by its unique ID. To block extensions, we target creation inside that directory.
โ Method 1: Use Carbon Black App Control Console (GUI)
- Log into the App Control Console.
- Navigate to:
Rules > File Creation Control > Add File Creation Rule - Fill in the fields:
- Name:
Block Chrome Extensions - Path or File Name: sqlCopyEdit
*\AppData\Local\Google\Chrome\User Data\Default\Extensions\* - Rule Type:
File and Directory - Action:
Block - Include Subdirectories: โ Checked
- Policy Scope: Choose the policy (e.g., “High Enforcement”)
- Message (optional):
"Chrome extension installation is blocked by security policy."
- Name:
- Click Save.
๐ง Method 2: Automate Rule Insertion with Python + SQL
๐ง Step 1: Create the Config File
Create a file named cb_config.ini in the same directory as your script:
iniCopyEdit[database]
server = YOUR_SQL_SERVER_HOSTNAME
database = das
policy_scope = YourPolicyNameOrID
๐ Step 2: Python Script to Insert Rule
pythonCopyEditimport pyodbc
import configparser
import getpass
# Load config from file
config = configparser.ConfigParser()
config.read('cb_config.ini')
server = config['database']['server']
database = config['database']['database']
policy_scope = config['database']['policy_scope']
# Prompt for SQL credentials
username = input("Enter your SQL Server username: ")
password = getpass.getpass("Enter your SQL Server password: ")
conn_str = (
f'DRIVER={{ODBC Driver 17 for SQL Server}};'
f'SERVER={server};DATABASE={database};UID={username};PWD={password}'
)
try:
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()
sql = """
INSERT INTO file_creation_rules (
name,
path_pattern,
rule_type,
action,
include_subdirectories,
user_scope,
policy_scope,
message,
enabled
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
values = (
'Block Chrome Extensions',
'*\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\*',
'Both',
'Block',
1,
'All',
policy_scope,
'Chrome extension installation is blocked by security policy.',
1
)
cursor.execute(sql, values)
conn.commit()
print("โ
File creation rule inserted successfully.")
except Exception as e:
print(f"โ Error: {e}")
finally:
if 'conn' in locals():
conn.close()
๐ก This script uses
pyodbcfor database connection. Install it with:
pip install pyodbc
๐งช Optional: PowerShell Audit Script
Before implementing the block, you can audit existing Chrome extensions with this PowerShell script:
powershellCopyEdit$basePath = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Extensions"
if (Test-Path $basePath) {
Write-Host "Chrome extension directory found at: $basePath"
$extensions = Get-ChildItem -Path $basePath -Directory
if ($extensions.Count -eq 0) {
Write-Host "No Chrome extensions currently installed."
} else {
Write-Host "Installed Chrome extensions:"
foreach ($ext in $extensions) {
Write-Host "- $($ext.Name)"
}
}
} else {
Write-Host "Chrome extension directory not found."
}