|
| 1 | +# Security-Relevant API Updates |
| 2 | + |
| 3 | +This document highlights the security-relevant additions to the Chrome DevTools Protocol implementation in this update. |
| 4 | + |
| 5 | +## Summary |
| 6 | + |
| 7 | +This update brings the python-chrome-devtools-protocol library to the latest CDP specification, adding **8 new domains** and significantly expanding security-relevant APIs, particularly in the Privacy Sandbox area. |
| 8 | + |
| 9 | +## New Security-Focused Domains |
| 10 | + |
| 11 | +### 1. Extensions Domain |
| 12 | +**Purpose**: Browser extension management for security testing |
| 13 | +- Load and uninstall extensions programmatically |
| 14 | +- Manage extension storage (local/sync/managed) |
| 15 | +- **Use Case**: Test extension security boundaries, data isolation, and permission handling |
| 16 | + |
| 17 | +### 2. FedCm Domain (Federated Credential Management) |
| 18 | +**Purpose**: Test federated authentication flows |
| 19 | +- Track and interact with FedCm dialogs |
| 20 | +- Programmatically select accounts or dismiss dialogs |
| 21 | +- **Use Case**: Verify federated login security, test account selection flows |
| 22 | + |
| 23 | +### 3. DeviceAccess Domain |
| 24 | +**Purpose**: Handle device permission prompts |
| 25 | +- Track camera, microphone, and other device access requests |
| 26 | +- Programmatically grant or deny permissions |
| 27 | +- **Use Case**: Test device permission security, verify proper permission prompts |
| 28 | + |
| 29 | +### 4. FileSystem Domain |
| 30 | +**Purpose**: File system directory access |
| 31 | +- Get directory access for testing File System Access API |
| 32 | +- **Use Case**: Test file system permission boundaries |
| 33 | + |
| 34 | +### 5. Autofill, BluetoothEmulation, PWA, Preload Domains |
| 35 | +Additional domains for comprehensive browser testing |
| 36 | + |
| 37 | +## Major Security Updates to Existing Domains |
| 38 | + |
| 39 | +### Storage Domain - Privacy Sandbox APIs |
| 40 | +The Storage domain received the most significant security-relevant updates: |
| 41 | + |
| 42 | +#### Attribution Reporting API (Privacy-Preserving Ad Measurement) |
| 43 | +```python |
| 44 | +# Enable tracking and local testing |
| 45 | +await conn.execute(storage.set_attribution_reporting_tracking(enable=True)) |
| 46 | +await conn.execute(storage.set_attribution_reporting_local_testing_mode(enabled=True)) |
| 47 | + |
| 48 | +# Send test reports |
| 49 | +await conn.execute(storage.send_pending_attribution_reports()) |
| 50 | + |
| 51 | +# Listen for events |
| 52 | +async for event in conn.listen(): |
| 53 | + if isinstance(event, storage.AttributionReportingSourceRegistered): |
| 54 | + print(f"Source registered: {event.registration}") |
| 55 | +``` |
| 56 | + |
| 57 | +#### Shared Storage API (Cross-Site Storage with Privacy) |
| 58 | +```python |
| 59 | +# Track shared storage access |
| 60 | +await conn.execute(storage.set_shared_storage_tracking(enable=True)) |
| 61 | + |
| 62 | +# Get and set entries for testing |
| 63 | +metadata = await conn.execute(storage.get_shared_storage_metadata( |
| 64 | + owner_origin="https://example.com" |
| 65 | +)) |
| 66 | + |
| 67 | +await conn.execute(storage.set_shared_storage_entry( |
| 68 | + owner_origin="https://example.com", |
| 69 | + key="test-key", |
| 70 | + value="test-value" |
| 71 | +)) |
| 72 | +``` |
| 73 | + |
| 74 | +#### Interest Groups / FLEDGE / Protected Audience API |
| 75 | +```python |
| 76 | +# Track interest group auctions |
| 77 | +await conn.execute(storage.set_interest_group_tracking(enable=True)) |
| 78 | +await conn.execute(storage.set_interest_group_auction_tracking(enable=True)) |
| 79 | + |
| 80 | +# Get details for security verification |
| 81 | +details = await conn.execute(storage.get_interest_group_details( |
| 82 | + owner_origin="https://example.com", |
| 83 | + name="interest-group-name" |
| 84 | +)) |
| 85 | + |
| 86 | +# Configure k-anonymity for testing |
| 87 | +await conn.execute(storage.set_protected_audience_k_anonymity(threshold=50)) |
| 88 | +``` |
| 89 | + |
| 90 | +#### Bounce Tracking Mitigation |
| 91 | +```python |
| 92 | +# Test bounce tracking mitigation |
| 93 | +deleted_sites = await conn.execute(storage.run_bounce_tracking_mitigations()) |
| 94 | +print(f"Mitigated tracking for {len(deleted_sites)} sites") |
| 95 | +``` |
| 96 | + |
| 97 | +### Network Domain - Cookie and IP Protection |
| 98 | +```python |
| 99 | +# Control cookie behavior for third-party cookie testing |
| 100 | +await conn.execute(network.set_cookie_controls(mode='block-third-party')) |
| 101 | + |
| 102 | +# Test IP protection features |
| 103 | +status = await conn.execute(network.get_ip_protection_proxy_status()) |
| 104 | +await conn.execute(network.set_ip_protection_proxy_bypass_enabled(enabled=True)) |
| 105 | + |
| 106 | +# Get related website sets (First-Party Sets) |
| 107 | +sets = await conn.execute(storage.get_related_website_sets()) |
| 108 | +``` |
| 109 | + |
| 110 | +### Audits Domain - Form Security |
| 111 | +```python |
| 112 | +# Automated form security/privacy issue detection |
| 113 | +issues = await conn.execute(audits.check_forms_issues()) |
| 114 | +for issue in issues: |
| 115 | + print(f"Form issue detected: {issue}") |
| 116 | +``` |
| 117 | + |
| 118 | +### Browser Domain - Privacy Sandbox Configuration |
| 119 | +```python |
| 120 | +# Override Privacy Sandbox enrollment for testing |
| 121 | +await conn.execute(browser.add_privacy_sandbox_enrollment_override( |
| 122 | + url="https://example.com" |
| 123 | +)) |
| 124 | + |
| 125 | +# Configure coordinator keys |
| 126 | +await conn.execute(browser.add_privacy_sandbox_coordinator_key_config( |
| 127 | + coordinator_origin="https://coordinator.example.com", |
| 128 | + coordinator_key="test-key" |
| 129 | +)) |
| 130 | +``` |
| 131 | + |
| 132 | +## Security Testing Use Cases |
| 133 | + |
| 134 | +### 1. Privacy Sandbox Testing |
| 135 | +Test the complete Privacy Sandbox suite: |
| 136 | +- Attribution Reporting (privacy-preserving conversion measurement) |
| 137 | +- Shared Storage (cross-site storage with privacy guarantees) |
| 138 | +- Interest Groups/FLEDGE (privacy-preserving ad auctions) |
| 139 | +- Topics API (via interest groups) |
| 140 | +- k-anonymity thresholds |
| 141 | + |
| 142 | +### 2. Third-Party Cookie Migration |
| 143 | +Test alternatives to third-party cookies: |
| 144 | +- First-Party Sets (Related Website Sets) |
| 145 | +- Partitioned cookies (CHIPS) |
| 146 | +- Storage Access API |
| 147 | +- Cookie controls and policies |
| 148 | + |
| 149 | +### 3. Authentication Security |
| 150 | +- Test FedCm federated login flows |
| 151 | +- Verify account selection security |
| 152 | +- Test dialog dismissal handling |
| 153 | + |
| 154 | +### 4. Permission Testing |
| 155 | +- Verify device permission prompts (camera, mic, etc.) |
| 156 | +- Test permission grant/deny flows |
| 157 | +- Validate permission persistence |
| 158 | + |
| 159 | +### 5. Extension Security |
| 160 | +- Test extension isolation boundaries |
| 161 | +- Verify extension data access controls |
| 162 | +- Test extension installation/uninstallation |
| 163 | + |
| 164 | +### 6. Anti-Tracking Features |
| 165 | +- Test bounce tracking mitigation |
| 166 | +- Verify IP protection |
| 167 | +- Test tracking prevention measures |
| 168 | + |
| 169 | +### 7. Form Security Auditing |
| 170 | +- Automated detection of insecure forms |
| 171 | +- Privacy leak detection |
| 172 | +- Input validation issues |
| 173 | + |
| 174 | +## Breaking Changes |
| 175 | + |
| 176 | +**Database Domain Removed**: The deprecated Database domain has been removed from the CDP specification. If your code imports `cdp.database`, you must migrate to: |
| 177 | +- IndexedDB APIs (`cdp.indexed_db`) |
| 178 | +- Storage APIs (`cdp.storage`) |
| 179 | +- Cache Storage APIs (`cdp.cache_storage`) |
| 180 | + |
| 181 | +## Implementation Notes |
| 182 | + |
| 183 | +### Generator Improvements |
| 184 | +- Fixed same-domain type reference bug (e.g., `Network.TimeSinceEpoch` now correctly resolves to `TimeSinceEpoch` within the network module) |
| 185 | +- Added domain context to all type, command, and event generation |
| 186 | +- Protected manually-written files (connection.py, util.py) from deletion |
| 187 | + |
| 188 | +### Testing |
| 189 | +- All 19 tests passing |
| 190 | +- mypy type checking successful (56 modules) |
| 191 | +- Generator tests updated and passing (20 tests) |
| 192 | + |
| 193 | +## Migration Guide |
| 194 | + |
| 195 | +### For Users of cdp.database |
| 196 | +```python |
| 197 | +# Old (no longer works) |
| 198 | +from cdp import database |
| 199 | +await conn.execute(database.some_command()) |
| 200 | + |
| 201 | +# New - Use IndexedDB instead |
| 202 | +from cdp import indexed_db |
| 203 | +await conn.execute(indexed_db.request_database_names(security_origin="https://example.com")) |
| 204 | +``` |
| 205 | + |
| 206 | +### For page.navigate() Users |
| 207 | +```python |
| 208 | +# Old return signature (3 values) |
| 209 | +frame_id, loader_id, error_text = await conn.execute(page.navigate(url="...")) |
| 210 | + |
| 211 | +# New return signature (4 values - added isDownload) |
| 212 | +frame_id, loader_id, error_text, is_download = await conn.execute(page.navigate(url="...")) |
| 213 | +``` |
| 214 | + |
| 215 | +## References |
| 216 | + |
| 217 | +- [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) |
| 218 | +- [Privacy Sandbox APIs](https://privacysandbox.com/) |
| 219 | +- [Attribution Reporting API](https://github.com/WICG/attribution-reporting-api) |
| 220 | +- [Shared Storage API](https://github.com/WICG/shared-storage) |
| 221 | +- [FLEDGE/Protected Audience](https://github.com/WICG/turtledove) |
| 222 | +- [FedCM](https://fedidcg.github.io/FedCM/) |
| 223 | + |
| 224 | +## Examples |
| 225 | + |
| 226 | +See `/tmp/security_examples.py` for comprehensive code examples demonstrating all new security APIs. |
| 227 | + |
| 228 | +## Version Information |
| 229 | + |
| 230 | +- Protocol Version: 1.3 (latest) |
| 231 | +- Total Domains: 56 (up from 48) |
| 232 | +- New Domains: 8 |
| 233 | +- Removed Domains: 1 (Database) |
| 234 | +- Security-Relevant Updates: 5 domains (Storage, Network, Audits, Browser, Target) |
0 commit comments