Search code examples
androidsecurityreact-nativeclickjacking

How to solve TapJacking vulnerability in ReactNative app


I know I can apply these property filterTouchesWhenObscured method onFilterTouchEventForSecurity in my view but I want to apply on my every clickable view so how can I apply it..?


Solution

  • I had the need to fix a Tapjacking scenario today. What works for my app is this:

    Eject the app from RN and add this to the MainActivity.java:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        // get the root view and activate touch filtering to prevent tap jacking
        View v = findViewById(android.R.id.content);
        v.setFilterTouchesWhenObscured(true);
    }