Skip to content

Latest commit

 

History

History
151 lines (112 loc) · 13.7 KB

0xm8-M8-Code Tampering.md

File metadata and controls

151 lines (112 loc) · 13.7 KB

M8:コード改ざん

                   
脅威エージェント 攻撃経路 セキュリティ上の弱点 技術的な影響 ビジネスへの影響
アプリ依存 攻撃難易度
容易
蔓延度
検出難易度
普通
影響度
重大
アプリ / ビジネス依存
通常、攻撃者は第三者のアプリストアに配置されたアプリケーションを、コード改ざんの標的にします。さらに、攻撃者は、フィッシング攻撃でユーザをだましてアプリケーションをインストールさせるかもしれません。通常、攻撃者はコード改ざん攻撃で以下のようなことを行います。
  • アプリケーションパッケージのコアバイナリに対して、直接バイナリ変更を加える。
  • アプリケーションパッケージ内のリソースに対して、直接バイナリ変更を加える。
  • システムAPIをリダイレクトまたは置換して、傍受したり悪質な外部コードを実行したりする。
改ざんされたアプリケーションは、意外にも想像以上に存在します。セキュリティ業界全体で、アプリストア内に許可されていないバージョンのモバイルアプリケーションが存在しないか検知して取り除くことが必須となっています。コード改ざん検知の問題解決アプローチの仕方によって、高い成功率で、不正なバージョンのアプリケーションの検知ができるようになります。
本カテゴリは、バイナリ更新、ローカルリソースの改ざん、メソッドフッキング、メソッドスウィズリング、動的メモリ改ざんについて記載します。
アプリケーションがモバイルデバイスに一旦配信されると、コードとデータといったリソースは端末に常駐することになります。攻撃者は、そのコードを直接改ざんしたり、メモリ内容を動的に改ざんしたり、アプリケーションが使用するシステムAPIを変更や置換したり、アプリケーションのデータやリソースを改ざんしたりすることが可能です。これにより攻撃者は、個人的利益もしくは金銭的利益のために、ソフトウェアが本来意図している使用方法を直接覆すことができるようになります。
コード改ざんによる影響は、改ざんされたもの自身の性質によりますが、広範囲に及ぶ可能性があります。典型的な影響は以下です。
       
  • 不正な新機能
  • なりすまし犯罪
  • 詐欺
コード改ざんによるビジネスへの影響は以下の結果につながります。
  • 海賊版による収入減
  • 風評被害

脆弱性有無の確認

技術的に、全てのモバイルコードはコード改ざんに対して脆弱です。モバイルコードはコードを作成した組織以外の環境下で実行されるからです。と同時に、コードが実行される環境を変更する方法もたくさん存在しているため、攻撃者は自由自在にコードを改ざんすることが可能となるのです。

モバイルコードは本質的に脆弱ですが、不正なコード改ざんを検出して防止するに値するアプリかどうかを問うことは重要です。あるビジネス分野のアプリケーション(例えばゲーム産業など)は、他のもの(例えばホスピタリティ産業など)よりもコート改ざんによる影響に対して脆弱です。そのため、このリスクに対処するかどうかを決定する前にビジネスへの影響を考慮することが非常に重要です。

防止方法

モバイルアプリケーションは、コンパイル時の完全版と比べてコードが追加、変更されていることを実行中に検出できなければなりません。アプリケーションは実行時、コードの完全性違反に適切に対応する必要があります。

このタイプのリスクを改善するための戦略は、OWASPのリバースエンジニアリングとコード改ざん防止プロジェクトに、技術的な詳細が記述されています。

Androidのroot検知

通常、改ざんされたアプリケーションはJailbreakされたもしくはroot化された環境で実行されます。したがって、実行時にこれらの危険な環境を検出し、それに応じて対処(サーバへの通知、もしくはシャットダウン)することが妥当です。root化されたAndroidデバイスを検出するために、以下のような一般的な方法が存在します。

テストキーのチェック

  • build.properties等に、開発用のビルドもしくは非公式のROMを示すro.build.tags=test-keyのような行が含まれていないかどうか確認する。

OTA証明書のチェック

  • /etc/security/otacerts.zipファイルが存在するか確認する。

既知のroot化されたAPKのチェック

  • com.noshufou.android.su
  • com.thirdparty.superuser
  • eu.chainfire.supersu
  • com.koushikdutta.superuser

SUバイナリのチェック

  • /system/bin/su
  • /system/xbin/su
  • /sbin/su
  • /system/su
  • /system/bin/.ext/.su

SUコマンドを直接実行してみる

  • suコマンドを実行し、カレントユーザのIDをチェックする。もし「0」が返ってくるなら、suコマンドは成功している。  

iOSのJailbreak検知

攻撃シナリオの例

アプリストアでは、偽のアプリケーションが多数、入手可能となっています。マルウェアのペイロードが含まれている場合もあります。改ざんされたアプリケーションのほとんどが、オリジナルのコアバイナリや関連リソースが改ざんされています。攻撃者は、これらを新たなアプリケーションとしてリパッケージし、第三者のアプリストアにリリースします。

