Reject tags owned by another business in charge tag updates
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 69/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 30
- フォーク
- 10
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 276
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Urigo/accounter-fullstack のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
Urigo/accounter-fullstack#5302 ·
メンテナーはふだん 2 日以内に返信
-
1214 annual-audit-workflow
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Urigo/accounter-fullstack#5257 ·
メンテナーはふだん 2 日以内に返信
-
1214 annual-audit-workflow
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
Urigo/accounter-fullstack#5256 ·
メンテナーはふだん 2 日以内に返信
-
annual-audit-workflow
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
Urigo/accounter-fullstack#5252 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
Urigo/accounter-fullstack#4919 ·
メンテナーはふだん 2 日以内に返信
Urigo/accounter-fullstack の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
tashfeenahmed/freellmapi#2217 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
remotion-dev/skills#37 ·
-
gui: a narrow window's gateway key row with a line under it wraps its faded badges onto blank linesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
Slider: Escape during a thumb drag keeps and commits the dragged value, unlike ui-sdk's other dragsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
vercel-labs/ui#1758 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nicobailon/pi-subagents#3425 ·
メンテナーはふだん 1 日以内に返信