Skip to content

Commit

Permalink
Fix blob upload verify hash bypass (#87)
Browse files Browse the repository at this point in the history
* Fix empty string detection + undefined bypass

* Delete upload file from R2 after cancel
  • Loading branch information
Dramelac authored Jan 3, 2025
1 parent 79ae725 commit d41961c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/registry/r2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function getUploadState(
throw new InternalError();
}

if (!verifyHash && stateStrHash !== verifyHash) {
if (verifyHash !== undefined && stateStrHash !== verifyHash) {
return new RangeError(stateStrHash, stateObject);
}

Expand Down Expand Up @@ -719,6 +719,7 @@ export class R2Registry implements Registry {

const upload = this.env.REGISTRY.resumeMultipartUpload(state.registryUploadId, state.uploadId);
await upload.abort();
await this.env.REGISTRY.delete(getRegistryUploadsPath(state));
return true;
}

Expand Down

0 comments on commit d41961c

Please sign in to comment.