T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- references/api-discovery.md:205
- Finding
- Broad Enumeration of Browser Cookies and Storage Credentials<![CDATA[ ## Vulnerability Details **File Location**: `references/api-discovery.md`, lines 205-220 **Vulnerability Type**: Excessive credential discovery **Risk Level**: Medium ### Vulnerable Code ```bash opencli browser eval "document.cookie.split('; ').reduce((o,x)=>{const[k,v]=x.split('=');o[k]=v;return o},{})" ``` ```bash opencli browser eval "Object.keys(localStorage).map(k=>k+' => '+localStorage.getItem(k).slice(0,50))" ``` ### Technical Analysis The discovery workflow enumerates every script-readable cookie and returns every local-storage key together with the first 50 characters of its value. It does not initially restrict access to known authentication keys such as a specific CSRF token or session-cookie name. This violates least-privilege principles because adapter discovery normally requires identifying and using only the credential associated with the selected endpoint. The output may include unrelated session identifiers, bearer tokens, personal preferences, tenant identifiers, or credentials belonging to other applications hosted under the same origin. Because these values are returned through `opencli browser eval`, they may also enter terminal output, agent context, conversation logs, or diagnostic records. ### Attack Path 1. A user opens an authenticated target site in the browser session. 2. The agent encounters an authenticated API and follows the token-discovery procedure. 3. The cookie command returns all non-HttpOnly cookies for the current document. 4. The storage command returns every local-storage key and a portion of every value. 5. Unrelated credentials become visible to the agent and may be retained in tool output or logs. 6. A malicious or compromised adapter-authoring process could reuse the exposed values outside the intended API request. ### Impact Assessment The exposed scope is limited to cookies accessible to page JavaScript and storage associated with the current origin. HttpOnly cookies are not exposed by the first ...[truncated 388 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Enumerate cookie and storage **names only** during initial discovery. 2. Retrieve a value only after the required credential name has been identified from a target request. 3. Add explicit allowlists for expected names such as `csrfToken` or a site-specific session token. 4. Mask values in tool output, showing only a short fingerprint where comparison is necessary. 5. Do not print bearer tokens, JWTs, session identifiers, or complete cookie objects. 6. Prefer using credentials inside the target page context without returning their values to the agent. 7. Add a warning that browser evaluation output may be logged or retained. 8. Clear diagnostic output and caches immediately if credential values are accidentally displayed. ]]>
