NOTE: $l$ used in this document is the same as $l$ used in https://eips.ethereum.org/EIPS/eip-2494, and same as $r$ used in Geometry's bug report.
The theoretical fix is to ensure $secret < l$. In circom, it'll look like this:
LessThan(251)([secret, l]) === 1;
Readers may know that just using LessThan template doesn't protect against all cases. For example, run this in zkrepl.dev: https://gist.github.com/0xbok/3f87b9c79fde41759f31fc62de218b80. It shows that LessThan passes when $secret = SNARK_FIELD-1$. $SNARK_FIELD-1$ is the maximum value in circom and hence it's greater than $l$, but LessThan returns 1 interpreting it as $p-1 < l$.
We show that enforcing LessThan(251)[secret, l].out === 1 and then using BabyPbk() (as defined in current master branch of circomlib) on $secret$ is enough to enforce that $secret < l$.
Proof