Class EasyTaintWrapper

java.lang.Object
soot.jimple.infoflow.taintWrappers.AbstractTaintWrapper
soot.jimple.infoflow.taintWrappers.EasyTaintWrapper
All Implemented Interfaces:
Cloneable, IReversibleTaintWrapper, ITaintPropagationWrapper

public class EasyTaintWrapper extends AbstractTaintWrapper implements IReversibleTaintWrapper, Cloneable
A list of methods is passed which contains signatures of instance methods that taint their base objects if they are called with a tainted parameter. When a base object is tainted, all return values are tainted, too. For static methods, only the return value is assumed to be tainted when the method is called with a tainted parameter value.
Author:
Christian Fritz, Steven Arzt
  • Constructor Details

  • Method Details

    • getDefault

      public static EasyTaintWrapper getDefault() throws IOException
      Throws:
      IOException
    • getTaintsForMethodInternal

      public Set<AccessPath> getTaintsForMethodInternal(soot.jimple.Stmt stmt, AccessPath taintedPath)
      Description copied from class: AbstractTaintWrapper
      Checks an invocation statement for black-box taint propagation. This allows the wrapper to artificially propagate taints over method invocations without requiring the analysis to look inside the method.
      Specified by:
      getTaintsForMethodInternal in class AbstractTaintWrapper
      Parameters:
      stmt - The invocation statement which to check for black-box taint propagation
      taintedPath - The tainted field or value to propagate
      Returns:
      The list of tainted values after the invocation statement referenced in Stmt has been executed
    • getInverseTaintsForMethod

      public Set<Abstraction> getInverseTaintsForMethod(soot.jimple.Stmt stmt, Abstraction d1, Abstraction taintedPath)
      Description copied from interface: IReversibleTaintWrapper
      Checks an invocation statement for black-box taint propagation. This allows the wrapper to artificially propagate taints over method invocations without requiring the analysis to look inside the method. Note that this method is the inverse of getTaintsForMethod. It obtains the taints that could have been tainted before a certain statement was executed given a taint that was active after the call.
      Specified by:
      getInverseTaintsForMethod in interface IReversibleTaintWrapper
      Parameters:
      stmt - The invocation statement which to check for black-box taint propagation
      d1 - The abstraction at the beginning of the method that calls the wrapped method
      taintedPath - The tainted field or value to propagate. Note that this taint must be valid after the execution of the black-box method.
      Returns:
      The list of possibly tainted values before the invocation statement referenced in Stmt has been executed
    • getInverseTaintsForMethodInternal

      public Set<AccessPath> getInverseTaintsForMethodInternal(soot.jimple.Stmt stmt, Abstraction taintedAbs)
    • isExclusiveInternal

      public boolean isExclusiveInternal(soot.jimple.Stmt stmt, AccessPath taintedPath)
      Description copied from class: AbstractTaintWrapper
      Gets whether the taints produced by this taint wrapper are exclusive, i.e. there are no other taints than those produced by the wrapper. In effect, this tells the analysis not to propagate inside the callee.
      Specified by:
      isExclusiveInternal in class AbstractTaintWrapper
      Parameters:
      stmt - The call statement to check
      taintedPath - The tainted field or value to propagate
      Returns:
      True if this taint wrapper is exclusive, otherwise false.
    • setAggressiveMode

      public void setAggressiveMode(boolean aggressiveMode)
      Sets whether the taint wrapper shall always assume the return value of a call "a = x.foo()" to be tainted if the base object is tainted, even if the respective method is not in the data file.
      Parameters:
      aggressiveMode - True if return values shall always be tainted if the base object on which the method is invoked is tainted, otherwise false
    • getAggressiveMode

      public boolean getAggressiveMode()
      Gets whether the taint wrapper shall always consider return values as tainted if the base object of the respective invocation is tainted
      Returns:
      True if return values shall always be tainted if the base object on which the method is invoked is tainted, otherwise false
    • setAlwaysModelEqualsHashCode

      public void setAlwaysModelEqualsHashCode(boolean alwaysModelEqualsHashCode)
      Sets whether the equals() and hashCode() methods shall always be modeled, regardless of the target type.
      Parameters:
      alwaysModelEqualsHashCode - True if the equals() and hashCode() methods shall always be modeled, regardless of the target type, otherwise false
    • getAlwaysModelEqualsHashCode

      public boolean getAlwaysModelEqualsHashCode()
      Gets whether the equals() and hashCode() methods shall always be modeled, regardless of the target type.
      Returns:
      True if the equals() and hashCode() methods shall always be modeled, regardless of the target type, otherwise false
    • addIncludePrefix

      public void addIncludePrefix(String prefix)
      Registers a prefix of class names to be included when generating taints. All classes whose names don't start with a registered prefix will be skipped.
      Parameters:
      prefix - The prefix to register
    • addMethodForWrapping

      public void addMethodForWrapping(String className, String subSignature)
      Adds a method to which the taint wrapping rules shall apply
      Parameters:
      className - The class containing the method to be wrapped
      subSignature - The subsignature of the method to be wrapped
    • clone

      public EasyTaintWrapper clone()
      Overrides:
      clone in class Object
    • supportsCallee

      public boolean supportsCallee(soot.SootMethod method)
      Description copied from interface: ITaintPropagationWrapper
      Checks whether this taint wrapper can in general produce artificial taints for the given callee. If an implementation returns "false" for a callee, all call sites for this callee might be removed if not needed elsewhere.
      Specified by:
      supportsCallee in interface ITaintPropagationWrapper
      Parameters:
      method - The method to check
      Returns:
      True if this taint wrapper can in general produce taints for the given method.
    • supportsCallee

      public boolean supportsCallee(soot.jimple.Stmt callSite)
      Description copied from interface: ITaintPropagationWrapper
      Checks whether this taint wrapper can in general produce artificial taints for the given call site. If an implementation returns "false" for a call site, this call sites might be removed if not needed elsewhere.
      Specified by:
      supportsCallee in interface ITaintPropagationWrapper
      Parameters:
      callSite - The call site to check
      Returns:
      True if this taint wrapper can in general produce taints for the given call site.
    • getAliasesForMethod

      public Set<Abstraction> getAliasesForMethod(soot.jimple.Stmt stmt, Abstraction d1, Abstraction taintedPath)
      Description copied from interface: ITaintPropagationWrapper
      Gets the aliases that a summarized method generates for the given abstraction. Note that this is a may-alias problem.
      Specified by:
      getAliasesForMethod in interface ITaintPropagationWrapper
      Parameters:
      stmt - The statement that calls the summarized method
      d1 - The abstraction at the entry point of the method that calls the wrapped method
      taintedPath - The abstraction for which the aliases shall be computed
      Returns:
      The set of aliases for the given abstraction or null if no such aliases exist
    • locateDefaultDefinitionFile

      public static File locateDefaultDefinitionFile()
      Attempts to locate the definition file for the easy taint wrapper in its default location
      Returns:
      The default definition file for the easy taint wrapper if it could be found, otherwise null