【发布时间】:2017-04-06 07:05:57
【问题描述】:
在我的 Android 应用程序中,我使用了一个意图来启动一个新活动,如下所示:
private void beginVideoChat()
{
Intent intent = new Intent(ProviderDetailsActivity.this, FragmentContainerActivity.class);
intent.putExtra("CommunicationEnum", Communications.Video);
intent.putExtra("provderId", provider.getProviderId());
this.startActivity(intent);
}
像beginVideoChat() 一样,我还有其他几种方法,在定义意图时,我已经明确指定了类名。
当我的应用程序接受客户端的安全测试时,我遇到了一个名为Intent Manipulation 的安全问题。下面给出相同的描述:
Severity Rating:
Medium
Description:
Allowing user input to control Intent parameters could enable an attacker to control the behavior of the subsequent activity.
Risk:
An intent manipulation issue occurs when the following two conditions are met:
• An attacker is able to specify the action, classname, or component of an Android Intent.
For example, an attacker may be able to specify the classname or the component to handle the intent.
• By specifying the action, classname, or component, the attacker gains a capability that would not otherwise be permitted.
For example, the program may give the attacker the ability to transmit sensitive information to a third-party software on the device.
报告生成的建议修复是:
不要依赖 Intent 过滤器作为安全机制。通过创建专门设计的 Intent 或使用显式 Intent 来绕过这种机制太容易了。
Remediation:
Do not rely on Intent Filters as a security mechanism. It is too easy to bypass this mechanism by creating specially designed Intents or using explicit Intents.
If private or personal data must be sent, always encrypt it using an industry standard encryption algorithm.
Verify that all Activities have a legitimate need to be publicly exported. If not, remove any Intent Filters from the Activity and make sure the android:explicit attribute is set to false.
The best way to secure an Activity is to rely on permission checks. If it is possible, specify a permission on the receiving Activity that will be used to prevent Intents from being received and handled that do not have that specific permission.
按照补救措施中的建议:
如果必须发送私人或个人数据,请始终使用行业标准加密算法对其进行加密 => 我会使用标准加密算法进行加密。
我的问题是如何在不指定意图中的类名的情况下启动任何活动?
另一个查询是:如何对接收活动进行一些权限检查? =>为了解决这个问题,我将使用 Custom Permissions。这是正确的处理方式吗?
提前致谢。
【问题讨论】:
-
“我的问题是如何在没有在意图中指定类名的情况下启动任何活动?” ——这与建议的内容完全背道而驰。清单中
FragmentContainerActivity的<activity>元素上是否有<intent-filter>?另外,请询问您的客户他们用于此测试的内容,因为测试本身存在错误(例如,Android 中没有android:explicit属性)。 “如何对接收活动进行一些权限检查?” -- 如果没有导出活动(例如,有一个<intent-filter>),则不需要。 -
@CommonsWare:是的,清单文件中的 FragmentContainerActivity 上有一个意图过滤器。然而,该报告表明,意图过滤机制很容易被绕过。因此,他们建议将权限与
中的 标记一起用作额外检查。如果活动没有意图,他们建议将活动的 android:explicit 属性设置为 false -过滤器。 -
“是的,清单文件中的 FragmentContainerActivity 上有一个意图过滤器”——去掉
<intent-filter>。 “他们建议将权限与中的 标记一起用作额外检查”——或者,您可以去掉 <intent-filter>。 “如果活动没有意图过滤器,他们建议将活动的 android:explicit 属性设置为 false”——Android SDK 中没有android:explicit。那么,为什么您在此活动中有<intent-filter>?
标签: android android-intent android-permissions