Skip to content

Commit e6d780a

Browse files
committed
fix(webapp): harden error status filter validation
Use hasOwnProperty instead of `in` when validating filter[status] so inherited Object properties (e.g. toString) can't pass validation and map to a non-status value.
1 parent 80db49b commit e6d780a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

apps/webapp/app/presenters/v3/ApiErrorListPresenter.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export const ApiErrorListSearchParams = z.object({
4545
}
4646

4747
const statuses = value.split(",");
48-
const invalid = statuses.filter((status) => !(status in API_STATUS_TO_DB));
48+
// hasOwnProperty, not `in`: `in` walks the prototype chain, so
49+
// `filter[status]=toString` would pass and map to a function.
50+
const invalid = statuses.filter(
51+
(status) => !Object.prototype.hasOwnProperty.call(API_STATUS_TO_DB, status)
52+
);
4953

5054
if (invalid.length > 0) {
5155
ctx.addIssue({

0 commit comments

Comments
 (0)