# Motoko request: Type size limit annotations

**URL:** <https://forum.dfinity.org/t/motoko-request-type-size-limit-annotations/31718>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [June 10, 2024, 4:17am UTC](https://forum.dfinity.org/t/motoko-request-type-size-limit-annotations/31718 "2024-06-10T04:17:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [June 10, 2024, 4:17am UTC](https://forum.dfinity.org/t/motoko-request-type-size-limit-annotations/31718/1 "2024-06-10T04:17:22Z")

</div>

I’ve now done three audits and everyone fails and has issues dealing with ingress and canister to canister DDoS cycle drain attacks where with ICRC1 where an attacker can put a huge memo or huge sub account.

Ingress inspect\_message can help, but much less can be done about canister to canister other than checking as early as possible and trapping if you see a violation.

It would be really great, even if it is only with public actor method and queries to be able to declare something:

‘’’  
public type TransferArgs = {  
to : {  
owner : Principal;  
subaccount : opt Blob\<32|32\>; // must be Len 32 if included  
};  
memo : opt [Nat8]\<|32\>; //can be len 0-32  
…  
}

It would be nice if the compiled motoko would just trap for us on those violations. It would remove a significant amount of boilerplate from everyone’s code that is releasing production actors.

Perhaps there is better sugar here, but that is the idea.

---

<div class="post-metadata">

**Author:** ![chenyan](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chenyan](https://forum.dfinity.org/u/chenyan)\
**Post date:** [June 10, 2024, 9:26pm UTC](https://forum.dfinity.org/t/motoko-request-type-size-limit-annotations/31718/2 "2024-06-10T21:26:46Z")

</div>

Thanks for the report. We are working on a solution at the Candid level. Basically, users can optionally specify a size limit on the Candid types during deserialization. The spec for this config is just up for review: [spec: candid type selector by chenyan-dfinity · Pull Request #555 · dfinity/candid · GitHub](https://github.com/dfinity/candid/pull/555).

At the moment, we only implemented this for Rust bindgen and random value generation. We will start to implement this for deserialization soon. For Motoko, we also need to figure out a good syntax to specify these limits, probably with some decoration.

---

<div class="post-metadata">

**Author:** ![LightningLad91](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lightninglad91/32/5373_2.png) [@LightningLad91](https://forum.dfinity.org/u/LightningLad91)\
**Post date:** [June 11, 2024, 11:12am UTC](https://forum.dfinity.org/t/motoko-request-type-size-limit-annotations/31718/3 "2024-06-11T11:12:57Z")

</div>

If we can get something like this it would be a huge relief.

I also like the idea of using a separate file to define our configuration.
