fix(organization): cap BrandContextSchema's id field length - #6997
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(organization): cap BrandContextSchema's id field length#6997pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
pedrofrxncx
enabled auto-merge (squash)
September 4, 2026 13:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every free-text field on
BrandContextSchema(packages/shared/src/organization/schema.ts) is capped atMAX_BRAND_STRING_LENGTH(500 chars) exceptid— the one field left as a barez.string().idis client-supplied onBRAND_CONTEXT_UPDATE(apps/api/src/tools/organization/brand-context-update.ts) and flows straight into a KyselyWHERE id = ...lookup (apps/api/src/storage/brand-context.ts). The query is parametrized so there's no injection risk, but an org member with ordinary brand-write permission could send an arbitrarily largeidstring in the request body with no validation catching it before it reaches storage — the same missing-validation-on-untrusted-input class every sibling field on this schema already guards against.Fix: add the existing
MAX_BRAND_STRING_LENGTHcap toid, matching every other field on the schema.Failure scenario before the fix:
BRAND_CONTEXT_UPDATEwith a multi-KBidstring passes schema validation and reaches the DB lookup unchecked.Reviewer check:
bun test packages/shared/src/organization/schema.test.ts— includes a new regression test asserting a 501-char id is rejected.Locally ran:
bun run fmt,cd packages/shared && bunx tsc --noEmit, the targeted test above, andbunx oxlinton both changed files — all clean. Full CI validates the rest.Summary by cubic
Caps
BrandContextSchema'sidfield atMAX_BRAND_STRING_LENGTH(500 characters), matching the validation on every other free-text field. Previously,idwas an unbounded string, so a client could submit an arbitrarily long id that reached storage without being caught. Now such inputs are rejected during schema validation.Written for commit bf6beca. Summary will update on new commits.