@@ -114,13 +114,19 @@ public boolean visit(
114114
115115 int numArgs = getNumberOfArgs (node );
116116 boolean isAtLeastOneTainted = false ;
117+ boolean isAtLeastOneTop = false ;
117118
118- for (int argIndex = 1 ; argIndex <= numArgs ; argIndex ++)
119+ for (int argIndex = 1 ; argIndex <= numArgs ; argIndex ++) {
119120 isAtLeastOneTainted |= TaintElement .isAtLeastOneTainted (
120121 taintedStack .getElementAtPosition (argIndex ));
122+ isAtLeastOneTop |= TaintElement .isAtLeastOneTop (
123+ taintedStack .getElementAtPosition (argIndex ));
124+ }
121125
122126 if (isAtLeastOneTainted )
123- checkForAccessControlIncompleteness (tool , cfg , node );
127+ checkForAccessControlIncompleteness (tool , cfg , node , false );
128+ else if (isAtLeastOneTop )
129+ checkForAccessControlIncompleteness (tool , cfg , node , true );
124130 }
125131 }
126132 return true ;
@@ -157,7 +163,7 @@ private int getNumberOfArgs(Statement node) {
157163 */
158164 private void checkForAccessControlIncompleteness (CheckToolWithAnalysisResults <
159165 SimpleAbstractState <MonolithicHeap , TaintAbstractDomain , TypeEnvironment <InferredTypes >>> tool , EVMCFG cfg ,
160- Statement sink ) {
166+ Statement sink , boolean isTop ) {
161167
162168 Set <Statement > sources = cfg .getAllStatementsByClass (
163169 Calldataload .class ,
@@ -176,23 +182,43 @@ private void checkForAccessControlIncompleteness(CheckToolWithAnalysisResults<
176182
177183 ProgramCounterLocation sinkLocation = (ProgramCounterLocation ) sink .getLocation ();
178184
179- log .warn (
180- "[DEFINITE] Access Control Incompleteness vulnerability at pc {} (line {}) coming from pc {} (line {})." ,
181- sinkLocation .getPc (),
182- sinkLocation .getSourceCodeLine (),
183- ((ProgramCounterLocation ) sink .getLocation ()).getPc (),
184- ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ());
185-
186- String warn = "[DEFINITE] Access Control Incompleteness vulnerability at "
187- + ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ();
188- tool .warn (warn );
189- MyCache .getInstance ().addUncheckedExternalCallWarning (cfg .hashCode (), warn );
190-
191- warn = "[DEFINITE] Access Control Incompleteness vulnerability in " + contract .getName () + " at "
192- + functionSignatureByStatement
193- + " (pc: " + ((ProgramCounterLocation ) sink .getLocation ()).getPc () + ", "
194- + "line: " + ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine () + ")" ;
195- MyCache .getInstance ().addVulnerabilityPerFunction (cfg .hashCode (), warn );
185+ if (isTop ) {
186+ log .warn (
187+ "[POSSIBLE] Access Control Incompleteness vulnerability at pc {} (line {}) coming from pc {} (line {})." ,
188+ sinkLocation .getPc (),
189+ sinkLocation .getSourceCodeLine (),
190+ ((ProgramCounterLocation ) sink .getLocation ()).getPc (),
191+ ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ());
192+
193+ String warn = "[POSSIBLE] Access Control Incompleteness vulnerability at "
194+ + ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ();
195+ tool .warn (warn );
196+ MyCache .getInstance ().addPossibleAccessControlIncompletenessWarning (cfg .hashCode (), warn );
197+
198+ // warn = "[POSSIBLE] Access Control Incompleteness vulnerability in " + contract.getName() + " at "
199+ // + functionSignatureByStatement
200+ // + " (pc: " + ((ProgramCounterLocation) sink.getLocation()).getPc() + ", "
201+ // + "line: " + ((ProgramCounterLocation) sink.getLocation()).getSourceCodeLine() + ")";
202+ // MyCache.getInstance().addVulnerabilityPerFunction(cfg.hashCode(), warn);
203+ } else {
204+ log .warn (
205+ "[DEFINITE] Access Control Incompleteness vulnerability at pc {} (line {}) coming from pc {} (line {})." ,
206+ sinkLocation .getPc (),
207+ sinkLocation .getSourceCodeLine (),
208+ ((ProgramCounterLocation ) sink .getLocation ()).getPc (),
209+ ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ());
210+
211+ String warn = "[DEFINITE] Access Control Incompleteness vulnerability at "
212+ + ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine ();
213+ tool .warn (warn );
214+ MyCache .getInstance ().addAccessControlIncompletenessWarning (cfg .hashCode (), warn );
215+
216+ warn = "[DEFINITE] Access Control Incompleteness vulnerability in " + contract .getName () + " at "
217+ + functionSignatureByStatement
218+ + " (pc: " + ((ProgramCounterLocation ) sink .getLocation ()).getPc () + ", "
219+ + "line: " + ((ProgramCounterLocation ) sink .getLocation ()).getSourceCodeLine () + ")" ;
220+ MyCache .getInstance ().addVulnerabilityPerFunction (cfg .hashCode (), warn );
221+ }
196222 }
197223 }
198224 }
0 commit comments