シナリオ# 1:
ゲームは、本メソッドを使って非常に多く攻撃されるターゲットです。攻撃者は、ゲームなどのフリーミアムな機能にも課金したくない人々を寄せつけるでしょう。コード内で、攻撃者はアプリケーション内購入が成功したかどうかを検出する条件分岐を回避します。この迂回のおかげで、カモとなった人たちは、課金しなければ得られないゲームの道具や新しい能力を獲得することができます。しかも攻撃者はユーザのIDを盗むスパイウェアを注入しています。

シナリオ# 2:
銀行アプリケーションも非常に多く攻撃されます。これらのアプリは通常、攻撃者にとって有益な機密情報を扱っています。攻撃者は、第三者のサイトへユーザ名/パスワードと共にユーザの個人識別情報(PII)を送信する、偽バージョンのアプリケーションを作成することができます。これは、Zeusマルウェアのデスクトップ版を思い出させます。これは通常、銀行を標的とした詐欺につながります。

参考資料

OWASP

外部リンク

  1. Arxan Research: State of Security in the App Economy, Volume 2, November 2013:   "Adversaries have hacked 78 percent of the top 100 paid Android and iOS apps in 2013."

  2. HP Research: HP Research Reveals Nine out of 10 Mobile Applications Vulnerable to Attack, 18 November 2013:  "86 percent of applications tested lacked binary hardening, leaving applications vulnerable to information disclosure, buffer overflows and poor performance. To ensure security throughout the life cycle of the application, it is essential to build in the best security practices from conception."

  3. North Carolina State University: Dissecting Android Malware: Characterization and Evolution, 7 September 2011:   "Our results show that 86.0% of them (Android Malware) repackage legitimate apps to include malicious payloads; 36.7% contain platform-level exploits to escalate privilege; 93.0% exhibit the bot-like capability."

  4. Tech Hive: Apple Pulls Ripoff Apps from its Walled GardenFeb 4th, 2012:  "While Apple is known for screening apps before they are allowed to sprout up in its walled garden, clearly fake apps do get in. Once they do, getting them out depends on developers who raise a fuss."

  5. Tech Crunch: Developer Spams Google Play With RipOffs of Well-Known Apps… Again, January 2 2014:  "It's not uncommon to search the Google Play app store and find a number of knock-off or "fake" apps aiming to trick unsuspecting searchers into downloading them over the real thing."

  6. Extreme Tech: Chinese App Store Offers Pirated iOS Apps Without the Need To Jailbreak, April 19 2013:  "The site offers apps for free that would otherwise cost money, including big-name titles."

  7. OWASP: Architectural Principles That Prevent Code Modification or Reverse Engineering, January 11th 2014.

  8. Gartner report: Avoiding Mobile App Development Security Pitfalls, 24 May 2013:  "For critical applications, such as transactional ones and sensitive enterprise applications, hardening should be used."

  9. Gartner report: Emerging Technology Analysis: Mobile Application Shielding, March 26th, 2013:  "As more regulated and sensitive data applications move to mobile platforms the need to increase data protection increases. Mobile application shielding presents the opportunity to security providers to offer higher data protection standards to mobile platforms that exceed mobile OS security."

  10. Gartner report: Proliferating Mobile Transaction Attack Vectors and What to Do About Them, March 1st, 2013:  "Use mobile application security testing services and self-defending application utilities to help prevent hacking attempts."

  11. Gartner report: Select a Secure Mobile Wallet for Proximity, March 1st, 2013:  "Application hardening can fortify sensitive business code against hacking attempts, such as reverse engineering"

  12. Forrester paper: Choose The Right Mobile Development Solutions For Your Organization, May 6th 2013:  "5 Key Protections: Data Protection, App Compliance, App-Level Threat Defense, Security Policy Enforcement, App Integrity"

  13. John Wiley and Sons, Inc: iOS Hacker's Handbook, Published May 2012, ISBN 1118204123.

  14. McGraw Hill Education: Mobile Hacking Exposed, Published July 2013, ISBN 0071817018.

  15. Publisher Unannounced: Android Hacker's Handbook, To Be Published April 2014.

  16. Software Development Times: More than 5,000 apps in the Google Play Store are copied APKs, or 'thief-ware', November 20 2013:  http://sdt.bz/66393#ixzz2sHa7dFMp  "In most cases, the 2,140 copycat developers that were found reassembled the apps almost identically, adding new advertising SDKs to siphon profits away from the original developers.

  17. InfoSecurity Magazine: Two Thirds of Personal Banking Apps Found Full of Vulnerabilities, January 3 2014:   "But one of his more worrying findings came from disassembling the apps themselves ... what he found was hardcoded development credentials within the code. An attacker could gain access to the development infrastructure of the bank and infest the application with malware causing a massive infection for all of the application’s users."

  18. InfoSecurity Magazine: Mobile Malware Infects Millions; LTE Spurs Growth, January 29 2014:  "Number of mobile malware samples is growing at a rapid clip, increasing by 20-fold in 2013... It is trivial for an attacker to hijack a legitimate Android application, inject malware into it and redistribute it for consumption. There are now binder kits available that will allow an attacker to automatically inject malware into an existing application"