Giter VIP home page Giter VIP logo

Comments (12)

jon-bell avatar jon-bell commented on July 17, 2024

Please see my comment on your PR. Please do not open a PR to add a new test until you have debugged it to verify that it's not a problem in the test itself.

If you have simple usage questions, like "How do I taint an array?" It might be more straightforward to, again, make a more compact example. Reflection is just adding a lot of confusion for you here.

Your code

int[] temp = (int[])f.get(fh);
temp = MultiTainter.taintedIntArray(temp, "tainted");

is equivalent to

MultiTainter.taintedIntArray(f.arr_i,"tainted");

At which point is might be clear that you are neglecting to assign f.arr_i to be the return value of MultiTainter.taintedIntArray, and that you really wanted

f.arr_i=MultiTainter.taintedIntArray(f.arr_i,"tainted");

And that you probably should have an f.set.... in your example code too.

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

from phosphor.

jon-bell avatar jon-bell commented on July 17, 2024

Thanks for your reply. I cannot taint any object directly, as I mentioned before I am extending the phosphor’s MultiTainter to taint the fields of an object using reflection till certain depth.

What does this mean? You are unable to add the line
f.set(fh,MultiTainter.taintedIntArray(temp,"tainted");?

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

Yes I have added, It gives a type casting error. Please look at the code below

package rough_work;

import java.lang.reflect.Field;
import edu.columbia.cs.psl.phosphor.runtime.MultiTainter;
public class rough_work {

public static class ArrayFieldHolder{
	public int[] arr_i = {2,4,5};
}

public static void main(String[] args) throws Exception
{		
	ArrayFieldHolder fh = new ArrayFieldHolder();	
	for (Field f : fh.getClass().getDeclaredFields())
	{
		int[] temp  = (int[])f.get(fh);
		f.set(fh, MultiTainter.taintedIntArray(temp, "tainted"));
	}
	System.out.println(MultiTainter.getTaint(fh.arr_i[1]));
}

}

Error Message:

objc[29226]: Class JavaLaunchHelper is implemented in both /Users/ajaychhokra/Dropbox/Taint_Analysis_isstac/phosphor/Phosphor/target/jre-inst-w-ctrl-data-multi/bin/java and /Users/ajaychhokra/Dropbox/Taint_Analysis_isstac/phosphor/Phosphor/target/jre-inst-w-ctrl-data-multi/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags
at java.lang.Throwable.fillInStackTrace$$PHOSPHORTAGGED(Throwable.java)
at java.lang.Throwable.fillInStackTrace$$PHOSPHORTAGGED(Throwable.java:783)
at java.lang.Throwable.(Throwable.java:265)
at java.lang.Exception.(Exception.java:66)
at java.lang.RuntimeException.(RuntimeException.java:62)
at java.lang.ClassCastException.(ClassCastException.java:58)
at java.lang.ClassCastException.(ClassCastException.java)
at rough_work.rough_work.main$$PHOSPHORTAGGED(rough_work.java:16)
at rough_work.rough_work.main(rough_work.java)

from phosphor.

jon-bell avatar jon-bell commented on July 17, 2024

That's because you are still iterating over every field. Please add the following before the f.get and cast: System.out.println(f.getName() +" " + f.getType());, and observe if you see a field of type long there.

Just as you can not cast from long to int[] normally, when using Phosphor, you can't cast from long to int[].

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

Sorry, I forgot to add the if condition, It does not taint the array components. The code is as follows:

public static void main(String[] args) throws Exception
{
ArrayFieldHolder fh = new ArrayFieldHolder();
for (Field f : fh.getClass().getDeclaredFields())
{
if (f.get(fh).getClass().isArray()){
int[] temp = (int[])f.get(fh);
f.set(fh, MultiTainter.taintedIntArray(temp, "tainted"));
}

	}
	System.out.println(MultiTainter.getTaint(fh.arr_i[1]));  // null
}

I'll really appreciate if you can add a small test case for the same

from phosphor.

jon-bell avatar jon-bell commented on July 17, 2024

OK - thanks for reducing this down to a simpler example. I've pushed a patch.

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

Thanks, for pushing the patch. I am able to taint the array field by using jre-inst-obj JRE but jre-inst-implicit does not taint that field.

from phosphor.

jon-bell avatar jon-bell commented on July 17, 2024

OK

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

Is the issue fixed with jre-inst-implicit (control flow tracking) ?

from phosphor.

jon-bell avatar jon-bell commented on July 17, 2024

Yes - did you see the commit?

from phosphor.

chhokrad avatar chhokrad commented on July 17, 2024

Thanks

from phosphor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.