Spot the bug in direct-upload completion

from File uploads
Node 24 intermediate 4 min 1 issue to find

Find the trust-boundary flaw in this direct-upload completion handler.

JavaScript
async function completeUpload(id, body, actor, db) {
  const record = await db.files.find(id);
  if (record.ownerId !== actor.id) throw new Error('forbidden');
  await db.files.update(id, {
    status: 'available',
    size: body.size,
    contentType: body.contentType,
    checksum: body.sha256,
  });
  return { id, status: 'available' };
}
Open in playground
Report an error