Why this matters
Intent redirection occurs when an app exposes an intent-processing component that can be manipulated by malicious applications, leading to security risks.
Ensure that applications do not expose intent-processing components that can be manipulated by other applications.
Intent redirection occurs when an app exposes an intent-processing component that can be manipulated by malicious applications, leading to security risks.
Side-by-side examples engineers can pattern-match during review.
public class Noncompliant extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Intent forward = (Intent) intent.getParcelableExtra("anotherintent");
startActivity(forward); // Noncompliant
}
}public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Intent forward = (Intent) intent.getParcelableExtra("anotherintent");
ComponentName title = forward.resolveActivity(getPackageManager());
if (title.getPackageName().equals("safePackage") &&
title.getClassName().equals("safeClass")) {
startActivity(forward);
}
}
}public class Noncompliant extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Intent forward = (Intent) intent.getParcelableExtra("anotherintent");
startActivity(forward); // Noncompliant
}
}public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Intent forward = (Intent) intent.getParcelableExtra("anotherintent");
ComponentName title = forward.resolveActivity(getPackageManager());
if (title.getPackageName().equals("safePackage") &&
title.getClassName().equals("safeClass")) {
startActivity(forward);
}
}
}From the same buckets as this rule.