Expense search leaks other groups' expenses (#28) - #34
Merged
Merged
Conversation
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.
Closes #28
Summary
Fixes a SQL injection in expense search.
listExpensesinsrc/expenses.tsnow binds the search term as a?parameter (e.description LIKE ?with%${query}%pushed ontoparams) instead of splicing it into the SQL string, so a search only returns expenses from the group in the URL.Acceptance criteria
goa-tripreturns no Flat 4B expense; every row hasgroup_idgoa-tripbun test tests/routes.test.ts -t "does not leak other groups' expenses"→1 pass, 0 failqis treated as literal text (200 with a list, no SQL error)bun test tests/routes.test.ts -t "treats quotes in q as literal text"→1 pass, 0 fail?q=Fuelstill returns exactly one expense)bun test tests/routes.test.ts→11 pass, 0 failoptions.queryno longer in the SQL string; stale "SEEDED DEFECT / VULNERABLE" comments removedgrep -n 'options.query}' src/expenses.ts→ no matchmake check→tsc --noEmitclean,28 pass, 0 failacross 4 files, skills validNon-goals respected
src/auth/**,.factory/**,.claude/**,.agents/**or.github/**. The diff issrc/expenses.tsandtests/routes.test.tsonly.src/routes/expenses.tsnot edited.%/_wildcard escaping and noESCAPEclause. Wildcard matching within the caller's own group is a separate question to file on its own.listExpensesuntouched; no changes toseed.ts,db.ts, the schema,csv.tsorcli.ts.The test that bites
GET /api/groups/:id/expenses > search does not leak other groups' expensesmain: with onlysrc/expenses.tsreverted to the base,bun test tests/routes.test.ts -t "does not leak other groups' expenses"fails withExpected to not contain: "Electricity bill"(the response included Flat 4B expenses). The same revert also failssearch treats quotes in q as literal textwith a SQLite syntax error.bun test tests/routes.test.ts -t "does not leak other groups' expenses"→1 pass, 0 failGate line
auditis an optional gate. It flags existinghonoadvisories that are unrelated to this change.Protected paths touched
noneReviewer findings addressed
None. The reviewer confirmed that the bound params are in the same order as the
?placeholders, pagination is unchanged, no string splicing is left insrc/expenses.ts, and no authz or secrets changed. Full evidence is in the verdict comment on #28.Note from triage: a code comment cited this defect as "issue #4". If #4 is still open, it's a duplicate of this one.
Human checklist
🤖 Generated with Claude Code