Reject tags owned by another business in charge tag updates
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 69/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start with validateUploadTarget in packages/server/src/modules/documents/helpers/upload-to-charge.helper.ts and its tests, then trace the listed charge and tag mutation paths to ChargeTagsProvider.insertChargeTag. Validate every caller-supplied tag id against the write-target business before any batch writes. Done means each listed mutation rejects a visible tag owned by another business with an error naming its id, with unit tests covering each path.
Written by the indexing model from the issue text.
Description
Problem
Writes that link a tag to a charge accept any tag id the caller can read, without checking that the tag belongs to the business being written to.
Under the multi-business RLS scope (2026-05-25T10-00-00.rls-multi-business-scope.ts):
- Reads on
tagsareowner_id = ANY(get_current_business_scope()), so a request can see the tags of every business in its scope. - Writes on
charge_tagsare pinned to the single write-target business (get_current_business_id()). charge_tags.tag_idis a bare foreign key, so it accepts any existing tag id.
As a result, a caller whose read scope covers businesses A and B can write a charge of A to point at a tag owned by B. That is cross-tenant data mixing.
The new-charge upload path already guards against this. #4904 added an ownership check in validateUploadTarget (packages/server/src/modules/documents/helpers/upload-to-charge.helper.ts), which rejects tags whose owner_id differs from AdminContextProvider.getVerifiedAdminContext().ownerId. The older tag-write paths don't have it.
Affected call sites (caller-supplied tag ids → ChargeTagsProvider.insertChargeTag)
packages/server/src/modules/charges/resolvers/charges.resolver.ts:updateCharge: the tag diff, around theinsertChargeTagcall.batchUpdateCharges: viabatchUpdateChargesTagsincharges/helpers/batch-update-charges.ts.
packages/server/src/modules/tags/resolvers/tags.resolvers.ts: thebatchUpdateChargesTagsmutation, viaapplyChargeTagChangesintags/helpers/batch-charge-tags.helper.ts. The MCP toolaccounter_update_charges_tagsgoes through this path too.
Not affected: business-trips-expenses.helper.ts and financial-charge.helper.ts also call insertChargeTag, but with server-chosen tags.
Suggested fix
- Extract the check from
validateUploadTargetinto a shared helper in the tags module, e.g.assertTagsOwnedByWriteTarget(injector, tagIds). It would load the tags withTagsProvider.getTagByIDLoader, reject missing ids, and reject tags whoseowner_iddiffers from the write-target owner. - Call it at each site above before any write. The batch paths should validate the whole id list up front, so a bad id can't leave a partial update behind.
- Consider moving this into
ChargeTagsProvider.insertChargeTagitself, so a future caller can't skip it.
Done when
- Each mutation above rejects a tag visible through the read scope but owned by another business, with a clear error naming the id.
- Unit tests cover each path, including a "visible tag owned by another business" case, mirroring the tests in
upload-to-charge.helper.test.ts. - Optionally, a DB-backed integration test with two businesses in scope.
- Dominant language
- TypeScript
- Stars
- 30
- Forks
- 10
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 276
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Urigo/accounter-fullstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Urigo/accounter-fullstack#5302 ·
Maintainers usually reply within 2 days
-
1214 annual-audit-workflow
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Urigo/accounter-fullstack#5257 ·
Maintainers usually reply within 2 days
-
1214 annual-audit-workflow
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#5256 ·
Maintainers usually reply within 2 days
-
annual-audit-workflow
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Urigo/accounter-fullstack#5252 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#4919 ·
Maintainers usually reply within 2 days
All issues in Urigo/accounter-fullstack
Similar issues
-
area: integrations documentation priority: P2 size: XS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eddiejaoude/StackDash#798 ·
Maintainers usually reply within 1 day
-
bot:ai-assisted component:midnight-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midnightntwrk/midnight-js#1790 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:vscode bug has repro platform:macos platform:vscode regression
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 77/100
Maintainers usually reply within 1 day