セキュアコーディングガイドライン:ユーザーエージェントの指定について

■質問■
セキュアコーディングガイドライン:ユーザーエージェントの指定について

セキュアコーディングガイドラインに記載の「適切なユーザーエージェントの設定」とは、例えばkintoneに接続する外部サーバー側で実装すべき内容なのか、もしくはkintone上で動作するアプリで実装すべき(Java Script実装して、クライアントのブラウザで動作する)なのかがわからず困っております。

ユーザーエージェントは、接続元のOSやブラウザを識別するログの情報というくらいにしか理解できていません。

実装例など参考情報をご存知の方がいらっしゃいましたら、ご教授いただけませんでしょうか。。

また、これによりセキュアになる理由が理解できていないのですが、どのようなケースを想定すれば良いでしょうか?

例えば、User Agentを指定することによって、cybozu側で当該サービスの利用ユーザーが把握できるので、例えば当該サービスがクラックされて不正にサービスを利用してcybozuに負荷のかかるようなアクセスしているような状況が発生した時に、検知しやすいといった理解で良いでしょうか?

========================================
https://developer.cybozu.io/hc/ja/articles/201919400-セキュアコーディング-ガイドライン

適切なユーザーエージェントを設定する

どのようなサービスやツールからリクエストを送信しているか判別可能にするために、適切なユーザーエージェント(User-Agent ヘッダー)を設定してください。

ユーザーエージェントのガイドラインについては、以下のRFC 7231の"User-Agent"の項をご参照ください。

  • RFC 7231 5.5.3. User-Agent http://www.ietf.org/rfc/rfc7231.txt

    5.5.3. User-Agent

     The "User-Agent" header field contains information about the user
     agent originating the request, which is often used by servers to help
     identify the scope of reported interoperability problems, to work
     around or tailor responses to avoid particular user agent
     limitations, and for analytics regarding browser or operating system
     use. A user agent SHOULD send a User-Agent field in each request
     unless specifically configured not to do so.
    
       User-Agent = product *( RWS ( product / comment ) )
    
     The User-Agent field-value consists of one or more product
     identifiers, each followed by zero or more comments (Section 3.2 of
     [RFC7230]), which together identify the user agent software and its
     significant subproducts. By convention, the product identifiers are
     listed in decreasing order of their significance for identifying the
     user agent software. Each product identifier consists of a name and
     optional version.
    
       product = token ["/" product-version]
       product-version = token
    
     A sender SHOULD limit generated product identifiers to what is
     necessary to identify the product; a sender MUST NOT generate
     advertising or other nonessential information within the product
     identifier. A sender SHOULD NOT generate information in
     product-version that is not a version identifier (i.e., successive
     versions of the same product name ought to differ only in the
     product-version portion of the product identifier).
    
     Example:
    
       User-Agent: CERN-LineMode/2.15 libwww/2.17b3
    

> User Agentを指定することによって、cybozu側で当該サービスの利用ユーザーが把握できるので、例えば当該サービスがクラックされて不正にサービスを利用してcybozuに負荷のかかるようなアクセスしているような状況が発生した時に、検知しやすいといった理解で良いでしょうか?

そういったケースや、自前のMobileアプリがkintoneだけじゃなく自前のサーバーにもアクセスがありうる、といったケースでも特定はしやすいので有効だと思います。

 

基本的に、公式アプリや通常のブラウザのみでkintoneを利用している場合は気にしなくていいものです。自前のモバイルアプリからkintoneにアクセスする、バッチなどのために自前のサーバーからPHPなどを使ってkintoneにアクセスする、などのときに、ちゃんとしたUserAgentを指定してる方がいいですよ、という認識でいいかと思います。

 

 

村濱様

ご助言、ありがとうございます。

ブラウザでは無く、Mobileアプリからの接続の場合を考えておりませんでした。
Mobileアプリの実装で、ユーザーエージェントを指定するということで理解しました。
実装方法はMobileアプリ開発時のUser Agent 指定方法で探せば見つかりそうです。

また、自前のサーバー側でアクセス解析する際にも接続元のエージェントがわかると解析しやすいですね。

大変、勉強になりました。