fix: validate cryptifytoken header in upload_finalize#99
Conversation
|
add some tests |
1 similar comment
|
add some tests |
|
Added 6 unit tests in b6696a4:
All green via |
Adds the same CryptifyToken validation to upload_finalize that upload_chunk already performs: the header is extracted via FinalizeHeaders and checked against state.cryptify_token before any file read. Without this, anyone who knew a valid upload UUID could finalize an upload without possessing the correct token, bypassing the token chain established during init/upload_chunk. Refactors the match against state.cryptify_token into a small check_cryptify_token helper shared by upload_chunk and upload_finalize so the two call-sites can't drift. Tests (15 new, 5 existing): - finalize_headers_* (4): FinalizeHeaders extractor regression tests — reject missing CryptifyToken, missing Content-Range, malformed range; echo both on success. - content_range_* (5): ContentRange parser coverage. - check_cryptify_token_* (4): match/mismatch/empty/case-sensitive. - compute_hash_* (2): determinism and token-sensitivity. Closes #45
b6696a4 to
448f82e
Compare
|
Dobby has rebased this on top of The branch previously had two commits from two different dobby variants running in parallel — both have been preserved and consolidated into a single commit with all the tests from both:
All 20 tests pass locally ( Will flip to ready-for-review once CI is green. |
|
Dobby sees the approval! Master rubenhensen has approved Dobby's fix for the Dobby will now update his notes so that future Dobbys remember the token-chain lesson from this fix. |
Summary
upload_finalizewas not validating thecryptifytokenheader despite the frontend sending it with every finalize request. Anyone who knew a valid upload UUID could finalize an upload without possessing the correct token, bypassing the token chain established duringinitandupload_chunk.This adds the same validation that
upload_chunkalready performs: the header is extracted, and the request is rejected with400 Bad Requestif it's missing or does not matchstate.cryptify_token.Why draft
There is no existing integration test suite that exercises the upload handlers, so I could not add a regression test. Verified locally via
cargo build --releaseandcargo test. A maintainer should confirm the change behaves as expected end-to-end with the frontend.How to verify
POST /fileupload/init.POST /fileupload/finalize/<uuid>with a wrong or missingcryptifytoken— should now return400 Bad Requestinstead of succeeding.Closes #45