T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/osm_ai_bridge.py:143- Finding
Overprivileged Access to Existing Browser Sessions and Sensitive Storage
- Content
View full analysis
Vulnerability Details
File Location:
scripts/osm_ai_bridge.py, lines 143–181
Vulnerability Type: Unrestricted browser-context attachment and sensitive session storage access
Risk Level: HighVulnerable Code
python async def _access_storage(self): """Access cookies and LocalStorage.""" if not self.page: return {} try: cookies = await self.context.cookies() local_storage = await self.page.evaluate('() => { const items = {}; for (let i = 0; i < localStorage.length; i++) { const key = localStorage.key(i); items[key] = localStorage.getItem(key); } return items; }') logger.info(f"Accessed {len(cookies)} cookies and {len(local_storage)} LocalStorage entries") return { 'cookies': cookies, 'localStorage': local_storage } except Exception as e: logger.warning(f"Storage access failed: {e}") return {} async def start(self): from playwright.async_api import async_playwright self.playwright = await async_playwright().start() if not await self._check_cdp_available(): await self._start_browser_with_debugging() self.browser = await self.playwright.chromium.connect_over_cdp(self.CDP_URL) contexts = self.browser.contexts if contexts: self.context = contexts[0] else: self.context = await self.browser.new_context() await self._inject_anti_detection() pages = self.context.pages if pages: self.page = pages[0] else: self.page = await self.context.new_page() await self._access_storage()The displayed comments and log messages are English translations of the original source text; executable statements and control flow are unchanged.
Technical Analysis
The bridge con ...[truncated 2737 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
_access_storage()unless a narrowly defined feature genuinely requires specific storage values. - Do not call
context.cookies()across an existing user context. If a cookie is required, restrict retrieval to an explicit, validated target URL. - Launch and use a dedicated browser profile owned by the Skill instead of attaching to the user's general-purpose browser profile.
- Create or locate a dedicated page by an exact allowlisted origin rather than selecting
pages[0]. - Validate
self.page.urlbefore reading storage or interacting with the DOM. Permit only expected HTTPS origins such as the explicitly supported AI service. - Reject unexpected CDP endpoints and avoid exposing CDP on non-loopback interfaces.
- Prefer a private Playwright-managed browser connection or pipe-based transport over a generally accessible debugging port.
- Apply the same context and page-origin protections to
scripts/osm_ai_discuss.py. - If storage access must remain, keep values in memory for the shortest possible period, never log them, and document the exact data and purpose.
- Remove
