セキュリティ

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(Omi Chiba)

セキュリティ

The Open Web Application Security Project (OWASP)は、アプリケーションソフトウェアのセキュリティを向上させることに焦点を置いた、自由で開かれた世界的なコミュニティです。

The Open Web Application Security Project19 (OWASP) is a free and open worldwide community focused on improving the security of application software.

OWASPでは、Webアプリケーションのリスクとなるセキュリティ問題のトップ10を挙げています。ここではこのリストを、web2pyがどのようにこれらの問題を解決しているかという説明とともに、再掲します:

OWASP has listed the top ten security issues that put web applications at risk. That list is reproduced here, along with a description of how each issue is addressed by web2py:

    • "クロスサイトスクリプティング(XSS):アプリケーションがユーザからデータを受信して、そのデータに対して検証やエンコードを行わずにブラウザに送信した時には、常にXSSの脆弱性が発生します。XSSは、セッションのハイジャック、Webサイトの改ざん、ワーム侵入の許可を可能にするような、犠牲となるブラウザ上で動くスクリプトを攻撃者が実行できるようにしてしまいます"。web2pyはデフォルトで、ビューに表示されるすべての変数をエスケープすることでXSSを防ぎます。

  • "Cross Site Scripting (XSS): XSS flaws occur whenever an application takes user supplied data and sends it to a web browser without first validating or encoding that content. XSS allows attackers to execute scripts in the victim's browser which can hijack user sessions, deface web sites, possibly introduce worms, etc." web2py, by default, escapes all variables rendered in the view, preventing XSS.

  • "インジェクションフロー:インジェクションフロー、特にSQLインジェクションは、Webアプリケーションで一般的なものです。インジェクションは、ユーザーが入力したデータをコマンドまたはクエリの一部としてインタプリタに送信するときに発生します。攻撃者の不正なデータはインタプリタに対して意図しないコマンドやデータの変更を実行させます"。web2pyには、データベース抽象化レイヤが含まれてて、それがSQLインジェクションを防ぎます。通常は、SQL文は開発者によって書かれません。代わりにSQLはDALによって動的に生成され、すべての挿入データが適切にエスケープされることを保証します。

  • "Injection Flaws: Injection flaws, particularly SQL injection, are common in web applications. Injection occurs when user-supplied data is sent to an interpreter as part of a command or query. The attacker's hostile data tricks the interpreter into executing unintended commands or changing data." web2py includes a Database Abstraction Layer that makes SQL injection impossible. Normally, SQL statements are not written by the developer. Instead, SQL is generated dynamically by the DAL, ensuring that all inserted data is properly escaped.

  • "悪意のあるファイルの実行:脆弱なコードによるリモートファイルのインクルード(RFI)は、悪意のあるコードやデータを持ち込ませることを許し、サーバー全体を危険にさらすような破壊的な攻撃につながります"。web2pyは公開するコードのみ実行を許可し、悪意のあるファイルの実行を防止します。インポートされた関数は決して公開されません。つまり、アクションのみが公開されます。Webベースの管理インターフェースを用いると、何が公開されているのか、いないのかを把握するのが容易になります。

    • "Malicious File Execution: Code vulnerable to remote file inclusion (RFI) allows attackers to include hostile code and data, resulting in devastating attacks, such as total server compromise." web2py allows only exposed functions to be executed, preventing malicious file execution. Imported functions are never exposed; only actions are exposed. web2py uses a Web-based administration interface which makes it very easy to keep track of what is exposed and what is not.

  • "安全でない直接オブジェクト参照:直接オブジェクト参照とは、開発者が内部実装のオブジェクト、たとえば、ファイル、ディレクトリ、データベースのレコード、キーなどへの参照を、URLやフォームのパラメータとして公開したときに起こるものです。攻撃者は、それらの参照を操作することができ、認証なしに他のオブジェクトにアクセスすることができます"。web2pyはいかなる内部オブジェクトも公開しません。さらに、すべてのURLを検証し、ディレクトリ走査の攻撃を防ぎます。web2pyはまた、すべての入力値を自動的に検証するフォームを作成するメカニズムを提供します。

    • "Insecure Direct Object Reference: A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, database record, or key, as a URL or form parameter. Attackers can manipulate those references to access other objects without authorization." web2py does not expose any internal objects; moreover, web2py validates all URLs, thus preventing directory traversal attacks. web2py also provides a simple mechanism to create forms that automatically validate all input values.

  • "クロスサイトリクエストフォージェリ(CSRF):CSRF攻撃はログイン処理が行われた犠牲者のブラウザに、事前に認証されたリクエストを、脆弱なWebアプリケーションに送信させます。これにより、犠牲者のブラウザは、攻撃者の利益となる悪意のあるアクションを実行させられます。CSRFは攻撃を行うWebアプリケーションと同じくらい強力です"。web2pyはCSRFとともに、偶発的なフォームの二重投稿も防ぎます。これは、一度きりのランダムトークンを各フォームに対して割り当てることで実現されます。さらに、web2pyはUUIDをセッションCookieとして使用しています。

    • "Cross Site Request Forgery (CSRF): A CSRF attack forces a logged-on victim's browser to send a pre-authenticated request to a vulnerable web application, which then forces the victim's browser to perform a hostile action to the benefit of the attacker. CSRF can be as powerful as the web application that it attacks." web2py prevents CSRF as well as accidental double submission of forms by assigning a one-time random token to each form. Moreover web2py uses UUID for session cookie.

  • 情報漏洩と、不適切なエラー処理:アプリケーションは、設定や内部資料などの情報を意図せず漏洩したり、さまざまなアプリケーションの問題によりプライバシーの侵害を起こす恐れがあります。攻撃者はこの弱点を利用して機密データを盗み、より深刻な攻撃を実施します"。web2pyはチケットシステムを持っています。どんなエラーでも、コードがユーザーにさらされることはありません。すべてのエラーはログに記録され、エラーの追跡を可能するためのチケットがユーザーに発行されます。しかし、エラーとソースコードに対しては管理者しかアクセスできません。

  • "Information Leakage and Improper Error Handling: Applications can unintentionally leak information about their configuration, internal workings, or violate privacy through a variety of application problems. Attackers use this weakness to steal sensitive data, or conduct more serious attacks." web2py includes a ticketing system. No error can result in code being exposed to the users. All errors are logged and a ticket is issued to the user that allows error tracking. But errors and source code are accessible only to the administrator.

  • "不適切な認証やセッション管理:アカウントのトークンやセッションのトークンは、しばしば適切に保護されません。攻撃者はパスワード、キー、認証トークンなどを侵害し、他のユーザーに成りすまします"。web2pyでは、管理者認証のための組み込み機構を提供します。そこでは、アプリケーションごとにセッションが独立に管理されます。管理インターフェイスでは、"localhost"からではないクライアントからの接続には、セキュアなセッションクッキーの使用を強制します。アプリケーションに対しては、強力なロールベースのアクセスコントロールAPIを用意しています。

    • "Broken Authentication and Session Management: Account credentials and session tokens are often not properly protected. Attackers compromise passwords, keys, or authentication tokens to assume other users' identities." web2py provides a built-in mechanism for administrator authentication, and it manages sessions independently for each application. The administrative interface also forces the use of secure session cookies when the client is not "localhost". For applications, it includes a powerful Role Based Access Control API.

  • "安全でない暗号保存:Webアプリケーションにおいて、データや機密情報を保護するための暗号化関数を適切に利用しているものはほとんどありません。攻撃者は、弱く保護されたデータから、身元情報の盗難や、クレジットカード詐欺などの他の犯罪を実施します"。web2pyでは、保存したパスワードを保護するために、MD5やHMAC+SHA-512のハッシュアルゴリズムを使用しています。他のアルゴリズムも利用可能です。

    • "Insecure Cryptographic Storage: Web applications rarely use cryptographic functions properly to protect data and credentials. Attackers use weakly protected data to conduct identity theft and other crimes, such as credit card fraud." web2py uses the MD5 or the HMAC+SHA-512 hash algorithms to protect stored passwords. Other algorithms are also available.

  • "安全でない通信:アプリケーションは、機密情報の通信を保護する必要になったとき、ネットワークトラフィックの暗号化をたびたび怠ることがあります"。web2pyは、SSLが有効なRocket WSGI サーバーを用意していますが、SSLの暗号化通信を提供するApacheやLigthttpdとmod_sslを用いることができます。

  • "Insecure Communications: Applications frequently fail to encrypt network traffic when it is necessary to protect sensitive communications." web2py includes the SSL-enabled21 Rocket WSGI server, but it can also use Apache or Lighttpd and mod_ssl to provide SSL encryption of communications.

  • "URLアクセス制限の失敗:よく見かけるのは、重要な機能を、非認証ユーザーに対して、リンクやURLの表示を防ぐだけで保護しているものです。攻撃者はこの弱点を利用することができ、URLを直接叩くことで、認証されていない操作にアクセスし実行します"。web2pyはURLリクエストをPythonのモジュールと関数へ対応付けします。そして、どの関数が公開され、どれが認証や権限が必要かを宣言するメカニズムを用意しています。組み込みのロールベースのアクセスコントロールAPIは、任意の関数へのアクセスを、ログインやグループメンバーシップ、グループベースの権限に基づいて制限することを可能にします。その権限はとても細かい粒度で行われ、また、CRUDと組み合わせて、たとえば、特定のテーブル、または/かつ、レコードへのアクセス権限を与えることができます。

    • "Failure to Restrict URL Access: Frequently an application only protects sensitive functionality by preventing the display of links or URLs to unauthorized users. Attackers can use this weakness to access and perform unauthorized operations by accessing those URLs directly." web2py maps URL requests to Python modules and functions. web2py provides a mechanism for declaring which functions are public and which require authentication and authorization. The included Role Based Access Control API allow developers to restrict access to any function based on login, group membership or group based permissions. The permissions are very granular and can be combined with CRUD to allow, for example, to give access to specific tables and/or records.

web2pyはセキュリティに対する論評を受けています。その評価は参照で見ることができます。

web2py was reviewed for security and you can find the result of the review in ref.20.