-
Notifications
You must be signed in to change notification settings - Fork 266
Description
The jolt::provable proc_macro_attribute does not take into account subsequent attributes when generating the token stream of a function. For instance, the make_execute_function's quote! does not output any used attributes alongside the function itself. This can lead to arbitrary behavior. If a user adds a custom safety-attribute or logical-attribute, this attribute will be omitted, which could introduce an unknown vulnerability or prevent the program from compiling. For example, the following code will fail to compile:
// guest code
#[jolt::provable]
#[allow(arithmetic_overflow)]
pub fn overflow_add() -> u8 {
let x = u8::MAX + u8::MAX;
x // should return 254
}with the following error:
error: this arithmetic operation will overflow
--> guest/src/lib.rs:21:13
|
21 | let x = u8::MAX + u8::MAX;
| ^^^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: could not compile `guest` (lib) due to 1 previous errorIn this case, this issue is preventing the program from compiling, but other attributes if omitted could introduce undefined behavior.
Consider either allowing the usage of further attributes, or parsing all function attributes and whitelisting a defined subset of those attributes to prevent undefined behavior.