Skip to content

billingtype: cross-tenant GET/PATCH/DELETE returns 403 — lets scoped callers enumerate billing-type ids #187

@CryptoJones

Description

@CryptoJones

Problem

Same class of bug as #173 (company), this time on the BillingType
controller:

  • GET /v1/billingtype/:id returns 404 for non-existent ids and 403
    for ids that exist but belong to a different tenant
  • PATCH /v1/billingtype/:id does the same
  • DELETE /v1/billingtype/:id does the same

A scoped (non-master) caller can iterate btId values and learn
which ids are populated across the whole tenant table by status
code alone.

Fix

Collapse "exists but not yours" into 404 with the same "Not found." body the absent-id branch uses. Master-key callers
unchanged; own-tenant 200 path unchanged.

Same pattern propagates to every soft-deletable entity (worker,
customer, invoice, job, …). They'll get their own PRs in follow-up
iterations — one entity per PR.

Acceptance

  • getById: non-master + existing-but-not-yours → 404
  • update: non-master + existing-but-not-yours → 404
  • remove: non-master + existing-but-not-yours → 404
  • Tests in tests/api/billingtype.test.js pin all three

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions