T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- index.js:136
- Finding
- Namespace Restrictions and Prefix Filtering Can Be Bypassed<![CDATA[ ## Vulnerability Details **File Location**: `index.js:18-21`, `index.js:136-146` **Vulnerability Type**: Missing access-control enforcement and ineffective prefix filtering **Risk Level**: High ### Complete Code Snippet ```javascript _expandCoordinate(shorthand) { if (shorthand.match(/^\d+\.\d+\.\d+\/\d+\.\d+\.\d+\/\d+\.\d+\.\d+$/)) { return shorthand; // Already full format } ``` ```javascript async list_memories(prefix) { const fullPrefix = this._expandCoordinate(prefix); const encoded = encodeURIComponent(fullPrefix); try { const response = await this._request('GET', `/api/v2/toc?p=${encodeURIComponent(this.phext)}`); const lines = response.split('\n').filter(l => l.trim()); return lines; } catch (err) { if (err.message.includes('404')) { return []; // No memories found } throw err; } } ``` ### Technical Analysis The coordinate expansion function accepts a fully numeric 11-dimensional coordinate without applying the configured namespace. Consequently, namespace restrictions are not enforced for coordinates matching that format. The `list_memories` function also calculates `fullPrefix` and `encoded`, but never includes either value in the request or filters the response locally. It instead retrieves and returns the complete table of contents for the configured `phext`. These behaviors conflict with the documented claim that namespaces isolate agents. A namespace is being used as a naming convention rather than as an enforced authorization boundary. The risk is especially significant when multiple agents or users share the same backend storage scope or explicitly configure the same `phext`. ### Attack Path 1. Multiple agents are configured to use the same SQ endpoint and storage `phext`. 2. An untrusted agent or user invokes `list_memories("user/")`. 3. The function ignores the requested prefix and requests the complete table of contents. 4. Coordinates belonging to other workflows or agents wi ...[truncated 957 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Treat the namespace as an enforced access-control boundary rather than a coordinate convention. 2. Reject full coordinates that do not belong to the configured namespace. 3. Avoid accepting unqualified numeric full coordinates unless explicitly required and authorized. 4. Include the prefix in the table-of-contents API request when the backend supports it. 5. Independently filter returned coordinates against a canonical namespace and prefix before returning them. 6. Use separate authenticated backend scopes or `phext` values for separate users or agents. 7. Enforce tenant authorization on the SQ server because client-side validation alone is not a sufficient security boundary. 8. Add tests proving that: - A prefix query cannot return unrelated coordinates. - A caller cannot recall, overwrite, or delete another namespace. - Malformed and fully qualified coordinates fail closed. ]]>
