【问题标题】:Android Intent manipulation issueAndroid Intent 操作问题
【发布时间】: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


【解决方案1】:

您在beginVideoChat() 中启动活动的方式是可以的,而不是安全警告中的问题:

... 可以使攻击者控制行为 后续活动

这里的问题是所有其他应用可以通过“FragmentContainerActivity”使用任何可能的provderId 开始“视频聊天”。

“FragmentContainerActivity”intent-api 不受滥用调用的保护。

这是否真的是一个安全问题取决于活动及其控制参数的敏感程度。

示例:如果您有一个主要活动首先调用 login-activity 然后调用 video-chat-activity 那么可以在不登录的情况下打开 video-chat-activity。

【讨论】:

  • 感谢您的回复。您能否建议一些机制来编码我们使用 putExtra() 方法发送到另一个活动的数据?
  • 当其他应用调用“视频聊天”时,您真的有安全问题吗?如果您想防止“视频聊天”在未登录的情况下被呼叫,您可以将用户 ID 和密码哈希作为附加参数,以便后续活动进行验证。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多