Skip to content

Commit 9c11ba3

Browse files
authored
Strictly enforce the Commitments max size in CBOR (#835)
The cbor-gen does not seem to implicitly enforce the length specified in the underlying Golang array type. Instead, it uses the maximum number of allowed bytes if no `maxlen` struct tag is specified (2MiB). Strictly enforce the max allowed size to avoid potential attack vector. Relates to: * whyrusleeping/cbor-gen#106
1 parent 7e86edb commit 9c11ba3

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

gpbft/cbor_gen.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gpbft/chain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type TipSet struct {
5656
// Blake2b256-32 CID of the CBOR-encoded power table.
5757
PowerTable cid.Cid
5858
// Keccak256 root hash of the commitments merkle tree.
59-
Commitments [32]byte
59+
Commitments [32]byte `cborgen:"maxlen=32"`
6060
}
6161

6262
// Validates a tipset.

gpbft/gpbft.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type Justification struct {
8585
type SupplementalData struct {
8686
// Merkle-tree of instance-specific commitments. Currently empty but this will eventually
8787
// include things like snark-friendly power-table commitments.
88-
Commitments [32]byte
88+
Commitments [32]byte `cborgen:"maxlen=32"`
8989
// The DagCBOR-blake2b256 CID of the power table used to validate the next instance, taking
9090
// lookback into account.
9191
PowerTable cid.Cid // []PowerEntry

0 commit comments

Comments
 (0)