-
Notifications
You must be signed in to change notification settings - Fork 102
CBORBytes does not validate - change Send() API to accept []byte #972
Comments
My current solution is to"
|
This change validates CBOR whenever accepted from the user as an arbitrary byte array. Note: 1. For the multisig actor, we could _technically_ skip validating the CBOR on approval because it has already been validated on propose. But this shouldn't be that expensive. 2. We don't actually need to validate the CBOR in the cron actor. I'm happy to remove it, I just wanted to start with something paranoid and walk back from there. fixes #972 depends on whyrusleeping/cbor-gen#39
This change validates CBOR whenever accepted from the user as an arbitrary byte array. Note: 1. For the multisig actor, we could _technically_ skip validating the CBOR on approval because it has already been validated on propose. But this shouldn't be that expensive. 2. We don't actually need to validate the CBOR in the cron actor. I'm happy to remove it, I just wanted to start with something paranoid and walk back from there. fixes #972 depends on whyrusleeping/cbor-gen#39
I do not understand what's dangerous here. Perhaps a concrete example would help. What would go wrong if something isn't valid CBOR, besides a call failing with |
See discussion in #973, but I don't think this is a problem or that we should do anything. |
Concrete example here: #974 (comment) |
This is effectively a buffer overflow. |
Resolution: In theory, actor "methods" take bytes and return bytes. However, for convenience, we encode to/from CBOR in the runtime. This means that, in theory, we shouldn't have to validate CBOR before calling To be specific, the following would be problematic: type Invocation struct {
Method abi.MethodNum
Params CBORMarshaller // Note: we don't do this in practice, we use bytes.
Amount abi.TokenAmount
} If So, to be extra-careful, we validate when calling Future proposal:
func Send(target Address, method MethodNum, params []bytes, amount TokenAmount) (ret []byte, code ExitCode)
func SendCBOR(rt Runtime, target Address, method MethodNum, params CBORMarshaler, amount TokenAmount, out CBORUnmarshaler) ExitCode |
This change validates CBOR when "sending" it to other actor methods. Technically, actor message params are arbitrary bytes. Ideally, we'd just pass the raw bytes in. However, for convenience, the runtime accepts any object implementing `CBORMarshaler`. Unfortunately, passing raw bytes as a `CBORMarshaler` without _checking_ them could lead to bugs down the road if we decide to treat this `CBORMarshaler` object as a valid CBOR object, so we validate them. fixes #972
This change validates CBOR when "sending" it to other actor methods. Technically, actor message params are arbitrary bytes. Ideally, we'd just pass the raw bytes in. However, for convenience, the runtime accepts any object implementing `CBORMarshaler`. Unfortunately, passing raw bytes as a `CBORMarshaler` without _checking_ them could lead to bugs down the road if we decide to treat this `CBORMarshaler` object as a valid CBOR object, so we validate them. fixes #972
This change validates CBOR when "sending" it to other actor methods. Technically, actor message params are arbitrary bytes. Ideally, we'd just pass the raw bytes in. However, for convenience, the runtime accepts any object implementing `CBORMarshaler`. Unfortunately, passing raw bytes as a `CBORMarshaler` without _checking_ them could lead to bugs down the road if we decide to treat this `CBORMarshaler` object as a valid CBOR object, so we validate them. fixes #972
This change validates CBOR when "sending" it to other actor methods. Technically, actor message params are arbitrary bytes. Ideally, we'd just pass the raw bytes in. However, for convenience, the runtime accepts any object implementing `CBORMarshaler`. Unfortunately, passing raw bytes as a `CBORMarshaler` without _checking_ them could lead to bugs down the road if we decide to treat this `CBORMarshaler` object as a valid CBOR object, so we validate them. fixes #972
Unlike
cbg.Deferred
,runtime.CBORBytes
does not validate the input CBOR. It looks like we may be fine at the moment, but anything like the following would be really dangerous:I'd feel more comfortable if we used deferred (always checks on deserialize), but this would be a pretty large refactor.
The text was updated successfully, but these errors were encountered: