B2023: a call out of an enclave to a subprogram that reaches its state or objects
Catalog status: active. Default severity: error. Stable name: enclave-call-out-global. Family: Types and constraints.
Inside a proof enclave's operations, its invariants may be broken in the middle of an update. A call out of the enclave (to a subprogram of another unit, a generic formal's actual, or through an access-to-subprogram value) must not reach the enclave's state or any object of its types: the callee could call the enclave's public operations on them, which assume the invariants hold. What the callee reaches is its Global contract, or what flow analysis infers for it.
Example (Vada)
with Holder; -- The_List : Lists.List; procedure Touch with Global => (In_Out => The_List);
package body Lists is
procedure Clear (L : in out List) is
begin
L.Head := null;
L.Count := 0;
Holder.Touch; -- may use The_List, perhaps the list being cleared
end Clear;
end Lists;What to do (Vada)
Call out only to subprograms that do not use the enclave's objects, or restructure the work so that the client calls the enclave, not the other way round.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.