Skip to content

[Backend][Caching][P2] Ensure Cache Keys Always Include Tenant Isolation #238

Description

@AnshRaj112

Backlog ID: ISSUE-KMP-095 | Epic: EPIC-03 | Complexity: Medium

Description

ISSUE-KMP-095 is a High severity / P2 priority Security issue in @kampyn-backend, under Caching / Multi-Tenancy.

Problem overview

This work item asks the team to: Ensure Cache Keys Always Include Tenant Isolation.

Today the system behaves as follows: Tenant Map OK if keyed by tenant; other caches Needs review.

That is incorrect or insufficient for a production multi-tenant platform. After this issue is fixed, the expected outcome is: All shared caches include tenantId in key; tests for cross-tenant pollution.

Why this issue exists

Cross-tenant cache pollution.

If this remains unresolved, realistic consequences include: Tenant A receives Tenant B cached data.

This finding is grounded in the technical audit: Audit Caching isolation; Multi-tenant gaps.

Implementation scope

Concrete touchpoints are listed later in this issue (2 file path(s) and 1 API/function touchpoint(s)). Use those lists during implementation and code review so nothing in scope is missed.

Recommended direction (outcome-focused, not a mandatory design): Key prefix convention tenantId:...

Planning

  • Estimated complexity: Medium
  • Priority rationale: High impact if Redis introduced without key discipline.
  • Depends on:
    • ISSUE-KMP-007
    • ISSUE-KMP-025

Do not treat this issue as independently shippable until listed dependencies are addressed or explicitly waived.

Definition of done

Close this issue only when every Acceptance Criteria checkbox is complete and the Testing Requirements have been run (or waived with written rationale on the PR). The title states the change; this description, the expected behavior, and the acceptance criteria together define success.

Current Behavior

Tenant Map OK if keyed by tenant; other caches Needs review.

Expected Behavior

All shared caches include tenantId in key; tests for cross-tenant pollution.

Why This Matters

Cross-tenant cache pollution.

Evidence From Audit

Audit Caching isolation; Multi-tenant gaps.

Risk / Impact

Tenant A receives Tenant B cached data.

Recommended Direction

Key prefix convention tenantId:...

Acceptance Criteria

  • Cache helper requires tenantId
  • Test proves no cross-tenant cache hit

Testing Requirements

  • Integration test
  • Security test

Dependencies

  • ISSUE-KMP-007
  • ISSUE-KMP-025

Affected Files

  • kampyn-backend/utils/tenantCache.js
  • kampyn-backend/middleware/tenantMiddleware.js

Affected Functions / APIs

  • Cached tenant config and any future caches

Created from KAMPYN_GITHUB_ISSUES.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions