Skip to content

Protect experiment reporting with privileged auth and bounded inputs #21

Description

@llinsss

Problem

The README says every /api/v1/* route requires a bearer API key, but GET /api/v1/experiments/report and POST /api/v1/experiments/report/export have no authentication dependency. The report scans all student profiles, and the export endpoint also writes derived data to disk. Any network caller can currently trigger both operations.

This is a security boundary regression and creates an avoidable denial-of-service/storage-abuse path even when the returned metrics are aggregated.

Proposed change

  • Require authenticated, explicitly privileged access for both experiment routes (prefer an admin or dedicated researcher role rather than any parent/teacher account).
  • Centralize the dependency at a router/sub-router boundary so future experiment endpoints inherit the policy by default.
  • Validate retention_days with a bounded FastAPI Query (for example 1–365) on both routes.
  • Make exports non-publicly triggerable and return only a safe artifact identifier, never a host filesystem path.
  • Update the authentication documentation/OpenAPI descriptions to state the role requirement.
  • Audit all /api/v1 endpoints with a route-table test that fails when a route is accidentally added without the intended auth dependency. Public endpoints, if any, should be explicitly allowlisted.

Acceptance criteria

  • Missing or invalid credentials receive 401 on both experiment endpoints.
  • Authenticated accounts without the privileged role receive 403.
  • A privileged account can retrieve and export the report.
  • Invalid or extreme retention_days values receive 422 without scanning profiles or writing a file.
  • Automated tests enumerate the registered API routes and enforce the documented authentication policy.
  • README examples and generated OpenAPI security metadata match the implementation.

Relevant code

  • api/routes.py (get_experiment_report, export_experiment_report)
  • agent/auth.py
  • dashboard/experiment_report.py
  • README.md

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignapiAPI surface changesexperimentationA/B testing and experiment infrasecuritySecurity-sensitive work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions