Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types: error out on decoding BlockMsg with extraneous data #10863

Merged
merged 2 commits into from
May 29, 2023

Conversation

AnomalRoil
Copy link
Contributor

@AnomalRoil AnomalRoil commented May 12, 2023

This fixes the OSS-fuzz finding 48208: lotus:fuzz_block_msg.

The error being that invalid CBOR encoding of BlockMsg can lead to decoded values that do not re-serialize as is. Not necessarily a security issue, but making sure we're not decoding invalid representations shouldn't hurt and prevents us from having to worry about having multiple CBOR representation of the same thing (our CBOR decoder requires canonical CBOR).

Related Issues

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48208

Proposed Changes

This reads the remaining bytes in the reader provided to UnmarshalCBOR and if it still contains data, errors out.

Additional Info

The oss-fuzz testcase boils down to:
0x83F6808020
which contains an extra byte after the data items: https://cbor.me/?bytes=83(F6-80-80((20

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

fix: types: error out on decoding BlockMsg with extraneous data
Fixes OSS-fuzz issue 48208: lotus:fuzz_block_msg

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
@AnomalRoil AnomalRoil requested a review from a team as a code owner May 12, 2023 19:45
Copy link
Contributor

@fridrik01 fridrik01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, also nice tests!

chain/types/blockmsg_test.go Outdated Show resolved Hide resolved
chain/types/blockmsg_test.go Outdated Show resolved Hide resolved
Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
@arajasek
Copy link
Contributor

Thanks very much!

@arajasek arajasek merged commit b76b5ef into filecoin-project:master May 29, 2023
93 checks passed
@AnomalRoil AnomalRoil deleted the fix/fuzz/48208 branch May 30, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants