Security: Missing Authorization Check in ensureTeamPlan Middleware#540
Open
tomaioo wants to merge 1 commit into
Open
Conversation
The `ensureTeamPlan` middleware sets `ctx.state.isTeamPlanRequired` based on whether the domain plan is 'team', but it does NOT enforce any restriction. The variable name suggests it should block non-team plans, yet it always calls `next()`. This is likely a logic bug where the developer intended to check if team plan is required and throw an error if not met, but instead only sets a boolean flag without enforcement. Signed-off-by: tomaioo <[email protected]>
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.
Summary
Security: Missing Authorization Check in ensureTeamPlan Middleware
Problem
Severity:
High| File:app/controllers/web/my-account/ensure-team-plan.js:L6The
ensureTeamPlanmiddleware setsctx.state.isTeamPlanRequiredbased on whether the domain plan is 'team', but it does NOT enforce any restriction. The variable name suggests it should block non-team plans, yet it always callsnext(). This is likely a logic bug where the developer intended to check if team plan is required and throw an error if not met, but instead only sets a boolean flag without enforcement.Solution
Add proper authorization logic. If the intent is to require a team plan, throw an error when
ctx.state.domain.plan !== 'team'. If the intent is just to set a flag for downstream use, rename the variable to avoid confusion. Current implementation:ctx.state.isTeamPlanRequired = ctx.state.domain.plan !== 'team';should likely be:if (ctx.state.domain.plan !== 'team') throw Boom.paymentRequired(ctx.translateError('TEAM_PLAN_REQUIRED'));Changes
app/controllers/web/my-account/ensure-team-plan.js(modified)