fix: validate participantIds server-side instead of trusting form input

Fetch participants from the DB in the action using the season ID from
the URL params, eliminating the untrusted participantIds hidden field.
Remove the now-unused hidden input from the frontend form.

https://claude.ai/code/session_01WHRynBCcugSK7HHEmN6Yuy
This commit is contained in:
Claude 2026-02-19 23:40:38 +00:00
parent 5dd6d90193
commit 2c2df277d1
No known key found for this signature in database
2 changed files with 2 additions and 11 deletions

View file

@ -40,12 +40,8 @@ const scoringRules = {
export async function action({ request, params }: Route.ActionArgs) { export async function action({ request, params }: Route.ActionArgs) {
const formData = await request.formData(); const formData = await request.formData();
const participantIdsRaw = formData.get("participantIds"); const participants = await findParticipantsBySportsSeasonId(params.id);
if (typeof participantIdsRaw !== "string" || !participantIdsRaw) { const participantIds = participants.map((p: { id: string }) => p.id);
return { error: "No participant IDs provided" };
}
const participantIds = participantIdsRaw.split(",").filter(Boolean);
try { try {
const results = await Promise.all( const results = await Promise.all(

View file

@ -30,10 +30,6 @@ export default function ExpectedValuesPage({ loaderData, actionData }: Route.Com
0 0
); );
const participantIds = participants
.map((p: { id: string; name: string }) => p.id)
.join(",");
return ( return (
<div className="container mx-auto p-6 space-y-6"> <div className="container mx-auto p-6 space-y-6">
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
@ -85,7 +81,6 @@ export default function ExpectedValuesPage({ loaderData, actionData }: Route.Com
</div> </div>
<Form method="post"> <Form method="post">
<input type="hidden" name="participantIds" value={participantIds} />
<Table> <Table>
<TableHeader> <TableHeader>