This lab illustrates how to prevent intra-app IPC intent eavesdropping with explicit intent instead of implicit intent.
There are two types of intents:
In the previous hands-on lab, the information attached on an implicit intent can be eavesdropped by a malicious app. Hence if communication happens inside one app, we should use an explicit intent with a specified receiver.
MainActivity.java
package example.com.interappsender;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText email, phone;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
email = findViewById(R.id.email);
phone = findViewById(R.id.phone);
}
public void onClick(View view) {
Intent intent = new Intent(this,MyReceiver.class);
intent.putExtra("Email",email.getText().toString());
intent.putExtra("Phone",phone.getText().toString());
sendBroadcast(intent);
}
}
After modifying the implicit intent to explicit intent, the malicious app cannot eavesdrop the sensitive information which attached on the intent.