Skip to content

Validate route-level :slug, :projectId, and :issueId params before fetching in detail pages #307

Description

@Jagadeeshftw

📌 Description

The router in src/app/App.tsx passes untrusted path params (:slug, :projectId, :issueId, :ecosystemId, :eventId) straight into detail pages via routeWrappers.tsx, which only null-checks presence. A malformed projectId is then interpolated directly into API endpoints like /projects/${projectId}. Add lightweight param-shape validation (allowed charset/length) in the wrappers so obviously invalid params render the NotFound/empty state instead of issuing a doomed request.

💡 Why it matters: Forwarding arbitrary path segments into API URLs wastes requests and can be abused to probe the backend.

🧩 Requirements and context

  • Define a small validator for id/slug params (e.g. UUID-ish or [a-z0-9-] bounded length).
  • Validate in ProjectDetailPageRoute, IssueDetailPageRoute, EcosystemDetailPageRoute, and the blog :slug path.
  • Render the existing not-found/empty state for invalid params rather than fetching.
  • Keep the existing presence null-guards.
  • Test valid and malformed params per wrapper.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b security/validate-route-params

2. Implement changes

  • Write/modify the relevant source: src/features/dashboard/routeWrappers.tsx (+ blog article page)
  • Write comprehensive tests: routeWrappers.test.tsx
  • Add documentation: inline TSDoc on the validator
  • Include TSDoc doc comments
  • Validate security assumptions: params constrained before URL interpolation

3. Test and commit

  • Run tests:
npm test -- routeWrappers
  • Cover edge cases: empty, overly long, path-traversal-like, encoded params
  • Include test output and security notes in the PR description.

Example commit message

security(routing): validate route params before detail fetches

✅ Acceptance criteria

  • Shared param validator added
  • Applied to all id/slug wrappers
  • Invalid params show not-found/empty state
  • Tests cover malformed params

🔒 Security notes

Reject path-traversal (.., /) and encoded variants before they reach apiRequest.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuebugSomething isn't workingfrontendFrontend / UI worksecuritySecurity hardening / audit

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions