Repository navigation
Conversation
Boost validated a downloaded CAR file with carv2.ReadVersion before publishing a deal (which reads only the 11-byte CARv2 pragma) but with the strict carv2.OpenReader in addPiece afterwards. A client could therefore submit a file with a valid CARv2 pragma and an invalid (zeroed) 40-byte header, pass CommP verification, and have the deal published with the provider collateral locked. addPiece then failed fatally, Boost deleted the inbound file and refused retry, leaving the deal published but never activated; once SettleDealPayments was called at StartEpoch, the provider collateral was slashed in full. The pre-publication gate also did not check that the file fits in the declared piece size, which is another post-publication fatal failure in padreader.NewInflator: a file larger than PieceSize.Unpadded() passes CommP verification (the padding branch is skipped) but fails when the piece is handed to the sealer. Add validatePieceData, which mirrors the constraints in openReader (size > 0, size <= PieceSize.Unpadded(), strict carv2.OpenReader), and run it in verifyCommP and again immediately before publishing. The extra check before publishing also covers deals resumed at the Transferred checkpoint, where verifyCommP is not re-run. Online deals fail fatally; offline deals fail with a manual retry so the provider can supply the correct file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A client could cause an honest provider's deal collateral to be burned by
submitting a CAR file that Boost accepts before publishing but rejects
afterwards.
Boost checked downloaded data with
carv2.ReadVersionbefore publishing(
storagemarket/deal_commp.go), which reads only the 11-byte CARv2 pragma,while
addPieceuses the strictcarv2.OpenReader, which also validatesthe 40-byte CARv2 header. A file with a valid pragma and a zeroed header
passes CommP verification (the client can compute the matching PieceCID),
the deal is published and the provider collateral locked, and only then
does
addPiecefail. That failure is classified as fatal, the inbound fileis deleted, and retry is refused. The published deal is never activated,
so
SettleDealPaymentsatStartEpochslashes 100% of the providercollateral.
The same pre-publication gate also missed the size constraint enforced by
padreader.NewInflator: a file larger thanPieceSize.Unpadded()passesCommP verification (the padding branch is skipped) but fails fatally when
the piece is handed to the sealer.
Changes
validatePieceData, mirroring the constraints inopenReader:non-empty file,
size <= PieceSize.Unpadded(), strictcarv2.OpenReader.verifyCommP, so bad data is rejected before CommP is computed.Transferredcheckpoint whereverifyCommPis not re-run.(the provider can supply the correct file).
Compatibility
carv2.OpenReaderbehaves thesame as
carv2.ReadVersionfor CARv1 and additionally validates the CARv2header for CARv2.
ReadVersion, so no supportis lost.
openReadercheck, so a file that could previously be sealed successfully cannot be
rejected.
GenerateCommPLocallyis untouched, soboostx commpbehaviour isunchanged. DDO import paths are unaffected.
Testing
TestValidatePieceData: valid CARv2, valid CARv1, oversized file,empty file, and a CARv2 with a valid pragma and a zeroed header (with an
assertion that the old
ReadVersioncheck accepts it).TestSimpleOfflineDealHappy,TestOfflineDealDataCleanup,TestSimpleDealHappy,TestDealCompletionOnProcessResumption,TestSingleDealResumptionDisconnect,TestDealFailuresHandlingNonRecoverableErrors,TestDealVerification,TestDealRestartAfterManualRecoverableErrors,TestOfflineDealRestartAfterManualRecoverableErrors.go build ./storagemarket/...,go vet ./storagemarket/,gofmtclean.