T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/cache.js:72- Finding
Global Semantic Cache Permits Cross-User Data Disclosure and Cache Poisoning
- Content
View full analysis
0) { await redis.expire(key, CACHE_TTL); } console.log(`Cached: "${query.substring(0, 60)}..." -> ${key}`); return key; } ``` ```js async function lookup(query) { const redis = await getRedis(); await ensureIndex(); const vector = await embed(query); const startTime = Date.now(); const results = await redis.ft.search(INDEX_NAME, `*=>[KNN 1 @embedding $BLOB AS score]`, { PARAMS: { BLOB: float32Buffer(vector) }, SORTBY: "score", LIMIT: { from: 0, size: 1 }, RETURN: ["query_text", "response_text", "score", "hit_count", "model", "created_at"], DIALECT: 2, }); const lookupMs = Date.now() - startTime; if (results.total === 0) { return { hit: false, lookupMs }; } const doc = results.documents[0]; const similarity = 1 - parseFloat(doc.value.score); if (similarity < SIMILARITY_THRESHOLD) { return { hit: false, lookupMs, closestSimilarity: similarity, closestQuery: doc.value.query_text, }; } // Increment hit count await redis.hIncrBy(doc.id, "hit_count", 1); return { hit: true, response: doc.value.response_text, similarity, originalQuery: doc.value.query_text, model: doc.value.mo ...[truncated 3017 chars]- Remediation
View remediation
::`. - Store the tenant identifier as a Redis TAG field. - Require a tenant filter in every vector query. 3. Enforce authorization before returning a cached response. The caller must be authorized to read the owner namespace of the selected entry. 4. Restrict cache writes to trusted code paths. Do not expose unrestricted `store` functionality to untrusted callers. 5. Separate caches for workflows with different confidentiality or trust levels. 6. Do not cache secrets, credentials, regulated data, or highly sensitive responses. Add configurable exclusion and redaction rules. 7. Consider encrypting sensitive cached values at rest with tenant-specific keys. 8. Record provenance, owner, model, policy version, and creation context for each entry. 9. Validate cached-response provenance and trust level before using it in downstream automation. 10. Add tests proving that one tenant cannot retrieve or influence another tenant's entries. ]]>
