@@ -265,7 +265,8 @@ public static void runCrossChainCheckers(Bridge bridge) {
265265 futures .add (
266266 EVMLiSAExecutor .submit (xEVMLiSA .class , () -> runEventOrderChecker (bridge , contract )));
267267 futures .add (
268- EVMLiSAExecutor .submit (xEVMLiSA .class , () -> runMissingEventNotificationChecker (contract )));
268+ EVMLiSAExecutor .submit (xEVMLiSA .class ,
269+ () -> runMissingEventNotificationChecker (contract , bridge .getPolicy ())));
269270 futures .add (
270271 EVMLiSAExecutor .submit (xEVMLiSA .class , () -> runAccessControlIncompleteness (contract )));
271272 }
@@ -456,20 +457,27 @@ public static void runEventOrderChecker(Bridge bridge, SmartContract contract) {
456457
457458 /**
458459 * Executes the Missing Event Notification Checker on a single contract. For
459- * each public function: (i) Follow only successful return paths (STOP for
460- * void, RETURN otherwise). (ii) Identify any SSTORE instructions on that
461- * path. (iii) Ensure that each such SSTORE is followed by at least one LOG
462- * before termination. (iv) Flag any missing notifications as
463- * vulnerabilities.
460+ * each public function with a cross-chain connection : (i) Follow only
461+ * successful return paths (STOP for void, RETURN otherwise). (ii) Identify
462+ * any SSTORE instructions on that path. (iii) Ensure that each such SSTORE
463+ * is followed by at least one Event emit before termination. (iv) Flag any
464+ * missing notifications as vulnerabilities.
464465 *
465466 * @param contract the SmartContract to analyze for missing event logs
466467 */
467- public static void runMissingEventNotificationChecker (SmartContract contract ) {
468+ public static void runMissingEventNotificationChecker (SmartContract contract , CustomPolicy policy ) {
468469 log .info ("[IN] Running missing event notification checker on {}." , contract .getName ());
469470
470471 EVMCFG cfg = contract .getCFG ();
471472
472473 for (Signature function : contract .getFunctionsSignature ()) {
474+ /*
475+ * We need to check only functions that have a cross chain
476+ * connection with another smart contract
477+ */
478+ if (policy .getEntriesBySourceFunction (function .getName ()).isEmpty ())
479+ continue ;
480+
473481 for (Statement entrypoint : function .getEntryPoints ()) {
474482 /*
475483 * It means that this vulnerability is inside a private
@@ -498,14 +506,28 @@ public static void runMissingEventNotificationChecker(SmartContract contract) {
498506 && exitpoint instanceof Return )
499507 continue ;
500508
501- /* We take only the state update inside the function */
502- Set <Statement > sstores = cfg . getStatementsInAPathWithTypes ( entrypoint , exitpoint ,
503- Set . of ( Sstore . class ) );
509+ Set < String > eventsPolicy = policy . getEventsForFunction ( function . getName ());
510+ Set <Signature > eventsContract = contract . getEventsSignature ();
511+ Set < Statement > eventsExitpoints = new HashSet <>( );
504512
505- for (Statement sstore : sstores ) {
506- if (cfg .reachableFromWithoutTypes (entrypoint , sstore , Set .of (Log .class ))
507- && cfg .reachableFromWithoutTypes (sstore , exitpoint , Set .of (Log .class ))) {
513+ for (String eventPolicy : eventsPolicy ) {
514+ for (Signature eventContract : eventsContract ) {
515+ if (!eventPolicy .equalsIgnoreCase (eventContract .getName ()))
516+ continue ;
517+ eventsExitpoints .addAll (eventContract .getExitPoints ());
518+ }
519+ }
520+
521+ /* Skip if we have no event exitpoints */
522+ if (eventsExitpoints .isEmpty ())
523+ continue ;
508524
525+ /* We take only state updates inside the function */
526+ Set <Statement > sstores = cfg .getStatementsInAPathWithTypes (entrypoint , exitpoint , Sstore .class );
527+
528+ for (Statement sstore : sstores ) {
529+ if (cfg .reachableFromWithoutStatements (entrypoint , sstore , eventsExitpoints )
530+ && cfg .reachableFromWithoutStatements (sstore , exitpoint , eventsExitpoints )) {
509531 ProgramCounterLocation sstoreLocation = (ProgramCounterLocation ) sstore
510532 .getLocation ();
511533 ProgramCounterLocation exitpointLocation = (ProgramCounterLocation ) exitpoint
0 commit comments