有人將如何防止針對 API 機密/ API 密鑰的 MITM 型別攻擊?facebook/instagram 如何保護他們的用戶免受 MITM 型別的黑客攻擊?
他們甚至保護用戶嗎?或者他們認為任何可能的攻擊都應該由用戶承擔?
uj5u.com熱心網友回復:
我的答案的一些背景
我假設您的問題是在移動應用程式的背景關系中,因此我的回答將展示如何針對為移動應用程式提供服務的 API 防止中間人攻擊以及如何繞過它。
您的 Facebook/Instagram 相關問題
facebook/instagram 如何保護他們的用戶免受 MITM 型別的黑客攻擊?
他們甚至保護用戶嗎?或者他們認為任何可能的攻擊都應該由用戶承擔?
這個問題最好由 Facebook/Instagram 的內部人員或在他們的移動應用程式和 API 上做了大量作業的安全研究人員回答。
很抱歉不能在這里向您解釋。
防止中間人攻擊
有人將如何防止針對 API 機密/ API 密鑰的 MITM 型別攻擊?
我可以通過使用證書公鑰鎖定證書來幫助您并快速回復它,我們將在下面詳細介紹。
在第一種情況下,您需要通過將移動應用程式配置為僅與 API 建立連接來保護 HTTPS 通信通道,在 TLS 握手期間,如果它提供為其域頒發的證書并且該證書為移動設備所知和信任應用程式,忽略根據對設備的證書信任存盤的驗證可能仍然有效的任何其他應用程式。我在我寫的使用證書鎖定保護 HTTPS的文章中詳細介紹了它以及如何實作它:
為了演示如何使用證書鎖定來保護您的移動應用程式和 API 服務器之間的 https 流量,我們將使用我在上一篇文章中使用的相同貨幣轉換器演示移動應用程式。
在本文中,我們將了解什么是證書鎖定、何時使用它、如何在 Android 應用程式中實作它以及它如何防止中間人攻擊。
釘什么?
我將參考同一篇文章:
固定的最簡單方法是使用服務器的公鑰或該公鑰的散列,散列公鑰是最靈活和可維護的方法,因為它允許證書在服務器中輪換,通過使用相同的簽名新的公鑰。因此,移動應用程式不必用新的 PIN 更新,因為新證書公鑰的哈希值將繼續與網路安全組態檔中提供的 PIN 匹配。稍后我們將在討論如何設定證書鎖定時看到一個示例。
實作靜態證書固定
在移動應用程式中實作靜態證書固定的最簡單快捷的方法是使用移動證書固定生成器,它接受您想要固定的域串列,并為您生成正確的證書固定配置以在 Android 和IOS。
給它一個要固定的域串列:

該工具會為您生成 Android 配置:

還有 iOS 配置:

該工具甚至作為如何將配置添加到您的移動應用程式的說明,您可以在證書固定配置框下方找到。他們還提供了適用于Android和iOS 的實體 Pin 測驗應用程式,這是一個分步教程。
繞過證書鎖定
It's important that any developer that decides to implement certificate pinning in their mobile apps also understands how it can be bypassed in order to learn the threat model and evaluate if further protections are needed to prevent certificate pinning bypass.
I wrote two articles on how to bypass certificate pinning on Android where you can learn in one of them how to do it by extracting, modifying and repackaging the APK, while in the other article you learn how to use the Frida instrumentation framework to hook at runtime into the mobile app in order to bypass certificate pinning:
Bypassing Certificate Pinning on Android via APK
In this article you will learn how to repackage a mobile app in order to make it trust custom ssl certificates. This will allow us to bypass certificate pinning.
How to Bypass Certificate Pinning with Frida on an Android App:
Today I will show how to use the Frida instrumentation framework to hook into the mobile app at runtime and instrument the code in order to perform a successful MitM attack even when the mobile app has implemented certificate pinning.
Bypassing certificate pinning is not too hard, just a little laborious, and allows an attacker to understand in detail how a mobile app communicates with its API, and then use that same knowledge to automate attacks or build other services around it.
Summary
Despite being possible to bypass certificate pinning I still strongly recommend you to implement it in your mobile app, because it reduces a lot the attack surface of your mobile app.
Being aware of how certificate pinning can be bypassed gives you the insights to decide if further protections are needed to be in place. Dynamic certificate pinning and Runtime Application Self-Protection(RASP) may be the next steps to take in your security ladder.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/327402.html
