createInvite has no role check — any member can invite #14
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
HouseholdService.createInvite()does not check whether the requesting user is aplanner. Any household member (including those withmemberrole) can generate invite codes.Affected files
HouseholdService.java:94-109— no role check before creating inviteRecommended fix
Check
member.getRole()and restrict invite creation toplannerrole (or make this a business decision and document it explicitly).Severity
Low — depends on business rules, but least-privilege suggests only planners should invite.
👨💻 Kai — Frontend Engineer
This is a pure backend authorization issue, but it does affect frontend behavior in one meaningful way: the invite creation UI.
Frontend implications:
hooks.server.tsshould expose the user's role. The page's+page.server.tsload function should checklocals.user.role === 'planner'and either redirect or return aforbiddenflag that suppresses the invite UI.What I need to know:
🔧 Backend Engineer — createInvite Role Check (Issue #14)
This is a straightforward authorization gap and the fix is clear. Let me add some implementation specifics.
The fix:
HouseholdService.createInvite()(line 94–109), fetch theHouseholdMemberrecord for the requesting user in this household, checkmember.getRole() == HouseholdRole.PLANNER, and throw a domain exception (e.g.,InsufficientRoleException) if they're not.@ExceptionHandlerand mapped to an HTTP 403 response.Why service layer, not controller:
if (role != PLANNER) return 403;in the controller, we've split the authorization logic across layers and made it invisible to unit tests of the service.Where to get the requesting user's role:
HouseholdMemberrecord rather than trusting any role passed from the request body.Also worth checking:
HouseholdServicemethods (e.g.,removeMember,changeRole,updateHouseholdSettings) that also lack role checks? This issue suggests the pattern is missing, not just a one-off. I'd audit the full service before closing this.Questions:
@PreAuthorizeor similar Spring Security method-level security annotation being used anywhere in the codebase? If so,@PreAuthorize("hasRole('PLANNER')")could handle this declaratively — but we'd need to ensure the role is in the security context, not just in the DB. Worth discussing the pattern before implementing.🧪 QA Engineer — createInvite Role Check (Issue #14)
Authorization gaps need to be tested at the integration level — a unit test of the service can verify the role check logic, but only an integration test proves the HTTP layer enforces it correctly end-to-end.
Tests I want written alongside this fix:
Unit tests (service layer):
Integration tests (full request cycle):
That last case is critical: a planner from household A should not be able to create an invite for household B. This is a separate but related authorization gap — the household ID in the path must be validated against the authenticated user's membership.
Regression check:
Audit suggestion:
HouseholdServicemethods alongside the backend engineer to produce a role-check coverage matrix. "Which methods exist, which roles do they require, which have tests?" This issue may be the tip of an iceberg.Questions:
🔐 Sable — Security Engineer
This is broken access control — OWASP A01. The severity is labeled Low because it's a business-rule violation (least privilege), but the real-world impact could be higher depending on how invites are used.
Attack scenario:
memberrole callsPOST /households/{id}/invitesdirectly (bypassing the UI entirely — just a curl command).The fix, with security requirements:
HouseholdService.createInvite()— fetch theHouseholdMemberfor the authenticated user, assertrole == PLANNER, throw 403 otherwise. Role must come from DB, not from the request.Broader audit I'm requesting before this closes:
HouseholdServicemutating methods should be audited for role checks. Specifically: remove member, change member role, update household name, delete household. Any of these missing a role check is the same class of bug.@PreAuthorizeannotations on the household controller methods? If not, all authorization is happening (or not happening) inside the service — which needs to be verified method by method.Questions:
🎨 Atlas — UI/UX Designer
This is a backend authorization issue, but the design layer has a role to play in preventing confusion and misuse at the UI level.
Role-aware UI:
Why "disabled" is the wrong pattern here:
Error state (defensive design):
Questions: