Skip to content

Analytics lets a guest read issues on teams they are not a member of #317

Closed

Description

@imshashank

Found while triaging #178. This is a question about an intentional decision rather than a report of a mistake, so it needs a yes or no from a maintainer before anybody writes code.

What the code does

visibilityFilters in packages/core/src/work/issue-query.ts has two modes:

function visibilityFilters(principal: Principal, visibility: IssueVisibility): SQL[] {
  if (visibility === 'workspace-analytics') {
    assertCan(principal, 'analytics:read');
    return [];
  }
  assertCan(principal, 'issue:read');
  return visibleTeamFilters(principal);
}

workspace-analytics applies no team filter. The only caller is baseAnalyticsPredicate in packages/core/src/analytics/drilldown.ts, which every lens and the drilldown go through.

analytics:read is the first entry in GUEST_PERMISSIONS in packages/shared/src/policy/index.ts, so every role in the workspace holds it, guest included.

Why it is worth confirming

Three things make this larger than a scoping choice:

  1. It reverses the previous behaviour. The engine this replaced restricted a non-admin to their own teams. visibleTeamsClause in packages/core/src/analytics/distribution.ts still shows it: and i.team_id in (...) for a member, and and false for somebody on no teams. The planning cockpit in feat(analytics): add planning cockpit #309 moved the shipping path onto workspace-analytics, and the old clause is now only reachable from unused code.

  2. The drilldown returns rows, not just totals. listAnalyticsDrilldown selects issue.identifier, issue.title, priority, estimate, due date and state name. So this is not "a guest sees an aggregate that includes other teams", it is "a guest can enumerate the identifiers and titles of issues on a team they cannot open in the issue list". The same person gets nothing for those issues through the team visibility that the issue list uses.

  3. Scope the analytics dashboard to a team, project or sprint #178 asked for the opposite in writing. It specified a test that "a member of team A cannot request a scope of team B and get numbers back". The implementation is the reverse of that, so the divergence should be recorded on purpose rather than discovered later.

It is deliberate, and pinned by a test

packages/core/tests/work/issue-query.test.ts asserts it directly. A guest, contributor and member each on only the engineering team see both Engineering work and Operations work through workspace-analytics, and only Engineering work through team. So somebody chose this and wrote the test that keeps it that way. Nothing here is accidental, which is exactly why it needs a decision rather than a patch.

The options

  1. Confirm it and document it. Analytics is workspace-wide on purpose, because a dashboard that silently omits half the workspace is misleading. If so, say it in docs/concepts.md next to the roles, because a self hoster reading the role table will not expect a guest to be able to enumerate every issue in the workspace. Consider whether the drilldown should return counts without identifiers and titles for teams the reader cannot otherwise see.
  2. Restrict the drilldown only. Keep aggregates workspace-wide, since that is the argument for the current behaviour, and apply visibleTeamFilters to the row listing, which is where the disclosure actually happens.
  3. Restore team scoping and accept that a non-admin's dashboard covers their teams.
  4. Drop analytics:read from guest, which narrows the exposure without touching the scoping question. This is the smallest change and it does not answer the underlying question, so it is probably not enough on its own.

Option 2 looks like the best fit for the reasoning already in the codebase, but this is a product call.

Files

  • packages/core/src/work/issue-query.ts
  • packages/core/src/analytics/drilldown.ts
  • packages/shared/src/policy/index.ts
  • packages/core/tests/work/issue-query.test.ts
  • docs/concepts.md

Activity

  1. added
    security
    needs design
    p1 high
    area: policy
    area: analytics
    size: medium
    points: 3
    on Aug 15, 2026
  2. imshashank commented on Aug 19, 2026

    @imshashank
    ContributorAuthor

    Decision

    Option 2. Aggregates stay workspace-wide, the drilldown gets scoped.

    The argument for the current behaviour is about totals, and it is a good argument: a dashboard that silently omits half the workspace is worse than useless, because the reader has no way to know it is partial. That reasoning covers "Operations has 14 open issues". It does not cover handing back the identifiers and titles of those 14 issues, and nobody argued for that part. It came along with the query rather than being chosen.

    So:

    • Aggregate paths keep workspace-analytics as is. No team filter, every lens counts the whole workspace. No change.
    • listAnalyticsDrilldown applies visibleTeamFilters. The row listing is where the disclosure actually happens, and it is the only place a reader gets identifiers, titles, priorities and due dates for work they cannot open.

    The wrinkle worth designing for

    Once totals span the workspace but rows do not, the two disagree on purpose. A member clicks a bar reading 14 and gets 3 rows. That is correct, and it will read as a bug unless the UI says so.

    Whoever picks this up should decide how the drilldown communicates the gap. My preference is that it returns the visible rows plus a count of what was withheld, and the panel says something like "3 of 14 shown, the rest belong to teams you are not on". Silently returning a short list is the one outcome I do not want, because it makes the product look broken and teaches people not to trust the numbers.

    The existing test

    packages/core/tests/work/issue-query.test.ts currently asserts that a guest, contributor and member each see both Engineering work and Operations work through workspace-analytics. That assertion stays correct and should not be deleted, because it is describing the aggregate path, which is not changing.

    What needs adding is a sibling test at the drilldown level: the same readers get rows only for their own teams, and the withheld count reflects the rest. Both tests should exist side by side, since together they state the rule that this issue is deciding.

    On #178

    #178 asked for the opposite, a test that a member of team A cannot request team B and get numbers back. That is now explicitly declined for aggregates and honoured for rows. Recording it here so the divergence is deliberate rather than rediscovered.

    Documentation

    docs/concepts.md, next to the role table. A self hoster reading that table should be able to learn that analytics totals span the workspace for every role, and that issue level detail follows team membership. That is a surprising enough rule to be worth stating rather than leaving to be inferred.

    Not doing

    Dropping analytics:read from guest. With the drilldown scoped, a guest reading workspace totals is intended behaviour rather than a leak, and removing the permission would break the guest analytics view for no remaining benefit.

    Retitling and relabelling this as ready. #336 is unblocked once this lands.

  3. added
    ready
    help wanted
    and removed
    needs design
    on Aug 19, 2026
  4. imshashank commented on Aug 23, 2026

    @imshashank
    ContributorAuthor

    Status after current-head review of #346:

    The direct authorization exposure is addressed in the latest code: drilldown rows and overview outlier candidates are now constrained to visible teams, and the drilldown UI receives a withheld-row count.

    Keep this P1 open. #346 is still changes-requested because the CSV export drops the withholding distinction, three required web tests are red, overview outliers do not expose completeness metadata, the claimed outlier regression does not actually enter the outlier path, and the all-withheld UI state is misleading. The PR is labeled waiting-for-author and must get green CI, a completed CodeRabbit review, and human approval before this issue can close.

  5. ayam04 commented on Aug 27, 2026

    @ayam04
    Contributor

    Taking this one. Implementing the maintainer decision: aggregates stay workspace-wide, listAnalyticsDrilldown gets visibleTeamFilters, and the drilldown returns visible rows plus a withheld count so the panel can say '3 of 14 shown'. Will write the policy test first, then the query change.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: analyticsarea: policyhelp wantedp1 highpoints: 3readysecuritysize: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions