Skip to content

fix(starknet-p2p-types): return error for invalid address public key bytes #1544

Description

@aproskill81

Summary

Address::from_proto() in starknet-p2p-types can panic on malformed 32-byte public key data instead of returning ProtoError.

Problem

Address::from_proto() checks only that the input length is 32, then calls Address::new(bytes), which reaches PublicKey::from_bytes(bytes). That constructor currently does try_from(...).unwrap().

As a result, invalid Ed25519 public key bytes with the correct length can panic during protobuf decoding.

Fix

Keep this narrow and local:

  • validate the 32-byte payload before constructing Address
  • return ProtoError on invalid key bytes instead of panicking
  • add a test covering invalid 32-byte input

If this makes sense, I can open a small PR with the fix and a regression test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-triageThis issue needs to be triaged

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions